Commit 14c92dd7 authored by Romain Reuillon's avatar Romain Reuillon
Browse files

[Plugin] enh: implement genome rejection

parent d531ac2d
......@@ -227,7 +227,7 @@ lazy val squants =
) settings(settings: _*)
lazy val mgoVersion = "3.39"
lazy val mgoVersion = "3.40"
lazy val mgo = OsgiProject(dir, "mgo", exports = Seq("mgo.*", "freestyle.*"), imports = Seq("!better.*", "!javax.xml.*", "!scala.meta.*", "!sun.misc.*", "*"), privatePackages = Seq("!scala.*", "!monocle.*", "!org.apache.commons.math3.*", "!cats.*", "!squants.*", "!scalaz.*", "*")) settings(
libraryDependencies += "org.openmole" %% "mgo" % mgoVersion,
......
......@@ -74,8 +74,8 @@ object NSGA2 {
def breeding(individuals: Vector[I], n: Int, s: S, rng: scala.util.Random) = FromContext { p
import p._
val discrete = Genome.discrete(om.genome).from(context)
val filterValue = om.filter.map(f GAIntegration.filterValue[G](f, om.genome, _.continuousValues.toVector, _.discreteValues.toVector).from(context))
MGONSGA2.adaptiveBreeding[S, Array[Any]](n, om.operatorExploration, discrete, ExactObjective.toFitnessFunction(om.objectives), filterValue)(s, individuals, rng)
val rejectValue = om.reject.map(f GAIntegration.rejectValue[G](f, om.genome, _.continuousValues.toVector, _.discreteValues.toVector).from(context))
MGONSGA2.adaptiveBreeding[S, Array[Any]](n, om.operatorExploration, discrete, ExactObjective.toFitnessFunction(om.objectives), rejectValue)(s, individuals, rng)
}
def elitism(population: Vector[I], candidates: Vector[I], s: S, rng: scala.util.Random) =
......@@ -101,7 +101,7 @@ object NSGA2 {
genome: Genome,
objectives: Seq[ExactObjective[_]],
operatorExploration: Double,
filter: Option[Condition])
reject: Option[Condition])
object StochasticParams {
import mgo.evolution.algorithm.{ CDGenome, NoisyNSGA2 MGONoisyNSGA2, _ }
......@@ -149,8 +149,8 @@ object NSGA2 {
def breeding(individuals: Vector[I], n: Int, s: S, rng: util.Random) = FromContext { p
import p._
val discrete = Genome.discrete(om.genome).from(context)
val filterValue = om.filter.map(f GAIntegration.filterValue[G](f, om.genome, _.continuousValues.toVector, _.discreteValues.toVector).from(context))
MGONoisyNSGA2.adaptiveBreeding[S, Array[Any]](n, om.operatorExploration, om.cloneProbability, aggregate, discrete, filterValue) apply (s, individuals, rng)
val rejectValue = om.reject.map(f GAIntegration.rejectValue[G](f, om.genome, _.continuousValues.toVector, _.discreteValues.toVector).from(context))
MGONoisyNSGA2.adaptiveBreeding[S, Array[Any]](n, om.operatorExploration, om.cloneProbability, aggregate, discrete, rejectValue) apply (s, individuals, rng)
}
def elitism(population: Vector[I], candidates: Vector[I], s: S, rng: util.Random) =
......@@ -177,7 +177,7 @@ object NSGA2 {
objectives: Seq[NoisyObjective[_]],
historySize: Int,
cloneProbability: Double,
filter: Option[Condition]
reject: Option[Condition]
)
def apply[P](
......@@ -185,13 +185,13 @@ object NSGA2 {
objectives: Objectives,
mu: Int = 200,
stochastic: OptionalArgument[Stochastic] = None,
filter: OptionalArgument[Condition] = None
reject: OptionalArgument[Condition] = None
): EvolutionWorkflow =
WorkflowIntegration.stochasticity(objectives, stochastic.option) match {
case None
val exactObjectives = objectives.map(o Objective.toExact(o))
val integration: WorkflowIntegration.DeterministicGA[_] = WorkflowIntegration.DeterministicGA(
DeterministicParams(mu, genome, exactObjectives, operatorExploration, filter),
DeterministicParams(mu, genome, exactObjectives, operatorExploration, reject),
genome,
exactObjectives
)(DeterministicParams.integration)
......@@ -201,7 +201,7 @@ object NSGA2 {
val noisyObjectives = objectives.map(o Objective.toNoisy(o))
val integration: WorkflowIntegration.StochasticGA[_] = WorkflowIntegration.StochasticGA(
StochasticParams(mu, operatorExploration, genome, noisyObjectives, stochasticValue.replications, stochasticValue.reevaluate, filter.option),
StochasticParams(mu, operatorExploration, genome, noisyObjectives, stochasticValue.replications, stochasticValue.reevaluate, reject.option),
genome,
noisyObjectives,
stochasticValue
......@@ -223,7 +223,7 @@ object NSGA2Evolution {
termination: OMTermination,
mu: Int = 200,
stochastic: OptionalArgument[Stochastic] = None,
filter: OptionalArgument[Condition] = None,
reject: OptionalArgument[Condition] = None,
parallelism: Int = 1,
distribution: EvolutionPattern = SteadyState(),
suggestion: Suggestion = Suggestion.empty,
......@@ -235,7 +235,7 @@ object NSGA2Evolution {
genome = genome,
objectives = objectives,
stochastic = stochastic,
filter = filter
reject = reject
),
evaluation = evaluation,
termination = termination,
......
......@@ -59,7 +59,7 @@ object NichedNSGA2Algorithm {
def initialGenomes(lambda: Int, continuous: Vector[C], discrete: Vector[D], rng: scala.util.Random) =
CDGenome.initialGenomes(lambda, continuous, discrete, rng)
def adaptiveBreeding[S, P](lambda: Int, filter: Option[Genome Boolean], operatorExploration: Double, discrete: Vector[D], fitness: P Vector[Double]) =
def adaptiveBreeding[S, P](lambda: Int, reject: Option[Genome Boolean], operatorExploration: Double, discrete: Vector[D], fitness: P Vector[Double]) =
NSGA2Operations.adaptiveBreeding[S, Individual[P], Genome](
i fitness(i.phenotype),
Individual.genome.get,
......@@ -71,7 +71,7 @@ object NichedNSGA2Algorithm {
buildGenome,
logOfPopulationSize,
lambda,
filter,
reject,
operatorExploration)
def expression[P](fitness: (Vector[Double], Vector[Int]) P, components: Vector[C]): Genome Individual[P] =
......@@ -136,7 +136,7 @@ object NoisyNichedNSGA2Algorithm {
def gridObjectiveProfile[P: Manifest](aggregation: Vector[P] Vector[Double], x: Int, intervals: Vector[Double]): Niche[Individual[P], Int] =
mgo.evolution.niche.gridContinuousProfile[Individual[P]](aggregatedFitness(aggregation), x, intervals)
def adaptiveBreeding[S, P: Manifest](lambda: Int, filter: Option[Genome Boolean], operatorExploration: Double, cloneProbability: Double, aggregation: Vector[P] Vector[Double], discrete: Vector[D]) =
def adaptiveBreeding[S, P: Manifest](lambda: Int, reject: Option[Genome Boolean], operatorExploration: Double, cloneProbability: Double, aggregation: Vector[P] Vector[Double], discrete: Vector[D]) =
NoisyNSGA2Operations.adaptiveBreeding[S, Individual[P], Genome, P](
aggregatedFitness(aggregation),
Individual.genome.get,
......@@ -148,7 +148,7 @@ object NoisyNichedNSGA2Algorithm {
buildGenome,
logOfPopulationSize,
lambda,
filter,
reject,
operatorExploration,
cloneProbability)
......@@ -263,8 +263,8 @@ object NichedNSGA2 {
def breeding(population: Vector[I], n: Int, s: S, rng: scala.util.Random) = FromContext { p
import p._
val discrete = Genome.discrete(om.genome).from(context)
val filterValue = om.filter.map(f GAIntegration.filterValue[G](f, om.genome, _.continuousValues.toVector, _.discreteValues.toVector).from(context))
mgo.evolution.algorithm.Profile.adaptiveBreeding[Array[Any]](n, om.operatorExploration, discrete, ExactObjective.toFitnessFunction(om.objectives), filterValue) apply (s, population, rng)
val rejectValue = om.reject.map(f GAIntegration.rejectValue[G](f, om.genome, _.continuousValues.toVector, _.discreteValues.toVector).from(context))
mgo.evolution.algorithm.Profile.adaptiveBreeding[Array[Any]](n, om.operatorExploration, discrete, ExactObjective.toFitnessFunction(om.objectives), rejectValue) apply (s, population, rng)
}
def elitism(population: Vector[I], candidates: Vector[I], s: S, rng: scala.util.Random) = FromContext { p
......@@ -290,7 +290,7 @@ object NichedNSGA2 {
genome: Genome,
objectives: Seq[ExactObjective[_]],
operatorExploration: Double,
filter: Option[Condition])
reject: Option[Condition])
object StochasticParams {
......@@ -366,8 +366,8 @@ object NichedNSGA2 {
def breeding(individuals: Vector[I], n: Int, s: S, rng: scala.util.Random) = FromContext { p
import p._
val discrete = Genome.discrete(om.genome).from(context)
val filterValue = om.filter.map(f GAIntegration.filterValue[G](f, om.genome, _.continuousValues.toVector, _.discreteValues.toVector).from(context))
NoisyNichedNSGA2Algorithm.adaptiveBreeding[S, Array[Any]](n, filterValue, om.operatorExploration, om.cloneProbability, NoisyObjective.aggregate(om.objectives), discrete) apply (s, individuals, rng)
val rejectValue = om.reject.map(f GAIntegration.rejectValue[G](f, om.genome, _.continuousValues.toVector, _.discreteValues.toVector).from(context))
NoisyNichedNSGA2Algorithm.adaptiveBreeding[S, Array[Any]](n, rejectValue, om.operatorExploration, om.cloneProbability, NoisyObjective.aggregate(om.objectives), discrete) apply (s, individuals, rng)
}
def elitism(population: Vector[I], candidates: Vector[I], s: S, rng: scala.util.Random) =
......@@ -402,7 +402,7 @@ object NichedNSGA2 {
objectives: Seq[NoisyObjective[_]],
historySize: Int,
cloneProbability: Double,
filter: Option[Condition])
reject: Option[Condition])
def apply[P](
niche: Seq[NichedElement],
......@@ -410,7 +410,7 @@ object NichedNSGA2 {
objectives: Objectives,
nicheSize: Int,
stochastic: OptionalArgument[Stochastic] = None,
filter: OptionalArgument[Condition] = None
reject: OptionalArgument[Condition] = None
): EvolutionWorkflow =
WorkflowIntegration.stochasticity(objectives, stochastic.option) match {
case None
......@@ -422,7 +422,7 @@ object NichedNSGA2 {
niche = DeterministicParams.niche(genome, exactObjectives, niche),
operatorExploration = operatorExploration,
nicheSize = nicheSize,
filter = filter.option),
reject = reject.option),
genome,
exactObjectives
)
......@@ -441,7 +441,7 @@ object NichedNSGA2 {
objectives = noisyObjectives,
historySize = stochasticValue.replications,
cloneProbability = stochasticValue.reevaluate,
filter = filter.option),
reject = reject.option),
genome,
noisyObjectives,
stochasticValue
......@@ -465,7 +465,7 @@ object NichedNSGA2Evolution {
nicheSize: Int,
stochastic: OptionalArgument[Stochastic] = None,
parallelism: Int = 1,
filter: OptionalArgument[Condition] = None,
reject: OptionalArgument[Condition] = None,
distribution: EvolutionPattern = SteadyState(),
suggestion: Suggestion = Suggestion.empty,
scope: DefinitionScope = "niched nsga2") =
......@@ -477,7 +477,7 @@ object NichedNSGA2Evolution {
nicheSize = nicheSize,
objectives = objectives,
stochastic = stochastic,
filter = filter
reject = reject
),
evaluation = evaluation,
termination = termination,
......
......@@ -26,7 +26,7 @@ object OSE {
genome: Genome,
objectives: Seq[ExactObjective[_]],
operatorExploration: Double,
filter: Option[Condition])
reject: Option[Condition])
object DeterministicParams {
......@@ -76,14 +76,14 @@ object OSE {
def breeding(individuals: Vector[I], n: Int, s: S, rng: scala.util.Random) = FromContext { p
import p._
val discrete = Genome.discrete(om.genome).from(context)
val filterValue = om.filter.map(f GAIntegration.filterValue[G](f, om.genome, _.continuousValues.toVector, _.discreteValues.toVector).from(context))
val rejectValue = om.reject.map(f GAIntegration.rejectValue[G](f, om.genome, _.continuousValues.toVector, _.discreteValues.toVector).from(context))
MGOOSE.adaptiveBreeding[Array[Any]](
n,
om.operatorExploration,
discrete,
om.origin,
ExactObjective.toFitnessFunction(om.objectives),
filterValue) apply (s, individuals, rng)
rejectValue) apply (s, individuals, rng)
}
def elitism(population: Vector[I], candidates: Vector[I], s: S, rng: scala.util.Random) =
......@@ -109,7 +109,7 @@ object OSE {
historySize: Int,
cloneProbability: Double,
operatorExploration: Double,
filter: Option[Condition])
reject: Option[Condition])
object StochasticParams {
......@@ -160,7 +160,7 @@ object OSE {
def breeding(individuals: Vector[I], n: Int, s: S, rng: scala.util.Random) = FromContext { p
import p._
val discrete = Genome.discrete(om.genome).from(context)
val filterValue = om.filter.map(f GAIntegration.filterValue[G](f, om.genome, _.continuousValues.toVector, _.discreteValues.toVector).from(context))
val rejectValue = om.reject.map(f GAIntegration.rejectValue[G](f, om.genome, _.continuousValues.toVector, _.discreteValues.toVector).from(context))
MGONoisyOSE.adaptiveBreeding[Array[Any]](
n,
......@@ -170,7 +170,7 @@ object OSE {
discrete,
om.origin,
om.limit,
filterValue) apply (s, individuals, rng)
rejectValue) apply (s, individuals, rng)
}
def elitism(population: Vector[I], candidates: Vector[I], s: S, rng: scala.util.Random) =
......@@ -275,7 +275,7 @@ object OSE {
genome: Genome = Seq(),
mu: Int = 200,
stochastic: OptionalArgument[Stochastic] = None,
filter: OptionalArgument[Condition] = None): EvolutionWorkflow =
reject: OptionalArgument[Condition] = None): EvolutionWorkflow =
WorkflowIntegration.stochasticity(objectives.map(_.objective), stochastic.option) match {
case None
val exactObjectives = FitnessPattern.toObjectives(objectives).map(o Objective.toExact(o))
......@@ -290,7 +290,7 @@ object OSE {
objectives = exactObjectives,
limit = FitnessPattern.toLimit(objectives),
operatorExploration = operatorExploration,
filter = filter.option),
reject = reject.option),
fg,
exactObjectives
)
......@@ -311,7 +311,7 @@ object OSE {
operatorExploration = operatorExploration,
historySize = stochasticValue.replications,
cloneProbability = stochasticValue.reevaluate,
filter = filter.option),
reject = reject.option),
fg,
noisyObjectives,
stochasticValue
......@@ -334,7 +334,7 @@ object OSEEvolution {
mu: Int = 200,
genome: Genome = Seq(),
stochastic: OptionalArgument[Stochastic] = None,
filter: OptionalArgument[Condition] = None,
reject: OptionalArgument[Condition] = None,
parallelism: Int = 1,
distribution: EvolutionPattern = SteadyState(),
suggestion: Suggestion = Suggestion.empty,
......@@ -347,7 +347,7 @@ object OSEEvolution {
objectives = objectives,
stochastic = stochastic,
mu = mu,
filter = filter
reject = reject
),
evaluation = evaluation,
termination = termination,
......
......@@ -81,7 +81,7 @@ object PSEAlgorithm {
def adaptiveBreeding[S, P](
lambda: Int,
filter: Option[CDGenome.Genome Boolean],
reject: Option[CDGenome.Genome Boolean],
operatorExploration: Double,
discrete: Vector[D],
pattern: P Vector[Int],
......@@ -96,7 +96,7 @@ object PSEAlgorithm {
Individual.phenotype[P].get _ andThen pattern,
buildGenome,
lambda,
filter,
reject,
operatorExploration,
hitmap)
......@@ -136,7 +136,7 @@ object NoisyPSEAlgorithm {
def adaptiveBreeding[S, P: Manifest](
lambda: Int,
filter: Option[Genome Boolean],
reject: Option[Genome Boolean],
operatorExploration: Double,
cloneProbability: Double,
aggregation: Vector[P] Vector[Double],
......@@ -153,7 +153,7 @@ object NoisyPSEAlgorithm {
vectorPhenotype.get _ andThen aggregation andThen pattern,
buildGenome,
lambda,
filter,
reject,
operatorExploration,
cloneProbability,
hitmap)
......@@ -220,7 +220,7 @@ object PSE {
genome: Genome,
objectives: Seq[ExactObjective[_]],
operatorExploration: Double,
filter: Option[Condition]
reject: Option[Condition]
)
object DeterministicParams {
......@@ -272,10 +272,10 @@ object PSE {
def breeding(individuals: Vector[I], n: Int, s: S, rng: scala.util.Random) = FromContext { p
import p._
val discrete = Genome.discrete(om.genome).from(context)
val filterValue = om.filter.map(f GAIntegration.filterValue[G](f, om.genome, _.continuousValues.toVector, _.discreteValues.toVector).from(context))
val rejectValue = om.reject.map(f GAIntegration.rejectValue[G](f, om.genome, _.continuousValues.toVector, _.discreteValues.toVector).from(context))
PSEAlgorithm.adaptiveBreeding[S, Array[Any]](
n,
filterValue,
rejectValue,
om.operatorExploration,
discrete,
pattern,
......@@ -306,7 +306,7 @@ object PSE {
historySize: Int,
cloneProbability: Double,
operatorExploration: Double,
filter: Option[Condition])
reject: Option[Condition])
object StochasticParams {
......@@ -357,10 +357,10 @@ object PSE {
def breeding(individuals: Vector[I], n: Int, s: S, rng: scala.util.Random) = FromContext { p
import p._
val discrete = Genome.discrete(om.genome).from(context)
val filterValue = om.filter.map(f GAIntegration.filterValue[G](f, om.genome, _.continuousValues.toVector, _.discreteValues.toVector).from(context))
val rejectValue = om.reject.map(f GAIntegration.rejectValue[G](f, om.genome, _.continuousValues.toVector, _.discreteValues.toVector).from(context))
NoisyPSEAlgorithm.adaptiveBreeding[S, Array[Any]](
n,
filterValue,
rejectValue,
om.operatorExploration,
om.cloneProbability,
NoisyObjective.aggregate(om.objectives),
......@@ -414,7 +414,7 @@ object PSE {
genome: Genome,
objectives: Seq[PatternAxe],
stochastic: OptionalArgument[Stochastic] = None,
filter: OptionalArgument[Condition] = None
reject: OptionalArgument[Condition] = None
) =
WorkflowIntegration.stochasticity(objectives.map(_.p), stochastic.option) match {
case None
......@@ -426,7 +426,7 @@ object PSE {
genome,
exactObjectives,
operatorExploration,
filter = filter.option),
reject = reject.option),
genome,
exactObjectives)(DeterministicParams.integration)
......@@ -442,7 +442,7 @@ object PSE {
historySize = stochasticValue.replications,
cloneProbability = stochasticValue.reevaluate,
operatorExploration = operatorExploration,
filter = filter.option),
reject = reject.option),
genome,
noisyObjectives,
stochasticValue)(StochasticParams.integration)
......@@ -462,7 +462,7 @@ object PSEEvolution {
evaluation: DSL,
termination: OMTermination,
stochastic: OptionalArgument[Stochastic] = None,
filter: OptionalArgument[Condition] = None,
reject: OptionalArgument[Condition] = None,
parallelism: Int = 1,
distribution: EvolutionPattern = SteadyState(),
suggestion: Suggestion = Suggestion.empty,
......@@ -473,7 +473,7 @@ object PSEEvolution {
genome = genome,
objectives = objectives,
stochastic = stochastic,
filter = filter
reject = reject
),
evaluation = evaluation,
termination = termination,
......
......@@ -32,7 +32,7 @@ object Profile {
genome: Genome,
objective: Objective[_],
stochastic: OptionalArgument[Stochastic] = None,
filter: OptionalArgument[Condition] = None,
reject: OptionalArgument[Condition] = None,
nicheSize: OptionalArgument[Int] = None
) = {
stochastic.option match {
......@@ -42,7 +42,7 @@ object Profile {
genome,
objectives = Seq(objective),
nicheSize = nicheSize.option.getOrElse(1),
filter = filter
reject = reject
)
case Some(stochastic)
NichedNSGA2(
......@@ -51,7 +51,7 @@ object Profile {
Seq(objective),
nicheSize.option.getOrElse(10),
stochastic = stochastic,
filter = filter
reject = reject
)
}
}
......@@ -71,7 +71,7 @@ object ProfileEvolution {
termination: OMTermination,
nicheSize: OptionalArgument[Int] = None,
stochastic: OptionalArgument[Stochastic] = None,
filter: OptionalArgument[Condition] = None,
reject: OptionalArgument[Condition] = None,
parallelism: Int = 1,
distribution: EvolutionPattern = SteadyState(),
suggestion: Suggestion = Suggestion.empty,
......@@ -85,7 +85,7 @@ object ProfileEvolution {
objective = objective,
stochastic = stochastic,
nicheSize = nicheSize,
filter = filter
reject = reject
),
evaluation = evaluation,
termination = termination,
......
......@@ -265,10 +265,10 @@ object GAIntegration {
)
}
def filterValue[G](filter: Condition, genome: Genome, continuous: G Vector[Double], discrete: G Vector[Int]) = FromContext { p (g: G)
def rejectValue[G](reject: Condition, genome: Genome, continuous: G Vector[Double], discrete: G Vector[Int]) = FromContext { p (g: G)
import p._
val genomeVariables = GAIntegration.genomeToVariable(genome, (continuous(g), discrete(g)), scale = true).from(context)
filter.from(genomeVariables)
reject.from(genomeVariables)
}
}
......
......@@ -9,7 +9,7 @@ object Libraries {
lazy val gridscaleVersion = "2.27"
lazy val sshjVersion = "0.27.0"
lazy val containerVersion = "1.4"
lazy val mgoVersion = "3.39"
lazy val mgoVersion = "3.40"
lazy val bouncyCastleVersion = "1.60"
lazy val d3Version = "3.5.12"
lazy val tooltipserVersion = "3.3.0"
......
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