Automatic parameter exploration methods


OpenMOLE provides advanced methods to help you explore your application's space of parameters. These methods automatically generate workflows in order to solve exploration problems.

Genetic algorithms


This workflow optimises a dummy model using the generational NSGA II multi-objective algorithm. You can replace the instances of model by your own model and adapt the variation range of its input variables. If you're not familiar with parameter tuning using Genetic Algorithms (GA), you should first consult the tutorial explaining how to calibrate a NetLogo model with a GA.
val x = Val[Double]
val y = Val[Double]

val o1 = Val[Double]
val o2 = Val[Double]

val model =
  ScalaTask("val o1 = x; val o2 = y") set (
    inputs += (x, y),
    outputs += (o1, o2)
  )


// Construction of the workflow orchestrating the genetic algorithm
// termination is the termination criterion, here it runs for 100 generations. A time limit could be set as an
// alternative by replacing 100 by 1 hour (hour is a duration type understood by OpenMOLE).
// the parallelism specifies how many evaluation are concurrently submitted to the execution environment
val evolution =
  SteadyStateEvolution(
    // Definition of the optimisation algorithm
    // mu is the size of the population
    // genome is the inputs prototype and their variation ranges
    // objectives are the objectives to minimise
    algorithm =
      NSGA2(
        mu = 100,
        genome = Seq(x in (0.0, 1.0), y in (0.0, 1.0)),
        objectives = Seq(o1, o2)
      ),
      evaluation = model,
      parallelism = 10,
      termination = 100
  )


// Definition of a hook to save the population of solutions to /tmp/evolution on the local machine running OpenMOLE
val savePopulation = SavePopulationHook(evolution, workDirectory / "evolution/")

// Construction of the complete mole with the execution environment, and the hook.
// Here the generated workflow will run using 4 threads of the local machine.
(evolution hook savePopulation on LocalEnvironment(4))

For distributed environments the island distribution scheme is well adapted. Islands of population evolve for a while on a remote node. When an island is finished, its final population is merged back into a global archive. A new island is then generated until the termination criterion: i.e. the total number of islands to generate is met. Islands can be used as follows:
val evolution =
  SteadyStateEvolution(
    // Definition of the optimisation algorithm
    // mu is the size of the population
    // genome is the inputs prototype and their variation ranges
    // objectives are the objectives to minimise
    algorithm =
      NSGA2(
        mu = 100,
        genome = Seq(x in (0.0, 1.0), y in (0.0, 1.0)),
        objectives = Seq(o1, o2)
      ),
    evaluation = model,
    termination = 100
  )

// Generate a workflow that orchestrates 100 concurrent islands.
// The workflow stops when 10,000 islands have completed.
val island =
  IslandEvolution(
    evolution,
    parallelism = 100,
    termination = 10000
  )

// Definition of a hook to save the population of solutions on the local machine running OpenMOLE
val savePopulation = SavePopulationHook(island, workDirectory / "evolution")

// Construction of the complete mole with the execution environment, and the hook.
// Here the generated workflow will run using 4 threads of the local machine.
(island on LocalEnvironment(4) hook savePopulation)

Calibration of stochastic models leads to noisy fitness functions. An efficient strategy to deal with such fitness functions is implemented in OpenMOLE. This strategy automatically balances the need for replications and the discovery of new solutions. In case you want to explore a stochastic model with a genetic algorithm you can do:
val seed = Val[Long]

val evolution =
  SteadyStateEvolution(
    // Definition of the optimisation algorithm
    // mu is the size of the population
    // genome is the inputs prototype and their variation ranges
    // objectives are the objectives to minimise
    algorithm =
      NSGA2(
        mu = 100,
        genome = Seq(x in (0.0, 1.0), y in (0.0, 1.0)),
        objectives = Seq(o1, o2),
        // OpenMOLE provide a seed for your stochastic model to use (it is optional)
        // 20% of the evaluations are used for replicating existing solutions
        // 100 replication are stored at max for each individual
        replication = Replication(seed = seed, reevaluate = 0.2, max = 100)
      ),
    evaluation = model,
    termination = 100
  )