Commit d7aa74fe authored by Romain Reuillon's avatar Romain Reuillon
Browse files

Fix entries

parent bc59a144
......@@ -33,9 +33,9 @@ val env = LocalEnvironment(2)
//Configuration of the genetic algorithm
NSGA2Evolution(
mu = 50, //Size of the population
populationSize = 50, //Size of the population
genome = Seq(T0 in (0.0, 3.0), cexp in (0.5, 1.0), pas in (0.1, 5.0), niter in (100.0, 10000.0)), //Space in which the population is sampled, values are rough estimations
objectives = Seq(doubleValue aggregate average as "average", doubleValue aggregate meanSquaredError as "mse", niter aggregate head), //We want to optimize over three parameters
objective = Seq(doubleValue aggregate average as "average", doubleValue aggregate meanSquaredError as "mse", niter aggregate head), //We want to optimize over three parameters
stochastic = Stochastic(seed = seed),
evaluation = AckleyFunction -- toDouble,
parallelism = 10,
......
......@@ -72,7 +72,7 @@ NichedNSGA2Evolution(
//Specify the niche parameters
niche = Seq(discrete_a, discrete_b, discrete_c),
//Specify the objective(s)
objectives = Seq(doubleValue aggregate median),
objective = Seq(doubleValue aggregate median),
evaluation = mapper -- AckleyFunction -- toDouble,
parallelism = 10,
termination = 2000,
......
......@@ -49,7 +49,7 @@ NichedNSGA2Evolution(
// (a in Vector(0.0, 2.0, 5.0, 10.0)) gives 4 segment of different sizes
niche = Seq((a, 4), (b, 4), (c, 4)),
//Specify the objective(s)
objectives = Seq(doubleValue aggregate median),
objective = Seq(doubleValue aggregate median),
stochastic = Stochastic(seed = seed),
evaluation = AckleyFunction -- toDouble,
parallelism = 10,
......
......@@ -4,9 +4,9 @@ val env = LocalEnvironment(4)
//Configuration of the algorithm NSGA2
NSGA2Evolution(
mu = 50, //Size of population
populationSize = 50, //Size of population
genome = Seq(x in (-30.0, 30.0), y in (-30.0, 30.0)), //Space in which the population is sampled
objectives = Seq(doubleValue), //We want to minimize the value of the Ackley function
objective = Seq(doubleValue), //We want to minimize the value of the Ackley function
evaluation = AckleyFunction -- toDouble,
termination = 10000, // Terminate after 10000 evaluation of the function
parallelism = 10 // Number of solution submitted to parallel evaluation by the optimization algorithm
......
......@@ -18,33 +18,28 @@ val cmds = Seq("run-to-grid")
val ants =
NetLogo5Task(workDirectory / "ants.nlogo", cmds, seed = seed) set (
// Map the OpenMOLE variables to NetLogo variables
netLogoInputs += (gPopulation, "gpopulation"),
netLogoInputs += (gDiffusionRate, "gdiffusion-rate"),
netLogoInputs += (gEvaporationRate, "gevaporation-rate"),
netLogoOutputs += ("final-ticks-food1", food1),
netLogoOutputs += ("final-ticks-food2", food2),
netLogoOutputs += ("final-ticks-food3", food3),
inputs += (gPopulation mapped "gpopulation"),
inputs += (gDiffusionRate mapped "gdiffusion-rate"),
inputs += (gEvaporationRate mapped "gevaporation-rate"),
outputs += (food1 mapped "final-ticks-food1"),
outputs += (food2 mapped "final-ticks-food2"),
outputs += (food3 mapped "final-ticks-food3"),
gPopulation := 100
)
val aggregate =
val agg =
ScalaTask("val obj = math.abs(250 - food1) + math.abs(400 - food2) + math.abs(800 - food3)") set (
inputs += (food1, food2, food3),
outputs += obj
)
val modelCapsule = Capsule(ants)
val evolution =
SteadyStateEvolution(
algorithm =
NSGA2(
mu = 10,
genome = Seq(gDiffusionRate in (0.0, 99.0), gEvaporationRate in (0.0, 99.0)),
objectives = Seq(obj),
stochastic = Stochastic(seed = seed)
),
evaluation = modelCapsule -- aggregate,
NSGA2Evolution(
genome = Seq(gDiffusionRate in (0.0, 99.0), gEvaporationRate in (0.0, 99.0)),
objective = Seq(obj),
stochastic = Stochastic(seed = seed),
evaluation = ants -- agg,
parallelism = 10,
termination = 100
) hook ( workDirectory / "evolution")
......
......@@ -20,10 +20,6 @@ val env = LocalEnvironment(64)
val purpose = "LHS_REPETS_LOCAL"
val indics_hook = CSVHook(workDirectory / "exploration" / ((new SimpleDateFormat("yyyy_MM_dd_HH_mm_ss")).format(new Date()))+"_"+purpose+".csv") set (arraysOnSingleRow := true)
// Define the NetlogoTask
// experiments:setup-experiment [setuptype antpop wangle diffrate evaprate]
val cmds = Seq("experiments:setup-experiment \"fixed\" ${population} ${wiggleAngle} ${diffusionRate} ${evaporationRate} ${seed}","experiments:run-experiment")
......@@ -40,7 +36,7 @@ val ants =
val replications =
Replication (
evaluation = (ants on env hook indics_hook),
evaluation = ants,
seed = seed,
sample = 64
)
......@@ -58,6 +54,7 @@ val ants =
population in (100.0,200.0),
wiggleAngle in (5.0,90.0)
) withIndex id
)
) on env hook (workDirectory / "exploration" / ((new SimpleDateFormat("yyyy_MM_dd_HH_mm_ss")).format(new Date()))+"_"+purpose+".csv")
exploration
......@@ -22,11 +22,6 @@ val env = LocalEnvironment(4)
val purpose = "TEST"
val indics_hook = CSVHook(workDirectory / "exploration" / ((new SimpleDateFormat("yyyy_MM_dd_HH_mm_ss")).format(new Date()))+"_"+purpose+".csv") set (arraysOnSingleRow := true)
// Define the NetlogoTask
// experiments:setup-experiment [setuptype antpop wangle diffrate evaprate]
val cmds = Seq("experiments:setup-experiment \"fixed\" ${population} ${wiggleAngle} ${diffusionRate} ${evaporationRate} ${seed}","experiments:run-experiment")
......@@ -61,8 +56,8 @@ val replications =
evaluation = (ants on env) -- FilterTask(food1, food2, food3),
seed = seed,
sample = 64,
aggregation = analyse hook indics_hook
)
aggregation = Seq(food1, food2, food3)
) hook (workDirectory / "exploration" / ((new SimpleDateFormat("yyyy_MM_dd_HH_mm_ss")).format(new Date()))+"_"+purpose+".csv")
......
......@@ -3,25 +3,19 @@ import _file_.Calibrate._
// Define the population (200) and the computation time (1h)
// The remaining is the same as above
val evolution =
SteadyStateEvolution(
algorithm =
NSGA2(
mu = 200,
genome = Seq(gDiffusionRate in (0.0, 99.0), gEvaporationRate in (0.0, 99.0)),
objectives = Seq(obj),
stochastic = Stochastic(seed = seed)
),
evaluation = modelCapsule -- aggregate,
termination = 1 hour
NSGA2Evolution(
genome = Seq(gDiffusionRate in (0.0, 99.0), gEvaporationRate in (0.0, 99.0)),
objective = Seq(obj),
stochastic = Stochastic(seed = seed),
evaluation = ants -- agg,
termination = 200000,
parallelism = 2000,
distribution = Island(5 minutes)
)
// Define the island model with 2,000 concurrent islands.
// The algorithm stops after 200,000 islands evaluations.
val island = IslandEvolution(evolution, parallelism = 2000, termination = 200000)
// Define the execution environment
val env = LocalEnvironment(4)
// Define the workflow
(island on env hook (workDirectory / "results"))
(evolution on env hook (workDirectory / "results"))
......@@ -27,21 +27,19 @@ val ants =
gPopulation := 100
)
val aggregate =
val agg =
ScalaTask("val obj = math.abs(250 - food1) + math.abs(400 - food2) + math.abs(800 - food3)") set (
inputs += (food1, food2, food3),
outputs += obj
)
val modelCapsule = Capsule(ants)
val evolution =
NSGA2Evolution(
mu = 10,
genome = Seq(gDiffusionRate in (0.0, 99.0), gEvaporationRate in (0.0, 99.0)),
objectives = Seq(obj),
objective = Seq(obj),
stochastic = Stochastic(seed = seed),
evaluation = modelCapsule -- aggregate,
evaluation = ants -- agg,
parallelism = 10,
termination = 10000
) hook (workDirectory / "calibration")
......
......@@ -5,9 +5,9 @@ import _file_.Calibrate._
val evolution =
NSGA2Evolution(
genome = Seq(gDiffusionRate in (0.0, 99.0), gEvaporationRate in (0.0, 99.0)),
objectives = Seq(obj),
objective = Seq(obj),
stochastic = Stochastic(seed = seed),
evaluation = modelCapsule -- aggregate,
evaluation = ants -- agg,
parallelism = 2000,
termination = 2000000,
distribution = Island(10 minutes)
......
//model inputs
val x = Val[Double]
//model outputs
val f1 = Val[Double]
val f2 = Val[Double]
// about the current experiment
val relativePath = "results/SchafferN2"
// the test function
val testFunctionSchafferN2=
ScalaTask("""
val f1 = if (x <= 1) {
-x*1.0
} else if (x <= 3) {
x - 2.0
} else if (x <= 4) {
4.0 - x
} else {
x - 4.0
}
val f2 = Math.pow(x - 5, 2);
""") set (
inputs += x,
outputs += f1,
outputs += f2
)
// the optimisation algorithm under test
val evolutionSchafferN2 =
NSGA2Evolution(
genome = Seq(
x in (-5.0, 10.0)
),
objective = Seq(f1, f2),
evaluation = testFunctionSchafferN2,
parallelism = 8,
termination = 1000
)
val envMultiThread = LocalEnvironment(4, name="multithread")
// compute evolution on the test Function
(evolutionSchafferN2 on envMultiThread hook (workDirectory/relativePath, keepAll=false)
// then plot the last Pareto front
) -- (taskPlotLastParetoFront set ( directoryWithResults := workDirectory/relativePath, countInputs := 1) hook CopyFileHook(last_pareto, workDirectory/"last Pareto front SchafferN2.png" ) )
......@@ -2,7 +2,7 @@ name := "hellocode"
version := "1.0"
scalaVersion := "2.12.10"
scalaVersion := "2.13.4"
enablePlugins(SbtOsgi)
......@@ -10,7 +10,7 @@ OsgiKeys.exportPackage := Seq("hellocode.*")
OsgiKeys.importPackage := Seq("*")
OsgiKeys.privatePackage := Seq("")
OsgiKeys.privatePackage := Seq("!scala.*,*")
......@@ -31,7 +31,7 @@ val cmds = List(
)
val model =
NetLogo5Task(workDirectory / "model" / "OM_Metamimetic_Networks_GIT.nlogo", cmds, true) set (
NetLogo5Task(workDirectory / "model" / "OM_Metamimetic_Networks_GIT.nlogo", cmds, embedWorkspace = true) set (
inputs += seed,
topology := "Small-World",
numAgents := 100.0,
......@@ -44,21 +44,21 @@ val model =
initialConf := 0,
replacement := false,
loadtopology := false,
netLogoInputs += (filein, "FileIn"),
netLogoInputs += (topology, "Topology"),
netLogoInputs += (numAgents, "Num-Agents"),
netLogoInputs += (connectionProbability, "Connection-Probability"),
netLogoInputs += (initialNeighbours, "Initial-Neighbours"),
netLogoInputs += (rewiringProbability, "Rewiring-Probability"),
netLogoInputs += (initialRandomTypes, "Initial-Random-Types?"),
netLogoInputs += (initialMaxi, "Initial-Maxi-%"),
netLogoInputs += (initialMini, "Initial-Mini-%"),
netLogoInputs += (initialConf, "Initial-Conf-%"),
netLogoInputs += (strengthOfDilemma, "Strength-of-Dilemma"),
netLogoInputs += (inicoop, "inicoop"),
netLogoInputs += (replacement, "replacement?"),
netLogoInputs += (culturalConstant, "cultural-constant"),
netLogoInputs += (loadtopology, "Load-Topology?"),
inputs += (filein mapped "FileIn"),
inputs += (topology mapped "Topology"),
inputs += (numAgents mapped "Num-Agents"),
inputs += (connectionProbability mapped "Connection-Probability"),
inputs += (initialNeighbours mapped "Initial-Neighbours"),
inputs += (rewiringProbability mapped "Rewiring-Probability"),
inputs += (initialRandomTypes mapped "Initial-Random-Types?"),
inputs += (initialMaxi mapped "Initial-Maxi-%"),
inputs += (initialMini mapped "Initial-Mini-%"),
inputs += (initialConf mapped "Initial-Conf-%"),
inputs += (strengthOfDilemma mapped "Strength-of-Dilemma"),
inputs += (inicoop mapped "inicoop"),
inputs += (replacement mapped "replacement?"),
inputs += (culturalConstant mapped "cultural-constant"),
inputs += (loadtopology mapped "Load-Topology?"),
outputFiles += ("graph.graphml", graph),
outputFiles += ("popul.csv", popul),
outputFiles += ("coop.csv", coop),
......
......@@ -47,4 +47,4 @@ val taskPlotLastParetoFront = RTask("""
filesHaveHeaders := 1,
countInputs := 2
)
\ No newline at end of file
import _file_.Learn._
val accuracy = Val[Double]
val parsing =
ScalaTask("val accuracy = learningOutput.lines.toSeq.head.toDouble") set (
inputs += learningOutput,
outputs += accuracy
)
val accuracyAverage = Val[Double]
val accuracyMedian = Val[Double]
val accuracyMSE = Val[Double]
val stat =
ScalaTask("""
|val accuracyAverage = accuracy.average
|val accuracyMedian = accuracy.median
|val accuracyMSE = accuracy.meanSquaredError
""".stripMargin) set (
inputs += (nbTrees, treeDepth, accuracy.toArray),
outputs += (nbTrees, treeDepth, accuracyAverage, accuracyMedian, accuracyMSE)
)
val resultHook =
AppendToCSVFileHook(
workDirectory / "analysed.csv",
nbTrees, treeDepth, accuracyAverage, accuracyMedian, accuracyMSE)
val imageExplorationCapsule = Capsule(imagesExploration)
val statSlot = Slot(stat)
(parameterExploration -< imageExplorationCapsule -< learning -- parsing >- statSlot) &
(imageExplorationCapsule -- (statSlot hook resultHook))
// inputs for our model
val seed = Val[Int]
val inputNumberOfCars = Val[Double]
val inputAcceleration = Val[Double]
val inputDeceleration = Val[Double]
// model outputs
val outputSpeedMin = Val[Double]
val outputSpeedMax = Val[Double]
// run on 4 threads/CPUs on the local computer
val envLocal = LocalEnvironment(4)
// hooks to save results into the results_traffic subdirectory
val storeSimuCSV = AppendToCSVFileHook(workDirectory / "results_traffic" / "simu.csv")
val storeSensitivityCSV = AppendToCSVFileHook(workDirectory / "results_traffic" / "sensitivity.csv")
// run the Traffic Netlogo model
val launch = List("setup","random-seed ${seed}","while [ticks < 1000] [go]")
val modelExec = NetLogo6Task(workDirectory / "Traffic Basic.nlogo", launch) set(
inputs += (seed),
outputs ++= Seq(inputNumberOfCars, inputAcceleration, inputDeceleration),
netLogoInputs += (inputNumberOfCars, "number-of-cars"),
netLogoInputs += (inputAcceleration, "acceleration"),
netLogoInputs += (inputDeceleration, "deceleration"),
netLogoOutputs += ("compute-speed-min", outputSpeedMin),
netLogoOutputs += ("compute-speed-max", outputSpeedMax)
)
// drive the sensitivity analysis
val sensi = SensitivityMorris(
evaluation = modelExec on envLocal hook storeSimuCSV,
inputs = Seq(inputNumberOfCars in (1.0, 41.0),
inputAcceleration in (0.0, 0.0099),
inputDeceleration in (0.0, 0.099)
),
outputs = Seq(outputSpeedMin, outputSpeedMax),
sample = 20,
level = 5)
// R Task plotting the graphs
val fileGraphSensitivity = Val[File]
val drawGraph = RTask("""source("plot_sensitivity.R")""") set(
resources += workDirectory / "plot_sensitivity.R",
rInputs += (MorrisAggregation.varInputName, "inputnames"),
rInputs += (MorrisAggregation.varOutputName, "outputnames"),
rInputs += (MorrisAggregation.varMu, "mus"),
rInputs += (MorrisAggregation.varMuStar, "mustars"),
rInputs += (MorrisAggregation.varSigma, "sigmas"),
outputFiles += ("/tmp/sensitivity.png", fileGraphSensitivity)
)
(sensi hook storeSensitivityCSV) -- (drawGraph hook CopyFileHook(fileGraphSensitivity, workDirectory / "results_traffic" / "sensitivity.png"))
import _file_.Model._
val evolution =
SteadyStateEvolution(
algorithm =
NSGA2(
mu = 200,
genome =
Seq(
rMax in (2.0, 50000.0),
distanceDecay in (0.0, 4.0),
pCreation in (0.0, 0.01),
pDiffusion in (0.0, 0.01),
innovationImpact in (0.0, 2.0),
innovationLife in (1.0, 4001.0)
),
objectives = Seq(ksValue, deltaPop, deltaTime),
stochastic =
Stochastic(
seed = seed,
aggregation = Seq(average, median, median)
)
NSGA2Evolution(
genome =
Seq(
rMax in (2.0, 50000.0),
distanceDecay in (0.0, 4.0),
pCreation in (0.0, 0.01),
pDiffusion in (0.0, 0.01),
innovationImpact in (0.0, 2.0),
innovationLife in (1.0, 4001.0)
),
objective = Seq(
ksValue aggregate average,
deltaPop aggregate median,
deltaTime aggregate median),
stochastic = Stochastic(seed = seed),
evaluation = evaluateModel,
termination = 15 minutes
)
val island = IslandEvolution(evolution, parallelism = 1000, termination = 200000)
parallelism = 1000,
termination = 200000,
distribution = Island(5 minutes)
) hook (workDirectory / "populations")
// Define the hook to save the results
val savePopulation = SavePopulationHook(island, workDirectory / "populations")
val grid = DIRACEnvironment("vo.complex-systems.eu")
val grid = EGIEnvironment("vo.complex-systems.eu")
// Define the execution
(island on grid hook savePopulation)
(evolution on grid hook savePopulation)
......@@ -2,7 +2,7 @@ import _file_.Model._
val aggregatedFitness = Val[Double]
val aggregate =
val agg =
ScalaTask("""
|val normalised = Seq(ksValue, deltaPop, deltaTime)
|val aggregatedFitness = if(normalised.exists(_.isNaN)) Double.PositiveInfinity else normalised.max""".stripMargin) set (
......@@ -10,14 +10,13 @@ val aggregate =
outputs += aggregatedFitness
)
val grid = DIRACEnvironment("vo.complex-systems.eu")
val grid = EGIEnvironment("vo.complex-systems.eu")
def profile(variable: Val[Double]) = {
val algo =
GenomeProfile (
x = variable,
nX = 100,
ProfileEvolution (
profile = Seq(variable in 100),
genome = Seq(
rMax in (2.0, 50000.0),
distanceDecay in (0.0, 4.0),
......@@ -26,28 +25,18 @@ def profile(variable: Val[Double]) = {
innovationImpact in (0.0, 2.0),
innovationLife in (1.0, 4001.0)
),
objective = aggregatedFitness,
stochastic = Stochastic(seed = seed)
)
// Calibration profile of 1000 points for the parameter
val evolution = SteadyStateEvolution(
algorithm = algo,
evaluation = evaluateModel -- aggregate,
termination = 30 minutes
)
// Define the island model
val island = IslandEvolution(evolution, parallelism = 1000, termination = 200000)
// Define the hook to save the results
val savePopulation = SavePopulationHook(island, workDirectory / s"profile2/${variable.name}/")
// Define the execution
(island on grid hook savePopulation)
objective = Seq(aggregatedFitness),
stochastic = Stochastic(seed = seed),
evaluation = evaluateModel -- agg,
distribution = Island(5 minutes),
parallelism = 1000,
termination = 200000
) hook (workDirectory / s"profile2/${variable.name}/")
algo on grid
}
val firstCapsule = Capsule(EmptyTask())
val profiles = Seq(rMax, distanceDecay, pCreation, pDiffusion, innovationImpact, innovationLife).map(profile)
profiles.map(firstCapsule -- _).reduce(_ & _)
EmptyTask() -- profiles
......@@ -15,7 +15,7 @@ NSGA2Evolution(
genome = Seq(
diffusion in (0.0, 99.0),
evaporation in (0.0, 99.0)),
objectives = Seq(deltaFood),
objective = Seq(deltaFood),
termination = 1000,
parallelism = 100,
stochastic = Stochastic(seed = seed),
......
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