Documentation > Advanced Concepts
In OpenMOLE evolutionary algorithms you can suggest genomes to start with. You can suggest genomes using an OMR file, a CSV file or setting it manually. It might be a way to inject use the results found a previous run to bootstrap a new one.
In the following examples we demonstrate suggestion using NSGA2, but it works with any evolutionary method.
In the following examples we demonstrate suggestion using NSGA2, but it works with any evolutionary method.
From an OMR file 🔗
If you saved the results of an evolution in a file called previous_result.omr, you can start an evolution using these results using suggestion. The file must contain values for each parts of the genome.val i1 = Val[Double]
val i2 = Val[Double]
val fitness = Val[Double]
val rastrigin = ScalaTask("""
val i = Vector(i1, i2)
val fitness = 10 * i.size + i.map(x => (x * x) - 10 * math.cos(2 * Pi * x)).sum
""") set (
inputs += (i1, i2),
outputs += fitness
)
NSGA2Evolution(
evaluation = rastrigin,
objective = fitness,
genome = Seq(
i1 in (-5.12 to 5.12),
i2 in (-5.12 to 5.12)
),
termination = 100,
parallelism = 10,
suggestion = workDirectory / "previous_result.omr"
) hook (workDirectory / "result.omr")
From an CSV file 🔗
You can also suggest genome values using a CSV file. The file must contain values for each parts of the genome, for instance:i1,i2
-1.79,-0.95
-2.79,-0.10
You can suggest the genome listed in this file as follows:
val i1 = Val[Double]
val i2 = Val[Double]
val fitness = Val[Double]
val rastrigin = ScalaTask("""
val i = Vector(i1, i2)
val fitness = 10 * i.size + i.map(x => (x * x) - 10 * math.cos(2 * Pi * x)).sum
""") set (
inputs += (i1, i2),
outputs += fitness
)
NSGA2Evolution(
evaluation = rastrigin,
objective = fitness,
genome = Seq(
i1 in (-5.12 to 5.12),
i2 in (-5.12 to 5.12)
),
termination = 100,
parallelism = 10,
suggestion = workDirectory / "suggestion.csv"
) hook (workDirectory / "result.omr")
Suggest in the script 🔗
You can also suggest initial genomes in the script, using the following syntax:val i1 = Val[Double]
val i2 = Val[Double]
val fitness = Val[Double]
val rastrigin = ScalaTask("""
val i = Vector(i1, i2)
val fitness = 10 * i.size + i.map(x => (x * x) - 10 * math.cos(2 * Pi * x)).sum
""") set (
inputs += (i1, i2),
outputs += fitness
)
NSGA2Evolution(
evaluation = rastrigin,
objective = fitness,
genome = Seq(
i1 in (-5.12 to 5.12),
i2 in (-5.12 to 5.12)
),
termination = 100,
parallelism = 10,
suggestion = Seq(
Suggestion(i1 := 1.4, i2 := 1.3),
Suggestion(i1 := -1.3, i2 := -1.2)
)
) hook (workDirectory / "file.omr")