Commit 9353bc9e authored by Mathieu's avatar Mathieu
Browse files

Merge branch 'master' of github.com:openmole/openmole

parents 74c0e75c f44f5174
......@@ -225,7 +225,7 @@ object DocumentationPages {
lazy val container = DocumentationPage.fromScalatex(name = "Linux Executable", content = scalatex.documentation.embed.Container)
// Explore
def explorePages = pageNode(explore, Vector(samplings, calibration, sensitivity, profile, pse))
def explorePages = pageNode(explore, Vector(samplings, calibration, sensitivity, profile, pse, ose))
lazy val explore = DocumentationPage.fromScalatex(name = "Explore", content = scalatex.documentation.explore.Explore, title = Some("Explore Your Model"))
......@@ -248,6 +248,7 @@ object DocumentationPages {
lazy val sensitivity = DocumentationPage.fromScalatex(name = "Sensitivity", content = scalatex.documentation.explore.Sensitivity, title = Some("Stastistical Sensitivity Analysis"))
lazy val profile = DocumentationPage.fromScalatex(name = "Profile", content = scalatex.documentation.explore.Profile)
lazy val pse = DocumentationPage.fromScalatex(name = "PSE", content = scalatex.documentation.explore.PSE, title = Some("Pattern Space Exploration"))
lazy val ose = DocumentationPage.fromScalatex(name = "OSE", content = scalatex.documentation.explore.OSE, title = Some("Origin Space Exploration"))
// Scale
def scalePages = pageNode(scale, Vector(multithread, ssh, cluster, egi))
......
@import org.openmole.site.tools._
@import org.openmole.site._
@import org.openmole.site.stylesheet._
@import DocumentationPages._
@h2{OSE description}
The Origin Space Exploration (OSE) method is used to @b{explore the multiples antecedents of a pattern}. Input parameter values which produce a given pattern are selected. OSE optimize the fitness and when it founds solutions that are good enough it keep them and blacklist the part of the inputs space containing these solution. The optimization process keep going in order to find multiple solution producing the pattern.
@h3{Exemple}
Here is a use example of the OSE method in an OpenMOLE script:
@br@br
@hl.openmole("""
// Seed declaration for random number generation
val myseed = Val[Int]
val param1 = Val[Double]
val param2 = Val[Double]
val output1 = Val[Double]
val output2 = Val[Double]
// PSE method
OSEEvolution(
evaluation = modelTask,
parallelism = 10,
termination = 100,
origin = Seq(
param1 in (0.0 to 1.0 by 0.1),
param2 in (-10.0 to 10.0 by 1.0)),
objectives = Seq(
output1 under 5.0,
output2 under 50.0),
stochastic = Stochastic(seed = myseed)
) hook (workDirectory / "results", frequency = 100)
""", name = "OSE", header = "val modelTask = EmptyTask()")
@i{origin} describes the discrete space of possible origins. Each cell is considered a potential origin. @i{objectives} describe the pattern to reach with inequalities. The sought patten is considered as reached when all the objective are under their threshold value. In this example OSE computes a maximal diversity of inputs for which all the outputs are under their respective threshold values.
\ No newline at end of file
......@@ -83,7 +83,12 @@ Here is a use example of the PSE method in an OpenMOLE script:
@hl.openmole("""
// Seed declaration for random number generation
val myseed =Val[Int]
val myseed = Val[Int]
val param1 = Val[Double]
val param2 = Val[Double]
val output1 = Val[Double]
val output2 = Val[Double]
// PSE method
PSEEvolution(
......@@ -98,7 +103,7 @@ PSEEvolution(
output2 in (0.0 to 4000.0 by 50.0)),
stochastic = Stochastic(seed = myseed)
) hook (workDirectory / "results", frequency = 100)
""", name = "PSE")
""", name = "PSE", header = "val modelTask = EmptyTask()")
@br
......
......@@ -46,9 +46,7 @@ class AuthenticationPanel {
lazy val authenticationSelector: Options[AuthenticationPluginFactory] = {
val factories = Plugins.authenticationFactories.now
val currentInd = {
val ind = factories.map {
_.name
}.indexOf(currentFactory.name)
val ind = factories.map { _.name }.indexOf(currentFactory.name)
if (ind == -1) 0 else ind
}
......
......@@ -216,7 +216,7 @@ class ExecutionPanel {
VarCell(tags.span(tags.span(Utils.longToDate(staticInf(execID).startDate)).tooltip("Starting time")), 1),
VarCell(tags.span(glyphAndText(glyph_flash, details.running.toString).tooltip("Running jobs")), 2),
VarCell(tags.span(glyphAndText(glyph_flag, details.ratio.toString).tooltip("Finished/Total jobs")), 3),
VarCell(tags.span(tags.span(durationString).tooltip("Elapsed time")), 4),
VarCell(tags.span(tags.span(durationString).tooltip("Execution time")), 4),
VarCell(tags.span(subLink(SubCompile, execID, execStatus, defaultModifier = executionState(info)).tooltip("Execution state")), 5),
VarCell(tags.span(subLink(SubEnvironment, execID, "Executions").tooltip("Computation environment details")), 6),
VarCell(tags.span(subLink(SubOutput, execID, glyphicon = glyph_list).tooltip("Standard output")), 7),
......
......@@ -150,7 +150,7 @@ class JobTable(executionId: ExecutionId) {
}
}, errOpen.map { _.getOrElse(EnvironmentId(i), false) })),
bsTableStyle = BSTableStyle(tableStyle = `class` := "table executionTable")
).addHeaders("Name", "Elapsed time", "Uploads", "Downloads", "Submitted", "Running", "Finished", "Failed", "Errors")
).addHeaders("Name", "Execution time", "Uploads", "Downloads", "Submitted", "Running", "Finished", "Failed", "Errors")
.render(minWidth := 1000)
}
......
......@@ -211,13 +211,13 @@ class FileToolBar(treeNodePanel: TreeNodePanel) {
def resetFilterThresold = {
thresholdInput.value = "1000"
thresholdChanged() = true
thresholdChanged() = true
}
def resetFilterTools: Unit = {
Try {
val th = thresholdInput.value.toInt
if ( th > 1000 || thresholdInput.value == "") resetFilterThresold
if (th > 1000 || thresholdInput.value == "") resetFilterThresold
else thresholdChanged() = false
} match {
case Failure(exception)
......
......@@ -10,6 +10,7 @@ import org.openmole.gui.server.core.Utils._
import org.openmole.gui.ext.data
import org.openmole.gui.ext.data._
import java.io._
import java.net.URL
import java.nio.file._
import java.util.zip.GZIPInputStream
......@@ -528,8 +529,14 @@ class ApiImpl(s: Services, applicationControl: ApplicationControl) extends Api {
val result =
Try {
gridscale.http.getResponse(url) { response
def extractName = url.split("/").last
val checkedURL =
java.net.URI.create(url).getScheme match {
case null "http://" + url
case _ url
}
gridscale.http.getResponse(checkedURL) { response
def extractName = checkedURL.split("/").last
val name =
response.headers.flatMap {
case ("Content-Disposition", value)
......@@ -539,16 +546,19 @@ class ApiImpl(s: Services, applicationControl: ApplicationControl) extends Api {
}
case _ None
}.headOption.getOrElse(extractName)
val dest = safePathToFile(path / name)(ServerFileSystemContext.project, workspace)
val is = response.inputStream
if (extract) {
val dest = safePathToFile(path)(ServerFileSystemContext.project, workspace)
val tis = new TarInputStream(new GZIPInputStream(is))
try tis.extract(dest)
finally tis.close
}
else dest.withOutputStream(os copy(is, os))
else {
val dest = safePathToFile(path / name)(ServerFileSystemContext.project, workspace)
dest.withOutputStream(os copy(is, os))
}
}
}
......
......@@ -98,8 +98,9 @@ object BatchEnvironment {
}
val MemorySizeForRuntime = ConfigurationLocation("BatchEnvironment", "MemorySizeForRuntime", Some(1024 megabytes))
val CheckInterval = ConfigurationLocation("BatchEnvironment", "CheckInterval", Some(1 minutes))
val SubmitRetryInterval = ConfigurationLocation("BatchEnvironment", "SubmitRetryInterval", Some(30 seconds))
val GetTokenInterval = ConfigurationLocation("BatchEnvironment", "GetTokenInterval", Some(1 minutes))
......
......@@ -38,6 +38,7 @@ object JobManager extends JavaLogger { self ⇒
case _: Refresh 5
case _: Submit 50
case _: GetResult 50
case _: Kill 10
case _: Manage 75
case _: Error 100 // This is very quick to process
case _ 1
......
......@@ -36,7 +36,7 @@ object SubmitActor {
catch {
case e: Throwable
JobManager ! Error(job, e, None)
JobManager ! Submit(job)
JobManager ! Delay(Submit(job), preference(BatchEnvironment.SubmitRetryInterval))
}
}
}
......
......@@ -6,50 +6,52 @@ import org.openmole.core.dsl.extension._
object ABCHook {
def apply(abc: DSLContainer[ABC.ABCParameters], dir: FromContext[File], frequency: OptionalArgument[Long] = None)(implicit name: sourcecode.Name, definitionScope: DefinitionScope) =
def apply(abc: DSLContainer[ABC.ABCParameters], dir: FromContext[File], frequency: Long = 1)(implicit name: sourcecode.Name, definitionScope: DefinitionScope) =
Hook("ABCHook") { p
import p._
import org.openmole.plugin.tool.csv._
context(abc.data.state) match {
case MonAPMC.Empty() ()
case MonAPMC.State(_, s)
val step = context(abc.data.step)
val filePath = dir / s"step${step}.csv"
val file = filePath.from(context)
val size = s.thetas.size
val dim = s.thetas(0).size
val paramNames = abc.data.prior.map { x x.v.name }
val header =
(Vector("epsilon,pAcc,t,ts,rhos,weight") ++
paramNames).mkString(",")
val data =
(Vector.fill(size)(s.epsilon) zip
Vector.fill(size)(s.pAcc) zip
Vector.fill(size)(s.t) zip
s.ts zip
s.rhos zip
s.weights zip
s.thetas).map {
case ((((((epsilon, pAcc), t), ti), rhoi), wi), thetai)
epsilon.formatted("%.12f") ++ "," ++
pAcc.formatted("%.12f") ++ "," ++
t.formatted("%d") ++ "," ++
ti.formatted("%d") ++ "," ++
rhoi.formatted("%.12f") ++ "," ++
wi.formatted("%.12f") ++ "," ++
thetai.map { _.formatted("%.12f") }.mkString(",")
}.mkString("\n")
file.createParentDir
file.content = header ++ "\n" ++ data
if (context(abc.data.step) % frequency == 0) {
context(abc.data.state) match {
case MonAPMC.Empty() ()
case MonAPMC.State(_, s)
val step = context(abc.data.step)
val filePath = dir / s"step${step}.csv"
val file = filePath.from(context)
val size = s.thetas.size
val dim = s.thetas(0).size
val paramNames = abc.data.prior.map { x x.v.name }
val header =
(Vector("epsilon,pAcc,t,ts,rhos,weight") ++
paramNames).mkString(",")
val data =
(Vector.fill(size)(s.epsilon) zip
Vector.fill(size)(s.pAcc) zip
Vector.fill(size)(s.t) zip
s.ts zip
s.rhos zip
s.weights zip
s.thetas).map {
case ((((((epsilon, pAcc), t), ti), rhoi), wi), thetai)
epsilon.formatted("%.12f") ++ "," ++
pAcc.formatted("%.12f") ++ "," ++
t.formatted("%d") ++ "," ++
ti.formatted("%d") ++ "," ++
rhoi.formatted("%.12f") ++ "," ++
wi.formatted("%.12f") ++ "," ++
thetai.map { _.formatted("%.12f") }.mkString(",")
}.mkString("\n")
file.createParentDir
file.content = header ++ "\n" ++ data
}
}
context
......
......@@ -113,7 +113,7 @@ package object abc {
val masterState = Val[MonAPMC.MonState]("masterState", abcNamespace)
val islandState = state
val step = Val[Int]("step", abcNamespace)
val step = Val[Int]("masterStep", abcNamespace)
val stop = Val[Boolean]
val n = sample + generated
......@@ -127,7 +127,8 @@ package object abc {
val master =
MoleTask(appendSplit -- terminationTask) set (
exploredOutputs += islandState.array
exploredOutputs += islandState.array,
step := 0
)
val slave =
......@@ -158,9 +159,9 @@ package object abc {
}
implicit class ABCContainer(dsl: DSLContainer[ABCParameters]) extends DSLContainerHook(dsl) {
def hook(directory: FromContext[File]): DSLContainer[ABC.ABCParameters] = {
def hook(directory: FromContext[File], frequency: Long = 1): DSLContainer[ABC.ABCParameters] = {
implicit val defScope = dsl.scope
dsl hook ABCHook(dsl, directory)
dsl hook ABCHook(dsl, directory, frequency)
}
}
......
package org.openmole.plugin.method.evolution
import org.openmole.core.dsl._
import org.openmole.core.workflow.task.ClosureTask
import org.openmole.core.context.Variable
import org.openmole.core.workflow.builder.DefinitionScope
import org.openmole.core.dsl.extension._
import org.openmole.tool.types.ToDouble
object DeltaTask {
def apply(objective: (Val[Double], Double)*)(implicit name: sourcecode.Name, definitionScope: DefinitionScope) =
ClosureTask("DeltaTask") { (context, _, _)
context ++ objective.map { case (v, o) Variable(v, math.abs(context(v) - o)) }
def apply(objective: Delta*)(implicit name: sourcecode.Name, definitionScope: DefinitionScope) =
Task("DeltaTask") { p
import p._
context ++ objective.map {
case DeltaDouble(v, o) Variable(v, math.abs(context(v) - o))
case DeltaInt(v, o) Variable(v, math.abs(context(v) - o))
case DeltaLong(v, o) Variable(v, math.abs(context(v) - o))
}
} set (
(inputs, outputs) += (objective.map(_._1): _*)
(inputs, outputs) += (objective.map(Delta.v): _*)
)
sealed trait Delta
case class DeltaDouble(v: Val[Double], objective: Double) extends Delta
case class DeltaInt(v: Val[Int], objective: Int) extends Delta
case class DeltaLong(v: Val[Long], objective: Long) extends Delta
object Delta {
implicit def fromTupleDouble[T](t: (Val[Double], T))(implicit toDouble: ToDouble[T]) = DeltaDouble(t._1, toDouble(t._2))
implicit def fromTupleInt(t: (Val[Int], Int)) = DeltaInt(t._1, t._2)
implicit def fromTupleLong(t: (Val[Long], Long)) = DeltaLong(t._1, t._2)
def v(delta: Delta) =
delta match {
case DeltaDouble(v, _) v
case DeltaInt(v, _) v
case DeltaLong(v, _) v
}
}
}
object Delta {
import org.openmole.core.workflow.builder.DefinitionScope
def apply(dsl: DSL, objective: (Val[Double], Double)*)(implicit definitionScope: DefinitionScope) =
def apply(dsl: DSL, objective: DeltaTask.Delta*)(implicit definitionScope: DefinitionScope) =
dsl -- DeltaTask(objective: _*)
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment