Commit 1355e796 authored by Romain Reuillon's avatar Romain Reuillon

[Plugin] enh: add objective metadata

parent b12b6d42
......@@ -26,17 +26,11 @@ sealed trait GUIPlugin
trait AuthenticationPlugin extends GUIPlugin {
type AuthType <: AuthenticationData
def data: AuthType
def factory: AuthenticationPluginFactory
def panel: TypedTag[HTMLElement]
def save(onsave: () Unit): Unit
def remove(onremoved: () Unit): Unit
def test: Future[Seq[Test]]
}
......@@ -46,18 +40,13 @@ sealed trait GUIPluginFactory {
trait AuthenticationPluginFactory extends GUIPluginFactory {
type AuthType <: AuthenticationData
def build(data: AuthType): AuthenticationPlugin
def buildEmpty: AuthenticationPlugin
def getData: Future[Seq[AuthType]]
}
trait WizardGUIPlugin extends GUIPlugin {
def factory: WizardPluginFactory
val panel: TypedTag[HTMLElement]
def save(
......@@ -71,10 +60,7 @@ trait WizardGUIPlugin extends GUIPlugin {
}
trait WizardPluginFactory extends GUIPluginFactory {
def build(safePath: SafePath, onPanelFilled: (LaunchingCommand) Unit): WizardGUIPlugin
def fileType: FileType
def parse(safePath: SafePath): Future[Option[LaunchingCommand]]
}
\ No newline at end of file
package org.openmole.plugin.method.evolution
import org.openmole.core.context.Val
import org.openmole.core.expansion.FromContext
import io.circe._
import io.circe.generic.extras.auto._
import io.circe.parser._
import io.circe.generic.extras.semiauto._
import io.circe.generic.extras.Configuration
import org.openmole.core.exception.InternalProcessingError
import org.openmole.core.tools.io.Prettifier._
object Metadata {
def method = "evolution"
implicit val genDevConfig: Configuration = Configuration.default.withDiscriminator("implementation")
implicit val genDevConfig: Configuration = Configuration.default.withDiscriminator("implementation").withKebabCaseMemberNames
implicit val metadataEncoder: Encoder[Metadata] = deriveConfiguredEncoder[Metadata]
case class nsga2(genome: Seq[GenomeBoundData], generation: Long, frequency: Option[Long], method: String = method) extends Metadata
case class StochasticNSGA2(
genome: Seq[GenomeBoundData],
objective: Seq[NoisyObjectiveData],
generation: Long,
frequency: Option[Long],
method: String = method) extends Metadata
case object none extends Metadata
sealed trait GenomeBoundData
......@@ -26,19 +33,37 @@ object Metadata {
def apply(b: GenomeBound) = FromContext { p
import p._
b match {
case b: GenomeBound.ScalarDouble bound(b.v.name, b.low.from(context).prettify(), b.high.from(context).prettify())
case b: GenomeBound.ScalarInt bound(b.v.name, b.low.from(context).prettify(), b.high.from(context).prettify())
case b: GenomeBound.SequenceOfDouble bound(b.v.name, b.low.from(context).prettify(), b.high.from(context).prettify())
case b: GenomeBound.SequenceOfInt bound(b.v.name, b.low.from(context).prettify(), b.high.from(context).prettify())
case b: GenomeBound.Enumeration[_] enumeration(b.v.name, b.values.prettify())
case b: GenomeBound.SequenceOfEnumeration[_] enumeration(b.v.name, b.values.prettify())
case b: GenomeBound.ScalarDouble DoubleBound(b.v.name, b.low.from(context), b.high.from(context))
case b: GenomeBound.ScalarInt IntBound(b.v.name, b.low.from(context), b.high.from(context))
case b: GenomeBound.SequenceOfDouble DoubleSequenceBound(b.v.name, b.low.from(context), b.high.from(context))
case b: GenomeBound.SequenceOfInt IntSequenceBound(b.v.name, b.low.from(context), b.high.from(context))
case b: GenomeBound.Enumeration[_] Enumeration(b.v.name, b.values.map(_.prettify()))
case b: GenomeBound.SequenceOfEnumeration[_] Enumeration(b.v.name, b.values.map(_.prettify()))
}
}
case class bound(value: String, low: String, high: String) extends GenomeBoundData
case class enumeration(value: String, values: String) extends GenomeBoundData
case class DoubleBound(value: String, low: Double, high: Double) extends GenomeBoundData
case class IntBound(value: String, low: Int, high: Int) extends GenomeBoundData
case class DoubleSequenceBound(value: String, low: Array[Double], high: Array[Double]) extends GenomeBoundData
case class IntSequenceBound(value: String, low: Array[Int], high: Array[Int]) extends GenomeBoundData
case class Enumeration(value: String, values: Seq[String]) extends GenomeBoundData
}
object NoisyObjectiveData {
def apply(o: NoisyObjective[_]) = new NoisyObjectiveData(o.as.getOrElse(o.prototype.name), o.delta, o.negative)
}
case class NoisyObjectiveData(
name: String,
delta: Option[Double],
negative: Boolean)
def fromString(s: String): Metadata =
decode[Metadata](s) match {
case Left(e) throw new InternalProcessingError(s"Error parsing metadata $s", e)
case Right(m) m
}
}
sealed trait Metadata
\ No newline at end of file
......@@ -156,8 +156,9 @@ object NSGA2 {
override def metadata(generation: Long, frequency: Option[Long]) = FromContext { p
import p._
import Metadata._
nsga2(
om.genome.map(GenomeBoundData(_).from(context)),
StochasticNSGA2(
genome = om.genome.map(GenomeBoundData(_).from(context)),
objective = om.objectives.map(NoisyObjectiveData(_)),
generation = generation,
frequency = frequency
)
......
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