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

[Plugin] fix: omr

parent f06c56d1
Pipeline #1222 passed with stages
in 44 minutes and 52 seconds
......@@ -245,6 +245,8 @@ case class Namespace(names: String*) {
if (names.isEmpty) ""
else names.mkString("$")
def isEmpty = names.isEmpty
def prefix(s: String*) = Namespace(s ++ names: _*)
def postfix(s: String*) = Namespace(names ++ s: _*)
}
/**
......
......@@ -33,7 +33,7 @@ object MetadataGeneration {
}
def objectiveData(o: Objective) =
EvolutionMetadata.Objective(o.as.getOrElse(Objective.prototype(o).name), o.delta, o.negative, o.noisy)
EvolutionMetadata.Objective(Objective.resultPrototype(o).name, o.delta, o.negative, o.noisy)
def fromString(s: String): EvolutionMetadata =
decode[EvolutionMetadata](s) match {
......
......@@ -110,6 +110,18 @@ object Objective {
def prototype(o: Objective) = if (!o.noisy) o.prototype else o.prototype.unsecureFromArray
def resultPrototype(o: Objective) = {
def objectiveNamespace(p: Val[_]) = p.withNamespace(p.namespace.prefix("objective"))
def p = (o.delta, o.as) match {
case (_, Some(s)) Objective.prototype(o).withName(s)
case (Some(_), None) Objective.prototype(o).withNamespace(Objective.prototype(o).namespace.postfix("delta"))
case _ Objective.prototype(o)
}
objectiveNamespace(p)
}
case class ComputeValue[P](
prototype: Val[P],
toDouble: FromContext[P Double],
......@@ -152,16 +164,7 @@ object Objectives {
def toExact(o: Objectives) = o.map(o Objective.toExact(o))
def toNoisy(o: Objectives) = o.map(o Objective.toNoisy(o))
def resultPrototypes(o: Objectives) = {
def resultPrototype(o: Objective) =
(o.delta, o.as) match {
case (_, Some(s)) Objective.prototype(o).withName(s)
case (Some(_), None) Objective.prototype(o).withNamespace(Objective.prototype(o).namespace.names ++ Seq("delta"))
case _ Objective.prototype(o)
}
o.map(resultPrototype)
}
def resultPrototypes(o: Objectives) = o.map(Objective.resultPrototype)
def validate(o: Objectives, outputs: Seq[Val[_]]) = Validate { p
import p._
......
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