Commit 1ad8d518 authored by Romain Reuillon's avatar Romain Reuillon
Browse files

[Method] fix: separate output method for morris and saltelli

parent 9c3bfe1f
......@@ -112,9 +112,17 @@ object MorrisAggregation {
modelInputs: Seq[ScalarOrSequenceOfDouble[_]],
modelOutputs: Seq[Val[Double]])(implicit name: sourcecode.Name, definitionScope: DefinitionScope) = {
val muOutputs = Sensitivity.outputs(modelInputs, modelOutputs).map { case (i, o) Morris.mu(i, o) }
val muStarOutputs = Sensitivity.outputs(modelInputs, modelOutputs).map { case (i, o) Morris.muStar(i, o) }
val sigmaOutputs = Sensitivity.outputs(modelInputs, modelOutputs).map { case (i, o) Morris.sigma(i, o) }
def morrisOutputs(
modelInputs: Seq[ScalarOrSequenceOfDouble[_]],
modelOutputs: Seq[Val[Double]]) =
for {
i ScalarOrSequenceOfDouble.prototypes(modelInputs)
o modelOutputs
} yield (i, o)
val muOutputs = morrisOutputs(modelInputs, modelOutputs).map { case (i, o) Morris.mu(i, o) }
val muStarOutputs = morrisOutputs(modelInputs, modelOutputs).map { case (i, o) Morris.muStar(i, o) }
val sigmaOutputs = morrisOutputs(modelInputs, modelOutputs).map { case (i, o) Morris.sigma(i, o) }
FromContextTask("MorrisAggregation") { p
import p._
......@@ -126,7 +134,7 @@ object MorrisAggregation {
// for each part of the space we were asked to explore, compute the elementary effects and returns them
// into the variables passed by the user
val List(mu, muStar, sigma) =
Sensitivity.outputs(modelInputs, modelOutputs).map {
morrisOutputs(modelInputs, modelOutputs).map {
case (input, output)
val outputValues: Array[Double] = context(output.toArray)
MorrisSampling.Log.logger.fine("Processing the elementary change for input " + input + " on " + output)
......
......@@ -65,8 +65,16 @@ object SaltelliAggregation {
firstOrderSI: Val[Array[Array[Double]]] = Val[Array[Array[Double]]]("firstOrderSI"),
totalOrderSI: Val[Array[Array[Double]]] = Val[Array[Array[Double]]]("totalOrderSI"))(implicit name: sourcecode.Name, definitionScope: DefinitionScope) = {
val fOOutputs = Sensitivity.outputs(modelInputs, modelOutputs).map { case (i, o) Saltelli.firstOrder(i, o) }
val tOOutputs = Sensitivity.outputs(modelInputs, modelOutputs).map { case (i, o) Saltelli.totalOrder(i, o) }
def saltelliOutputs(
modelInputs: Seq[ScalarOrSequenceOfDouble[_]],
modelOutputs: Seq[Val[Double]]) =
for {
o modelOutputs
i ScalarOrSequenceOfDouble.prototypes(modelInputs)
} yield (i, o)
val fOOutputs = saltelliOutputs(modelInputs, modelOutputs).map { case (i, o) Saltelli.firstOrder(i, o) }
val tOOutputs = saltelliOutputs(modelInputs, modelOutputs).map { case (i, o) Saltelli.totalOrder(i, o) }
FromContextTask("SaltelliAggregation") { p
import p._
......@@ -100,7 +108,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
......
......@@ -63,14 +63,6 @@ package object sensitivity {
}
}
def outputs(
modelInputs: Seq[ScalarOrSequenceOfDouble[_]],
modelOutputs: Seq[Val[Double]]) =
for {
o modelOutputs
i ScalarOrSequenceOfDouble.prototypes(modelInputs)
} yield (i, o)
case class SaltelliParams(inputs: Seq[ScalarOrSequenceOfDouble[_]], outputs: Seq[Val[_]])
case class MorrisParams(inputs: Seq[ScalarOrSequenceOfDouble[_]], outputs: Seq[Val[_]])
......
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