Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
openmole
openmole
Commits
0b3b73a4
Commit
0b3b73a4
authored
Jun 21, 2019
by
Guillaume Chérel
Browse files
[Plugin] fix inputs outputs order.
parent
d6d9f4e2
Changes
4
Hide whitespace changes
Inline
Side-by-side
openmole/plugins/org.openmole.plugin.method.sensitivity/src/main/scala/org/openmole/plugin/method/sensitivity/SaltelliAggregation.scala
View file @
0b3b73a4
...
...
@@ -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
)
}
...
...
openmole/plugins/org.openmole.plugin.method.sensitivity/src/main/scala/org/openmole/plugin/method/sensitivity/SaltelliSampling.scala
View file @
0b3b73a4
...
...
@@ -79,5 +79,4 @@ class SaltelliSampling(val samples: FromContext[Int], val factors: ScalarOrSeque
(
aVariables
++
bVariables
++
cVariables
).
toIterator
}
}
openmole/plugins/org.openmole.plugin.method.sensitivity/src/main/scala/org/openmole/plugin/method/sensitivity/package.scala
View file @
0b3b73a4
...
...
@@ -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
)
...
...
openmole/plugins/org.openmole.plugin.method.sensitivity/src/test/scala/org/openmole/plugin/method/sensitivity/SaltelliSpec.scala
View file @
0b3b73a4
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
()
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment