Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
openmole
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
RoiArthurB
openmole
Commits
9a6e9aa6
Commit
9a6e9aa6
authored
May 05, 2020
by
Romain Reuillon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Core] enh: add method data to output format
parent
82f7e181
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
149 additions
and
45 deletions
+149
-45
openmole/build.sbt
openmole/build.sbt
+4
-1
openmole/core/org.openmole.core.workflow/src/main/scala/org/openmole/core/workflow/composition/package.scala
...cala/org/openmole/core/workflow/composition/package.scala
+1
-1
openmole/core/org.openmole.core.workflow/src/main/scala/org/openmole/core/workflow/mole/CSVHook.scala
.../main/scala/org/openmole/core/workflow/mole/CSVHook.scala
+2
-2
openmole/core/org.openmole.core.workflow/src/main/scala/org/openmole/core/workflow/mole/FormattedFileHook.scala
...a/org/openmole/core/workflow/mole/FormattedFileHook.scala
+6
-5
openmole/core/org.openmole.core.workflow/src/main/scala/org/openmole/core/workflow/mole/package.scala
.../main/scala/org/openmole/core/workflow/mole/package.scala
+1
-1
openmole/core/org.openmole.core.workflow/src/test/scala/org/openmole/core/workflow/mole/HookSpec.scala
...test/scala/org/openmole/core/workflow/mole/HookSpec.scala
+7
-3
openmole/plugins/org.openmole.plugin.hook.json/src/main/scala/org/openmole/plugin/hook/json/JSONOutputFormat.scala
...cala/org/openmole/plugin/hook/json/JSONOutputFormat.scala
+2
-2
openmole/plugins/org.openmole.plugin.hook.omr/src/main/scala/org/openmole/plugin/hook/omr/Activator.scala
...c/main/scala/org/openmole/plugin/hook/omr/Activator.scala
+46
-0
openmole/plugins/org.openmole.plugin.hook.omr/src/main/scala/org/openmole/plugin/hook/omr/OMROutputFormat.scala
.../scala/org/openmole/plugin/hook/omr/OMROutputFormat.scala
+35
-0
openmole/plugins/org.openmole.plugin.method.directsampling/src/main/scala/org/openmole/plugin/method/directsampling/package.scala
...a/org/openmole/plugin/method/directsampling/package.scala
+6
-6
openmole/plugins/org.openmole.plugin.method.directsampling/src/test/scala/org/openmole/plugin/method/directsampling/DirectSamplingSpec.scala
...ole/plugin/method/directsampling/DirectSamplingSpec.scala
+12
-1
openmole/plugins/org.openmole.plugin.method.evolution/src/main/scala/org/openmole/plugin/method/evolution/SavePopulationHook.scala
...openmole/plugin/method/evolution/SavePopulationHook.scala
+10
-6
openmole/plugins/org.openmole.plugin.method.evolution/src/main/scala/org/openmole/plugin/method/evolution/package.scala
.../scala/org/openmole/plugin/method/evolution/package.scala
+1
-1
openmole/plugins/org.openmole.plugin.method.sensitivity/src/main/scala/org/openmole/plugin/method/sensitivity/MorrisHook.scala
...a/org/openmole/plugin/method/sensitivity/MorrisHook.scala
+7
-7
openmole/plugins/org.openmole.plugin.method.sensitivity/src/main/scala/org/openmole/plugin/method/sensitivity/SaltelliHook.scala
...org/openmole/plugin/method/sensitivity/SaltelliHook.scala
+5
-5
openmole/plugins/org.openmole.plugin.method.sensitivity/src/main/scala/org/openmole/plugin/method/sensitivity/package.scala
...cala/org/openmole/plugin/method/sensitivity/package.scala
+4
-4
No files found.
openmole/build.sbt
View file @
9a6e9aa6
...
...
@@ -441,7 +441,7 @@ lazy val onvariableGrouping = OsgiProject(pluginDir, "org.openmole.plugin.groupi
/* Hook */
def
allHook
=
Seq
(
displayHook
,
fileHook
,
modifierHook
,
jsonHook
)
def
allHook
=
Seq
(
displayHook
,
fileHook
,
modifierHook
,
jsonHook
,
omrHook
)
lazy
val
displayHook
=
OsgiProject
(
pluginDir
,
"org.openmole.plugin.hook.display"
,
imports
=
Seq
(
"*"
))
dependsOn
(
openmoleDSL
)
settings
(
pluginSettings
:
_
*
)
...
...
@@ -454,6 +454,9 @@ lazy val modifierHook = OsgiProject(pluginDir, "org.openmole.plugin.hook.modifie
lazy
val
jsonHook
=
OsgiProject
(
pluginDir
,
"org.openmole.plugin.hook.json"
,
imports
=
Seq
(
"*"
))
dependsOn
(
openmoleDSL
,
json
,
replication
%
"test"
)
settings
(
libraryDependencies
+=
Libraries
.
scalatest
)
settings
(
pluginSettings
:
_
*
)
lazy
val
omrHook
=
OsgiProject
(
pluginDir
,
"org.openmole.plugin.hook.omr"
,
imports
=
Seq
(
"*"
))
dependsOn
(
openmoleDSL
,
json
,
replication
%
"test"
)
settings
(
libraryDependencies
+=
Libraries
.
scalatest
)
settings
(
pluginSettings
:
_
*
)
/* Method */
...
...
openmole/core/org.openmole.core.workflow/src/main/scala/org/openmole/core/workflow/composition/package.scala
View file @
9a6e9aa6
...
...
@@ -141,7 +141,7 @@ package composition {
def
hook
[
F
](
output
:
WritableOutput
,
values
:
Seq
[
Val
[
_
]]
=
Vector
.
empty
,
format
:
F
=
CSVOutputFormat
(
append
=
true
))(
implicit
definitionScope
:
DefinitionScope
,
fileFormat
:
OutputFormat
[
F
])
:
TaskNode
=
hook
(
FormattedFileHook
(
output
=
output
,
values
=
values
,
format
=
format
))
format
:
F
=
CSVOutputFormat
(
append
=
true
))(
implicit
definitionScope
:
DefinitionScope
,
fileFormat
:
OutputFormat
[
F
,
Any
])
:
TaskNode
=
hook
(
FormattedFileHook
(
output
=
output
,
values
=
values
,
format
=
format
))
def
source
(
sources
:
Source*
)
=
copy
(
sources
=
this
.
sources
++
sources
)
}
...
...
openmole/core/org.openmole.core.workflow/src/main/scala/org/openmole/core/workflow/mole/CSVHook.scala
View file @
9a6e9aa6
...
...
@@ -30,8 +30,8 @@ object CSVHook {
object
CSVOutputFormat
{
implicit
def
format
:
OutputFormat
[
CSVOutputFormat
]
=
new
OutputFormat
[
CSVOutputFormat
]
{
override
def
write
(
format
:
CSVOutputFormat
,
output
:
WritableOutput
,
variables
:
Seq
[
Variable
[
_
]])
:
FromContext
[
Unit
]
=
FromContext
{
p
⇒
implicit
def
format
:
OutputFormat
[
CSVOutputFormat
,
Any
]
=
new
OutputFormat
[
CSVOutputFormat
,
Any
]
{
override
def
write
(
format
:
CSVOutputFormat
,
output
:
WritableOutput
,
variables
:
Seq
[
Variable
[
_
]]
,
method
:
Any
)
:
FromContext
[
Unit
]
=
FromContext
{
p
⇒
import
p._
def
headerLine
=
format
.
header
.
map
(
_
.
from
(
context
))
getOrElse
csv
.
header
(
variables
.
map
(
_
.
prototype
),
variables
.
map
(
_
.
value
),
arrayOnRow
=
format
.
arrayOnRow
)
...
...
openmole/core/org.openmole.core.workflow/src/main/scala/org/openmole/core/workflow/mole/FormattedFileHook.scala
View file @
9a6e9aa6
...
...
@@ -8,20 +8,21 @@ import org.openmole.core.exception.UserBadDataError
import
org.openmole.core.expansion.FromContext
import
org.openmole.core.workflow.builder._
trait
OutputFormat
[
T
]
{
def
write
(
format
:
T
,
output
:
WritableOutput
,
variables
:
Seq
[
Variable
[
_
]])
:
FromContext
[
Unit
]
trait
OutputFormat
[
T
,
-M
]
{
def
write
(
format
:
T
,
output
:
WritableOutput
,
variables
:
Seq
[
Variable
[
_
]]
,
method
:
M
)
:
FromContext
[
Unit
]
def
validate
(
format
:
T
)
:
FromContextHook.ValidateParameters
⇒
Seq
[
Throwable
]
def
extension
:
String
}
object
FormattedFileHook
{
def
apply
[
T
:
OutputFormat
](
def
apply
[
T
,
M
](
format
:
T
,
output
:
WritableOutput
,
values
:
Seq
[
Val
[
_
]]
=
Vector
.
empty
,
exclude
:
Seq
[
Val
[
_
]]
=
Vector
.
empty
,
name
:
Option
[
String
]
=
None
)(
implicit
valName
:
sourcecode.Name
,
definitionScope
:
DefinitionScope
,
fileFormat
:
OutputFormat
[
T
])
:
mole.FromContextHook
=
method
:
M
=
None
,
name
:
Option
[
String
]
=
None
)(
implicit
valName
:
sourcecode.Name
,
definitionScope
:
DefinitionScope
,
fileFormat
:
OutputFormat
[
T
,
M
])
:
mole.FromContextHook
=
Hook
(
name
getOrElse
"FileFormatHook"
)
{
parameters
⇒
import
parameters._
...
...
@@ -30,7 +31,7 @@ object FormattedFileHook {
val
ps
=
{
if
(
values
.
isEmpty
)
context
.
values
.
map
{
_
.
prototype
}.
toVector
else
values
}.
filter
{
v
⇒
!
excludeSet
.
contains
(
v
.
name
)
}
val
variables
=
ps
.
map
(
p
⇒
context
.
variable
(
p
).
getOrElse
(
throw
new
UserBadDataError
(
s
"Variable $p not found in hook $this"
)))
fileFormat
.
write
(
format
,
output
,
variables
).
from
(
context
)
fileFormat
.
write
(
format
,
output
,
variables
,
method
).
from
(
context
)
context
}
validate
{
p
⇒
...
...
openmole/core/org.openmole.core.workflow/src/main/scala/org/openmole/core/workflow/mole/package.scala
View file @
9a6e9aa6
...
...
@@ -24,7 +24,7 @@ package mole {
def
CSVHook
=
mole
.
CSVHook
def
CSVOutputFormat
=
mole
.
CSVHook
.
CSVOutputFormat
type
OutputFormat
[
T
]
=
mole
.
OutputFormat
[
T
]
type
OutputFormat
[
T
,
D
]
=
mole
.
OutputFormat
[
T
,
D
]
type
FromContextHook
=
mole
.
FromContextHook
type
FromContextSource
=
mole
.
FromContextSource
}
...
...
openmole/core/org.openmole.core.workflow/src/test/scala/org/openmole/core/workflow/mole/HookSpec.scala
View file @
9a6e9aa6
...
...
@@ -37,8 +37,7 @@ class HookSpec extends FlatSpec with Matchers {
"A hook"
should
"intercept the execution of a task"
in
{
val
executed
=
new
AtomicInteger
(
0
)
val
p
=
Val
[
String
](
"p"
)
val
p
=
Val
[
String
]
val
t1
=
TestTask
{
_
+
(
p
→
"test"
)
}
set
(
...
...
@@ -66,7 +65,6 @@ class HookSpec extends FlatSpec with Matchers {
val
t1
=
TestTask
{
_
+
(
p
→
"test"
)
}
set
(
name
:=
"Test"
,
outputs
+=
p
)
...
...
@@ -83,4 +81,10 @@ class HookSpec extends FlatSpec with Matchers {
executed
should
equal
(
true
)
}
"Display hook"
should
"be accepted"
in
{
val
t1
=
EmptyTask
()
val
ex
=
t1
hook
display
ex
.
run
}
}
openmole/plugins/org.openmole.plugin.hook.json/src/main/scala/org/openmole/plugin/hook/json/JSONOutputFormat.scala
View file @
9a6e9aa6
...
...
@@ -7,8 +7,8 @@ import org.openmole.plugin.tool.json._
object
JSONOutputFormat
{
implicit
def
outputFormat
=
new
OutputFormat
[
JSONOutputFormat
]
{
override
def
write
(
format
:
JSONOutputFormat
,
output
:
WritableOutput
,
variables
:
Seq
[
Variable
[
_
]])
:
FromContext
[
Unit
]
=
FromContext
{
p
⇒
implicit
def
outputFormat
=
new
OutputFormat
[
JSONOutputFormat
,
Any
]
{
override
def
write
(
format
:
JSONOutputFormat
,
output
:
WritableOutput
,
variables
:
Seq
[
Variable
[
_
]]
,
method
:
Any
)
:
FromContext
[
Unit
]
=
FromContext
{
p
⇒
import
p._
import
org.json4s._
import
org.json4s.jackson.JsonMethods._
...
...
openmole/plugins/org.openmole.plugin.hook.omr/src/main/scala/org/openmole/plugin/hook/omr/Activator.scala
0 → 100644
View file @
9a6e9aa6
/*
* Copyright (C) 2015 Romain Reuillon
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package
org.openmole.plugin.hook.omr
import
org.openmole.core.pluginmanager._
import
org.openmole.core.preference.ConfigurationInfo
import
org.osgi.framework.BundleContext
class
Activator
extends
PluginInfoActivator
{
override
def
keyWordTraits
=
List
()
override
def
stop
(
context
:
BundleContext
)
:
Unit
=
{
PluginInfo
.
unregister
(
this
)
ConfigurationInfo
.
unregister
(
this
)
}
override
def
start
(
context
:
BundleContext
)
:
Unit
=
{
import
org.openmole.core.pluginmanager.KeyWord._
val
keyWords
:
Vector
[
KeyWord
]
=
Vector
(
// TaskKeyWord(objectName(JSONHook)),
// OtherKeyWord(objectName(JSONOutputFormat))
)
PluginInfo
.
register
(
this
,
Vector
(
this
.
getClass
.
getPackage
),
keyWords
=
keyWords
)
ConfigurationInfo
.
register
(
this
,
ConfigurationInfo
.
list
()
)
}
}
\ No newline at end of file
openmole/plugins/org.openmole.plugin.hook.omr/src/main/scala/org/openmole/plugin/hook/omr/OMROutputFormat.scala
0 → 100644
View file @
9a6e9aa6
//package org.openmole.plugin.hook.omr
//
//import org.openmole.core.dsl._
//import org.openmole.core.dsl.extension._
//import org.openmole.core.workflow.mole.FromContextHook
//import org.openmole.plugin.tool.json._
//
//object OMROutputFormat {
//
// implicit def outputFormat = new OutputFormat[OMROutputFormat, Any] {
// override def write(format: OMROutputFormat, output: WritableOutput, variables: Seq[Variable[_]]): FromContext[Unit] = FromContext { p ⇒
// import p._
// import org.json4s._
// import org.json4s.jackson.JsonMethods._
//
// implicit val formats = DefaultFormats
//
// output match {
// case WritableOutput.FileValue(file) ⇒
// file.from(context).withPrintStream(append = false, create = true) { ps ⇒
// ps.print(compact(render(variablesToJValue(variables))))
// }
// case WritableOutput.StreamValue(ps, prelude) ⇒
// prelude.foreach(ps.print)
// ps.println(pretty(render(variablesToJValue(variables))))
// }
// }
//
// override def validate(format: OMROutputFormat): FromContextHook.ValidateParameters ⇒ Seq[Throwable] = { p ⇒ Seq() }
// override def extension = ".omr"
// }
//
//}
//
//case class OMROutputFormat()
openmole/plugins/org.openmole.plugin.method.directsampling/src/main/scala/org/openmole/plugin/method/directsampling/package.scala
View file @
9a6e9aa6
...
...
@@ -35,24 +35,24 @@ package object directsampling {
type
Aggregation
=
AggregateTask
.
AggregateVal
[
_
,
_
]
implicit
class
DirectSamplingDSL
(
dsl
:
DSLContainer
[
DirectSampling
])
extends
DSLContainerHook
(
dsl
)
{
def
hook
[
T
:
OutputFormat
](
def
hook
[
T
](
output
:
WritableOutput
,
values
:
Seq
[
Val
[
_
]]
=
Vector
.
empty
,
format
:
T
=
CSVOutputFormat
(
append
=
true
))
:
DSLContainer
[
DirectSampling
]
=
{
format
:
T
=
CSVOutputFormat
(
append
=
true
))
(
implicit
outputFormat
:
OutputFormat
[
T
,
DirectSampling
])
:
DSLContainer
[
DirectSampling
]
=
{
implicit
val
defScope
=
dsl
.
scope
dsl
hook
FormattedFileHook
(
output
=
output
,
values
=
values
,
format
=
format
)
dsl
hook
FormattedFileHook
(
output
=
output
,
values
=
values
,
format
=
format
,
method
=
dsl
.
data
)
}
}
implicit
class
ReplicationDSL
(
dsl
:
DSLContainer
[
Replication
])
extends
DSLContainerHook
(
dsl
)
{
def
hook
[
T
:
OutputFormat
](
def
hook
[
T
](
output
:
WritableOutput
,
values
:
Seq
[
Val
[
_
]]
=
Vector
.
empty
,
includeSeed
:
Boolean
=
false
,
format
:
T
=
CSVOutputFormat
(
append
=
true
))
:
DSLContainer
[
Replication
]
=
{
format
:
T
=
CSVOutputFormat
(
append
=
true
))
(
implicit
outputFormat
:
OutputFormat
[
T
,
Replication
])
:
DSLContainer
[
Replication
]
=
{
implicit
val
defScope
=
dsl
.
scope
val
exclude
=
if
(!
includeSeed
)
Seq
(
dsl
.
data
.
seed
)
else
Seq
()
dsl
hook
FormattedFileHook
(
output
=
output
,
values
=
values
,
exclude
=
exclude
,
format
=
format
)
dsl
hook
FormattedFileHook
(
output
=
output
,
values
=
values
,
exclude
=
exclude
,
format
=
format
,
method
=
dsl
.
data
)
}
}
...
...
openmole/plugins/org.openmole.plugin.method.directsampling/src/test/scala/org/openmole/plugin/method/directsampling/
PatternComposition
Spec.scala
→
openmole/plugins/org.openmole.plugin.method.directsampling/src/test/scala/org/openmole/plugin/method/directsampling/
DirectSampling
Spec.scala
View file @
9a6e9aa6
...
...
@@ -11,7 +11,7 @@ import org.openmole.plugin.tool.pattern._
import
org.scalatest._
import
org.openmole.core.workflow.test._
class
PatternComposition
Spec
extends
FlatSpec
with
Matchers
{
class
DirectSampling
Spec
extends
FlatSpec
with
Matchers
{
import
org.openmole.core.workflow.test.Stubs._
"Direct sampling"
should
"transmit explored inputs"
in
{
...
...
@@ -193,4 +193,15 @@ class PatternCompositionSpec extends FlatSpec with Matchers {
mole
.
run
}
"Direct samplings"
should
"accept display hook"
in
{
val
l
=
Val
[
Double
]
val
model
=
EmptyTask
()
set
(
inputs
+=
l
)
DirectSampling
(
model
,
ExplicitSampling
(
l
,
Seq
(
1.0
,
2.0
))
)
hook
display
}
}
\ No newline at end of file
openmole/plugins/org.openmole.plugin.method.evolution/src/main/scala/org/openmole/plugin/method/evolution/SavePopulationHook.scala
View file @
9a6e9aa6
...
...
@@ -22,13 +22,17 @@ import org.openmole.core.dsl.extension._
object
SavePopulationHook
{
case
class
EvolutionData
()
def
evolutionData
(
t
:
EvolutionWorkflow
)
=
EvolutionData
()
def
resultVariables
(
t
:
EvolutionWorkflow
)
=
FromContext
{
p
⇒
import
p._
context
.
variable
(
t
.
generationPrototype
).
toSeq
++
t
.
operations
.
result
(
context
(
t
.
populationPrototype
).
toVector
,
context
(
t
.
statePrototype
)).
from
(
context
)
}
def
hook
[
F
](
t
:
EvolutionWorkflow
,
output
:
WritableOutput
,
frequency
:
Option
[
Long
],
last
:
Boolean
,
format
:
F
)(
implicit
name
:
sourcecode.Name
,
definitionScope
:
DefinitionScope
,
outputFormat
:
OutputFormat
[
F
])
=
{
def
hook
[
F
](
t
:
EvolutionWorkflow
,
output
:
WritableOutput
,
frequency
:
Option
[
Long
],
last
:
Boolean
,
format
:
F
)(
implicit
name
:
sourcecode.Name
,
definitionScope
:
DefinitionScope
,
outputFormat
:
OutputFormat
[
F
,
EvolutionData
])
=
{
Hook
(
"SavePopulationHook"
)
{
p
⇒
import
p._
...
...
@@ -44,7 +48,7 @@ object SavePopulationHook {
output
match
{
case
WritableOutput
.
FileValue
(
dir
)
⇒
saveFile
(
dir
)
match
{
case
Some
(
outputFile
)
⇒
outputFormat
.
write
(
format
,
outputFile
.
from
(
context
),
resultVariables
(
t
).
from
(
context
)).
from
(
context
)
case
Some
(
outputFile
)
⇒
outputFormat
.
write
(
format
,
outputFile
.
from
(
context
),
resultVariables
(
t
).
from
(
context
)
,
evolutionData
(
t
)
).
from
(
context
)
case
None
⇒
}
case
o
⇒
...
...
@@ -55,7 +59,7 @@ object SavePopulationHook {
case
_
⇒
false
}
if
(
save
)
outputFormat
.
write
(
format
,
o
,
resultVariables
(
t
).
from
(
context
)).
from
(
context
)
if
(
save
)
outputFormat
.
write
(
format
,
o
,
resultVariables
(
t
).
from
(
context
)
,
evolutionData
(
t
)
).
from
(
context
)
}
context
...
...
@@ -63,7 +67,7 @@ object SavePopulationHook {
}
def
apply
[
T
,
F
:
OutputFormat
](
algorithm
:
T
,
output
:
WritableOutput
,
frequency
:
OptionalArgument
[
Long
]
=
None
,
last
:
Boolean
=
false
,
format
:
F
=
CSVOutputFormat
(
unrollArray
=
true
))(
implicit
wfi
:
WorkflowIntegration
[
T
],
name
:
sourcecode.Name
,
definitionScope
:
DefinitionScope
)
=
{
def
apply
[
T
,
F
](
algorithm
:
T
,
output
:
WritableOutput
,
frequency
:
OptionalArgument
[
Long
]
=
None
,
last
:
Boolean
=
false
,
format
:
F
=
CSVOutputFormat
(
unrollArray
=
true
))(
implicit
wfi
:
WorkflowIntegration
[
T
],
name
:
sourcecode.Name
,
definitionScope
:
DefinitionScope
,
outputFormat
:
OutputFormat
[
F
,
EvolutionData
]
)
=
{
val
t
=
wfi
(
algorithm
)
hook
(
t
,
output
,
frequency
.
option
,
last
=
last
,
format
=
format
)
}
...
...
@@ -72,14 +76,14 @@ object SavePopulationHook {
object
SaveLastPopulationHook
{
def
apply
[
T
,
F
](
algorithm
:
T
,
output
:
WritableOutput
,
format
:
F
=
CSVOutputFormat
(
unrollArray
=
true
))(
implicit
wfi
:
WorkflowIntegration
[
T
],
name
:
sourcecode.Name
,
definitionScope
:
DefinitionScope
,
outputFormat
:
OutputFormat
[
F
])
=
{
def
apply
[
T
,
F
](
algorithm
:
T
,
output
:
WritableOutput
,
format
:
F
=
CSVOutputFormat
(
unrollArray
=
true
))(
implicit
wfi
:
WorkflowIntegration
[
T
],
name
:
sourcecode.Name
,
definitionScope
:
DefinitionScope
,
outputFormat
:
OutputFormat
[
F
,
SavePopulationHook.EvolutionData
])
=
{
val
t
=
wfi
(
algorithm
)
Hook
(
"SaveLastPopulationHook"
)
{
p
⇒
import
p._
import
org.openmole.core.csv
outputFormat
.
write
(
format
,
output
,
SavePopulationHook
.
resultVariables
(
t
).
from
(
context
)).
from
(
context
)
outputFormat
.
write
(
format
,
output
,
SavePopulationHook
.
resultVariables
(
t
).
from
(
context
)
,
SavePopulationHook
.
evolutionData
(
t
)
).
from
(
context
)
context
}
set
(
inputs
+=
(
t
.
populationPrototype
,
t
.
statePrototype
))
...
...
openmole/plugins/org.openmole.plugin.method.evolution/src/main/scala/org/openmole/plugin/method/evolution/package.scala
View file @
9a6e9aa6
...
...
@@ -99,7 +99,7 @@ package object evolution {
implicit
def
workflowIntegration
=
WorkflowIntegration
[
DSLContainer
[
EvolutionWorkflow
]](
_
.
data
)
implicit
class
EvolutionMethodContainer
(
dsl
:
DSLContainer
[
EvolutionWorkflow
])
extends
DSLContainerHook
(
dsl
)
{
def
hook
[
F
:
OutputFormat
](
output
:
WritableOutput
,
frequency
:
OptionalArgument
[
Long
]
=
None
,
last
:
Boolean
=
false
,
format
:
F
=
CSVOutputFormat
()
)
:
DSLContainer
[
EvolutionWorkflow
]
=
{
def
hook
[
F
](
output
:
WritableOutput
,
frequency
:
OptionalArgument
[
Long
]
=
None
,
last
:
Boolean
=
false
,
format
:
F
=
CSVOutputFormat
())(
implicit
outputFormat
:
OutputFormat
[
F
,
SavePopulationHook.EvolutionData
]
)
:
DSLContainer
[
EvolutionWorkflow
]
=
{
implicit
val
defScope
=
dsl
.
scope
dsl
.
hook
(
SavePopulationHook
(
dsl
,
output
,
frequency
=
frequency
,
last
=
last
,
format
=
format
))
}
...
...
openmole/plugins/org.openmole.plugin.method.sensitivity/src/main/scala/org/openmole/plugin/method/sensitivity/MorrisHook.scala
View file @
9a6e9aa6
...
...
@@ -5,7 +5,7 @@ import org.openmole.core.dsl.extension._
object
MorrisHook
{
def
apply
[
F
](
dsl
:
DSLContainer
[
Sensitivity.MorrisParams
],
output
:
WritableOutput
,
format
:
F
=
CSVOutputFormat
())(
implicit
name
:
sourcecode.Name
,
definitionScope
:
DefinitionScope
,
outputFormat
:
OutputFormat
[
F
])
=
def
apply
[
F
](
dsl
:
DSLContainer
[
Sensitivity.MorrisParams
],
output
:
WritableOutput
,
format
:
F
=
CSVOutputFormat
())(
implicit
name
:
sourcecode.Name
,
definitionScope
:
DefinitionScope
,
outputFormat
:
OutputFormat
[
F
,
Sensitivity.MorrisParams
])
=
Hook
(
"MorrisHook"
)
{
p
⇒
import
p._
import
WritableOutput._
...
...
@@ -14,13 +14,13 @@ object MorrisHook {
output
match
{
case
FileValue
(
dirFC
)
⇒
Sensitivity
.
writeResults
(
format
,
FileValue
(
dirFC
/
s
"mu${outputFormat.extension}"
),
inputs
,
dsl
.
data
.
outputs
,
Morris
.
mu
(
_
,
_
)).
from
(
context
)
Sensitivity
.
writeResults
(
format
,
FileValue
(
dirFC
/
s
"muStar${outputFormat.extension}"
),
inputs
,
dsl
.
data
.
outputs
,
Morris
.
muStar
(
_
,
_
)).
from
(
context
)
Sensitivity
.
writeResults
(
format
,
FileValue
(
dirFC
/
s
"sigma${outputFormat.extension}"
),
inputs
,
dsl
.
data
.
outputs
,
Morris
.
sigma
(
_
,
_
)).
from
(
context
)
Sensitivity
.
writeResults
(
format
,
dsl
.
data
,
FileValue
(
dirFC
/
s
"mu${outputFormat.extension}"
),
inputs
,
dsl
.
data
.
outputs
,
Morris
.
mu
(
_
,
_
)).
from
(
context
)
Sensitivity
.
writeResults
(
format
,
dsl
.
data
,
FileValue
(
dirFC
/
s
"muStar${outputFormat.extension}"
),
inputs
,
dsl
.
data
.
outputs
,
Morris
.
muStar
(
_
,
_
)).
from
(
context
)
Sensitivity
.
writeResults
(
format
,
dsl
.
data
,
FileValue
(
dirFC
/
s
"sigma${outputFormat.extension}"
),
inputs
,
dsl
.
data
.
outputs
,
Morris
.
sigma
(
_
,
_
)).
from
(
context
)
case
StreamValue
(
ps
,
prelude
)
⇒
Sensitivity
.
writeResults
(
format
,
StreamValue
(
ps
,
Some
(
prelude
.
getOrElse
(
""
)
+
"mu\n"
)),
inputs
,
dsl
.
data
.
outputs
,
Morris
.
mu
(
_
,
_
)).
from
(
context
)
Sensitivity
.
writeResults
(
format
,
StreamValue
(
ps
,
Some
(
"muStar\n"
)),
inputs
,
dsl
.
data
.
outputs
,
Morris
.
muStar
(
_
,
_
)).
from
(
context
)
Sensitivity
.
writeResults
(
format
,
StreamValue
(
ps
,
Some
(
"sigma\n"
)),
inputs
,
dsl
.
data
.
outputs
,
Morris
.
sigma
(
_
,
_
)).
from
(
context
)
Sensitivity
.
writeResults
(
format
,
dsl
.
data
,
StreamValue
(
ps
,
Some
(
prelude
.
getOrElse
(
""
)
+
"mu\n"
)),
inputs
,
dsl
.
data
.
outputs
,
Morris
.
mu
(
_
,
_
)).
from
(
context
)
Sensitivity
.
writeResults
(
format
,
dsl
.
data
,
StreamValue
(
ps
,
Some
(
"muStar\n"
)),
inputs
,
dsl
.
data
.
outputs
,
Morris
.
muStar
(
_
,
_
)).
from
(
context
)
Sensitivity
.
writeResults
(
format
,
dsl
.
data
,
StreamValue
(
ps
,
Some
(
"sigma\n"
)),
inputs
,
dsl
.
data
.
outputs
,
Morris
.
sigma
(
_
,
_
)).
from
(
context
)
}
context
}
...
...
openmole/plugins/org.openmole.plugin.method.sensitivity/src/main/scala/org/openmole/plugin/method/sensitivity/SaltelliHook.scala
View file @
9a6e9aa6
...
...
@@ -5,7 +5,7 @@ import org.openmole.core.dsl.extension._
object
SaltelliHook
{
def
apply
[
F
](
dsl
:
DSLContainer
[
Sensitivity.SaltelliParams
],
output
:
WritableOutput
,
format
:
F
=
CSVOutputFormat
())(
implicit
name
:
sourcecode.Name
,
definitionScope
:
DefinitionScope
,
outputFormat
:
OutputFormat
[
F
])
=
def
apply
[
F
](
dsl
:
DSLContainer
[
Sensitivity.SaltelliParams
],
output
:
WritableOutput
,
format
:
F
=
CSVOutputFormat
())(
implicit
name
:
sourcecode.Name
,
definitionScope
:
DefinitionScope
,
outputFormat
:
OutputFormat
[
F
,
Sensitivity.SaltelliParams
])
=
Hook
(
"SaltelliHook"
)
{
p
⇒
import
p._
import
WritableOutput._
...
...
@@ -14,11 +14,11 @@ object SaltelliHook {
output
match
{
case
FileValue
(
dirFC
)
⇒
Sensitivity
.
writeResults
(
format
,
FileValue
(
dirFC
/
s
"firstOrderIndices${outputFormat.extension}"
),
inputs
,
dsl
.
data
.
outputs
,
Saltelli
.
firstOrder
(
_
,
_
)).
from
(
context
)
Sensitivity
.
writeResults
(
format
,
FileValue
(
dirFC
/
s
"totalOrderIndices${outputFormat.extension}"
),
inputs
,
dsl
.
data
.
outputs
,
Saltelli
.
totalOrder
(
_
,
_
)).
from
(
context
)
Sensitivity
.
writeResults
(
format
,
dsl
.
data
,
FileValue
(
dirFC
/
s
"firstOrderIndices${outputFormat.extension}"
),
inputs
,
dsl
.
data
.
outputs
,
Saltelli
.
firstOrder
(
_
,
_
)).
from
(
context
)
Sensitivity
.
writeResults
(
format
,
dsl
.
data
,
FileValue
(
dirFC
/
s
"totalOrderIndices${outputFormat.extension}"
),
inputs
,
dsl
.
data
.
outputs
,
Saltelli
.
totalOrder
(
_
,
_
)).
from
(
context
)
case
StreamValue
(
ps
,
prelude
)
⇒
Sensitivity
.
writeResults
(
format
,
StreamValue
(
ps
,
Some
(
prelude
.
getOrElse
(
""
)
+
"first order\n"
)),
inputs
,
dsl
.
data
.
outputs
,
Saltelli
.
firstOrder
(
_
,
_
)).
from
(
context
)
Sensitivity
.
writeResults
(
format
,
StreamValue
(
ps
,
Some
(
"total order\n"
)),
inputs
,
dsl
.
data
.
outputs
,
Saltelli
.
totalOrder
(
_
,
_
)).
from
(
context
)
Sensitivity
.
writeResults
(
format
,
dsl
.
data
,
StreamValue
(
ps
,
Some
(
prelude
.
getOrElse
(
""
)
+
"first order\n"
)),
inputs
,
dsl
.
data
.
outputs
,
Saltelli
.
firstOrder
(
_
,
_
)).
from
(
context
)
Sensitivity
.
writeResults
(
format
,
dsl
.
data
,
StreamValue
(
ps
,
Some
(
"total order\n"
)),
inputs
,
dsl
.
data
.
outputs
,
Saltelli
.
totalOrder
(
_
,
_
)).
from
(
context
)
}
context
...
...
openmole/plugins/org.openmole.plugin.method.sensitivity/src/main/scala/org/openmole/plugin/method/sensitivity/package.scala
View file @
9a6e9aa6
...
...
@@ -53,7 +53,7 @@ package object sensitivity {
}
def
writeResults
[
F
](
format
:
F
,
output
:
WritableOutput
,
inputs
:
Seq
[
Val
[
_
]],
outputs
:
Seq
[
Val
[
_
]],
coefficient
:
(
Val
[
_
],
Val
[
_
])
⇒
Val
[
_
])(
implicit
outputFormat
:
OutputFormat
[
F
])
=
FromContext
{
p
⇒
def
writeResults
[
F
,
D
](
format
:
F
,
method
:
D
,
output
:
WritableOutput
,
inputs
:
Seq
[
Val
[
_
]],
outputs
:
Seq
[
Val
[
_
]],
coefficient
:
(
Val
[
_
],
Val
[
_
])
⇒
Val
[
_
])(
implicit
outputFormat
:
OutputFormat
[
F
,
D
])
=
FromContext
{
p
⇒
import
p._
def
results
=
outputs
.
map
{
o
⇒
...
...
@@ -64,7 +64,7 @@ package object sensitivity {
def
allVals
=
Seq
(
Val
[
String
](
"output"
))
++
inputs
val
data
=
(
results
.
transpose
zip
allVals
).
map
{
case
(
value
,
v
)
=>
Variable
.
unsecure
(
v
.
array
,
value
)
}
outputFormat
.
write
(
format
,
output
,
data
).
from
(
context
)
outputFormat
.
write
(
format
,
output
,
data
,
method
=
method
).
from
(
context
)
}
...
...
@@ -77,7 +77,7 @@ package object sensitivity {
* @param dsl
*/
implicit
class
SaltelliMethodContainer
(
dsl
:
DSLContainer
[
Sensitivity.SaltelliParams
])
extends
DSLContainerHook
(
dsl
)
{
def
hook
[
F
:
OutputFormat
](
output
:
WritableOutput
,
format
:
F
=
CSVOutputFormat
()
)
:
DSLContainer
[
Sensitivity.SaltelliParams
]
=
{
def
hook
[
F
](
output
:
WritableOutput
,
format
:
F
=
CSVOutputFormat
())(
implicit
outputFormat
:
OutputFormat
[
F
,
Sensitivity.SaltelliParams
]
)
:
DSLContainer
[
Sensitivity.SaltelliParams
]
=
{
implicit
val
defScope
=
dsl
.
scope
dsl
hook
SaltelliHook
(
dsl
,
output
,
format
)
}
...
...
@@ -89,7 +89,7 @@ package object sensitivity {
* @param dsl
*/
implicit
class
MorrisMethodContainer
(
dsl
:
DSLContainer
[
Sensitivity.MorrisParams
])
extends
DSLContainerHook
(
dsl
)
{
def
hook
[
F
:
OutputFormat
](
output
:
WritableOutput
,
format
:
F
=
CSVOutputFormat
()
)
:
DSLContainer
[
Sensitivity.MorrisParams
]
=
{
def
hook
[
F
](
output
:
WritableOutput
,
format
:
F
=
CSVOutputFormat
())(
implicit
outputFormat
:
OutputFormat
[
F
,
Sensitivity.MorrisParams
]
)
:
DSLContainer
[
Sensitivity.MorrisParams
]
=
{
implicit
val
defScope
=
dsl
.
scope
dsl
hook
MorrisHook
(
dsl
,
output
,
format
)
}
...
...
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