Commit 0b3b73a4 authored by Guillaume Chérel's avatar Guillaume Chérel
Browse files

[Plugin] fix inputs outputs order.

parent d6d9f4e2
......@@ -100,7 +100,6 @@ object SaltelliAggregation {
val ftoi: Array[(Array[Double], Array[Double])] =
(fA zip fB zip fC).map { case ((fAo, fBo), fCo) firstAndTotalOrderIndices(fAo, fBo, fCo) }
// first order indices
// fosi(o)(i) contains first order index for input i on output o.
val fosi = ftoi.map { _._1.toArray }.toArray
......@@ -121,6 +120,9 @@ object SaltelliAggregation {
v ScalarOrSequenceOfDouble.unflatten(modelInputs, tosi(oi), scale = false).from(context)
} yield v.value
println("fOOutputs " ++ fOOutputs.toString)
println("fosiv " ++ fosiv.toString)
context ++
(fOOutputs zip fosiv).map { case (fo, v) Variable.unsecure(fo, v) } ++
(tOOutputs zip tosiv).map { case (to, v) Variable.unsecure(to, v) }
......
......@@ -79,5 +79,4 @@ class SaltelliSampling(val samples: FromContext[Int], val factors: ScalarOrSeque
(aVariables ++ bVariables ++ cVariables).toIterator
}
}
......@@ -67,8 +67,8 @@ package object sensitivity {
modelInputs: Seq[ScalarOrSequenceOfDouble[_]],
modelOutputs: Seq[Val[Double]]) =
for {
i ScalarOrSequenceOfDouble.prototypes(modelInputs)
o modelOutputs
i ScalarOrSequenceOfDouble.prototypes(modelInputs)
} yield (i, o)
......
package org.openmole.plugin.method.sensitivity
import org.scalatest.{FlatSpec, Matchers}
import org.scalatest.{ FlatSpec, Matchers }
import org.openmole.core.dsl._
import org.openmole.core.workflow.test._
import scala.util.Random
......@@ -23,34 +23,37 @@ class Saltelli extends FlatSpec with Matchers {
val x2 = Val[Double]
val y1 = Val[Double]
val y2 = Val[Double]
val y3 = Val[Double]
/* Expected values of first order (SI) and total order (STI) sensitivity indices.
*
* - y1, x1: SI1 = 4/5, STI1 = 4/5
* - y1, x2: SI2 = 1/5, STI2 = 1/5
* - y2, x1: SI1 = (9 / 4) * (12 / 42) ~= 0.643,
* - y2, x1: SI1 = (9 / 4) * (12 / 42) ~= 0.643,
* STI1 = (7.0 / 36.0) / (40.0 / 144.0) = 0.7
* - y2, x2: SI2 = 12 / 42 ~= 0.286,
* - y2, x2: SI2 = 12 / 42 ~= 0.286,
* STI2 = (13.0 / 144.0) / (40.0 / 144.0) ~= 0.325
*/
val model = TestTask { context => context +
(y1 -> (context(x1) + 0.5 * context(x2) )) +
(y2 -> (context(x1) + 0.5 * context(x2) + context(x1) * context(x2)))
} set(
val model = TestTask { context
context +
(y1 -> (context(x1) + 0.5 * context(x2))) +
(y2 -> (context(x1) + 0.5 * context(x2) + context(x1) * context(x2))) +
(y3 -> (context(x1)))
} set (
inputs += (x1, x2),
outputs += (y1, y2)
outputs += (y1, y2, y3)
)
val sen = SensitivitySaltelli(
val sen = SensitivitySaltelli(
evaluation = model,
samples = 10000,
inputs = Seq(x1 in (0.0,1.0), x2 in (0.0,1.0)),
outputs = Seq(y1, y2)
inputs = Seq(x1 in (0.0, 1.0), x2 in (0.0, 1.0)),
outputs = Seq(y1, y2, y3)
)
"Saltelli" should "run" in {
sen run()
sen run ()
}
}
......
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