Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
vadere
vadere
Commits
3da97584
Commit
3da97584
authored
Jul 10, 2018
by
Benedikt Kleinmeier
Browse files
Merge branch 'develop' of gitlab.lrz.de:vadere/vadere into develop
parents
e52611ce
dbb6b563
Pipeline
#61292
failed with stage
in 21 seconds
Changes
13
Pipelines
1
Show whitespace changes
Inline
Side-by-side
VadereGui/src/org/vadere/gui/postvisualization/model/PostvisualizationModel.java
View file @
3da97584
...
@@ -300,7 +300,7 @@ public class PostvisualizationModel extends SimulationModel<PostvisualizationCon
...
@@ -300,7 +300,7 @@ public class PostvisualizationModel extends SimulationModel<PostvisualizationCon
private
double
getSimTimeInSec
(
final
Step
step
)
{
private
double
getSimTimeInSec
(
final
Step
step
)
{
return
step
.
getSimTimeInSec
()
return
step
.
getSimTimeInSec
()
.
orElse
(
step
.
getStepNumber
()
*
vadere
.
getScenarioStore
().
a
ttributesSimulation
.
getSimTimeStepLength
());
.
orElse
(
step
.
getStepNumber
()
*
vadere
.
getScenarioStore
().
getA
ttributesSimulation
()
.
getSimTimeStepLength
());
}
}
public
synchronized
void
setPotentialFieldContainer
(
final
PotentialFieldContainer
container
)
{
public
synchronized
void
setPotentialFieldContainer
(
final
PotentialFieldContainer
container
)
{
...
...
VadereGui/src/org/vadere/gui/projectview/view/TextView.java
View file @
3da97584
...
@@ -173,7 +173,7 @@ public class TextView extends JPanel implements IJsonView {
...
@@ -173,7 +173,7 @@ public class TextView extends JPanel implements IJsonView {
switch
(
attributeType
)
{
switch
(
attributeType
)
{
case
MODEL:
case
MODEL:
ModelDefinition
modelDefinition
=
JsonConverter
.
deserializeModelDefinition
(
json
);
ModelDefinition
modelDefinition
=
JsonConverter
.
deserializeModelDefinition
(
json
);
currentScenario
.
getScenarioStore
().
m
ainModel
=
modelDefinition
.
getMainModel
();
currentScenario
.
getScenarioStore
().
setM
ainModel
(
modelDefinition
.
getMainModel
()
)
;
currentScenario
.
setAttributesModel
(
modelDefinition
.
getAttributesList
());
currentScenario
.
setAttributesModel
(
modelDefinition
.
getAttributesList
());
break
;
break
;
case
SIMULATION:
case
SIMULATION:
...
@@ -220,7 +220,7 @@ public class TextView extends JPanel implements IJsonView {
...
@@ -220,7 +220,7 @@ public class TextView extends JPanel implements IJsonView {
switch
(
attributeType
)
{
switch
(
attributeType
)
{
case
MODEL:
case
MODEL:
txtrTextfiletextarea
.
setText
(
StateJsonConverter
.
serializeMainModelAttributesModelBundle
(
txtrTextfiletextarea
.
setText
(
StateJsonConverter
.
serializeMainModelAttributesModelBundle
(
scenario
.
getModelAttributes
(),
scenario
.
getScenarioStore
().
m
ainModel
));
scenario
.
getModelAttributes
(),
scenario
.
getScenarioStore
().
getM
ainModel
()
));
break
;
break
;
case
SIMULATION:
case
SIMULATION:
txtrTextfiletextarea
txtrTextfiletextarea
...
...
VadereSimulator/src/org/vadere/simulator/control/Simulation.java
View file @
3da97584
...
@@ -67,7 +67,7 @@ public class Simulation {
...
@@ -67,7 +67,7 @@ public class Simulation {
this
.
name
=
name
;
this
.
name
=
name
;
this
.
mainModel
=
mainModel
;
this
.
mainModel
=
mainModel
;
this
.
scenarioStore
=
scenarioStore
;
this
.
scenarioStore
=
scenarioStore
;
this
.
attributesSimulation
=
scenarioStore
.
a
ttributesSimulation
;
this
.
attributesSimulation
=
scenarioStore
.
getA
ttributesSimulation
()
;
this
.
attributesAgent
=
scenarioStore
.
getTopography
().
getAttributesPedestrian
();
this
.
attributesAgent
=
scenarioStore
.
getTopography
().
getAttributesPedestrian
();
this
.
sourceControllers
=
new
LinkedList
<>();
this
.
sourceControllers
=
new
LinkedList
<>();
this
.
targetControllers
=
new
LinkedList
<>();
this
.
targetControllers
=
new
LinkedList
<>();
...
...
VadereSimulator/src/org/vadere/simulator/entrypoints/ScenarioBuilder.java
View file @
3da97584
...
@@ -61,9 +61,9 @@ public class ScenarioBuilder {
...
@@ -61,9 +61,9 @@ public class ScenarioBuilder {
// TODO: duplicated code
// TODO: duplicated code
if
(
AttributesSimulation
.
class
==
clazz
){
if
(
AttributesSimulation
.
class
==
clazz
){
builder
=
new
AttributesBuilder
<>((
E
)
store
.
a
ttributesSimulation
);
builder
=
new
AttributesBuilder
<>((
E
)
store
.
getA
ttributesSimulation
()
);
builder
.
setField
(
fieldName
,
value
);
builder
.
setField
(
fieldName
,
value
);
store
.
a
ttributesSimulation
=
(
AttributesSimulation
)
builder
.
build
();
store
.
setA
ttributesSimulation
(
(
AttributesSimulation
)
builder
.
build
()
)
;
}
}
else
if
(
AttributesAgent
.
class
==
clazz
){
else
if
(
AttributesAgent
.
class
==
clazz
){
builder
=
new
AttributesBuilder
<>((
E
)
store
.
getTopography
().
getAttributesPedestrian
());
builder
=
new
AttributesBuilder
<>((
E
)
store
.
getTopography
().
getAttributesPedestrian
());
...
@@ -84,8 +84,8 @@ public class ScenarioBuilder {
...
@@ -84,8 +84,8 @@ public class ScenarioBuilder {
else
{
else
{
builder
=
new
AttributesBuilder
<>(
store
.
getAttributes
(
clazz
));
builder
=
new
AttributesBuilder
<>(
store
.
getAttributes
(
clazz
));
builder
.
setField
(
fieldName
,
value
);
builder
.
setField
(
fieldName
,
value
);
store
.
a
ttributes
List
.
remove
If
(
attributes
->
attributes
.
getClass
()
==
clazz
);
store
.
removeA
ttributesIf
(
attributes
->
attributes
.
getClass
()
==
clazz
);
store
.
attributes
List
.
add
(
builder
.
build
());
store
.
a
ddA
ttributes
(
builder
.
build
());
}
}
}
}
...
...
VadereSimulator/src/org/vadere/simulator/models/MainModelBuilder.java
View file @
3da97584
...
@@ -25,7 +25,7 @@ public class MainModelBuilder {
...
@@ -25,7 +25,7 @@ public class MainModelBuilder {
public
void
createModelAndRandom
()
public
void
createModelAndRandom
()
throws
ClassNotFoundException
,
InstantiationException
,
IllegalAccessException
{
throws
ClassNotFoundException
,
InstantiationException
,
IllegalAccessException
{
final
AttributesSimulation
attributesSimulation
=
scenarioStore
.
a
ttributesSimulation
;
final
AttributesSimulation
attributesSimulation
=
scenarioStore
.
getA
ttributesSimulation
()
;
if
(
attributesSimulation
.
isUseRandomSeed
())
{
if
(
attributesSimulation
.
isUseRandomSeed
())
{
random
=
new
Random
(
attributesSimulation
.
getRandomSeed
());
random
=
new
Random
(
attributesSimulation
.
getRandomSeed
());
}
else
{
}
else
{
...
@@ -45,10 +45,10 @@ public class MainModelBuilder {
...
@@ -45,10 +45,10 @@ public class MainModelBuilder {
}
}
private
MainModel
instantiateMainModel
(
Random
random
)
{
private
MainModel
instantiateMainModel
(
Random
random
)
{
String
mainModelName
=
scenarioStore
.
m
ainModel
;
String
mainModelName
=
scenarioStore
.
getM
ainModel
()
;
DynamicClassInstantiator
<
MainModel
>
instantiator
=
new
DynamicClassInstantiator
<>();
DynamicClassInstantiator
<
MainModel
>
instantiator
=
new
DynamicClassInstantiator
<>();
MainModel
mainModel
=
instantiator
.
createObject
(
mainModelName
);
MainModel
mainModel
=
instantiator
.
createObject
(
mainModelName
);
mainModel
.
initialize
(
scenarioStore
.
a
ttributesList
,
scenarioStore
.
getTopography
(),
mainModel
.
initialize
(
scenarioStore
.
getA
ttributesList
()
,
scenarioStore
.
getTopography
(),
scenarioStore
.
getTopography
().
getAttributesPedestrian
(),
random
);
scenarioStore
.
getTopography
().
getAttributesPedestrian
(),
random
);
return
mainModel
;
return
mainModel
;
}
}
...
...
VadereSimulator/src/org/vadere/simulator/projects/Scenario.java
View file @
3da97584
...
@@ -11,6 +11,7 @@ import java.util.List;
...
@@ -11,6 +11,7 @@ import java.util.List;
import
org.apache.log4j.LogManager
;
import
org.apache.log4j.LogManager
;
import
org.apache.log4j.Logger
;
import
org.apache.log4j.Logger
;
import
org.jetbrains.annotations.NotNull
;
import
org.vadere.simulator.projects.dataprocessing.DataProcessingJsonManager
;
import
org.vadere.simulator.projects.dataprocessing.DataProcessingJsonManager
;
import
org.vadere.simulator.projects.io.JsonConverter
;
import
org.vadere.simulator.projects.io.JsonConverter
;
import
org.vadere.state.attributes.Attributes
;
import
org.vadere.state.attributes.Attributes
;
...
@@ -32,24 +33,17 @@ import difflib.DiffUtils;
...
@@ -32,24 +33,17 @@ import difflib.DiffUtils;
public
class
Scenario
{
public
class
Scenario
{
private
static
Logger
logger
=
LogManager
.
getLogger
(
Scenario
.
class
);
private
static
Logger
logger
=
LogManager
.
getLogger
(
Scenario
.
class
);
private
ScenarioStore
scenarioStore
;
private
ScenarioStore
scenarioStore
;
private
DataProcessingJsonManager
dataProcessingJsonManager
;
private
DataProcessingJsonManager
dataProcessingJsonManager
;
private
String
savedStateSerialized
;
private
String
savedStateSerialized
;
private
String
currentStateSerialized
;
private
String
currentStateSerialized
;
public
Scenario
(
final
String
name
)
{
public
Scenario
(
final
String
name
)
{
this
(
name
,
new
ScenarioStore
(
name
));
this
(
new
ScenarioStore
(
name
));
}
public
Scenario
(
final
ScenarioStore
store
)
{
this
(
store
.
name
,
store
);
}
}
public
Scenario
(
final
String
name
,
final
ScenarioStore
store
)
{
public
Scenario
(
@NotNull
final
ScenarioStore
store
)
{
this
.
scenarioStore
=
store
;
this
.
scenarioStore
=
store
;
this
.
dataProcessingJsonManager
=
new
DataProcessingJsonManager
();
this
.
dataProcessingJsonManager
=
new
DataProcessingJsonManager
();
...
@@ -88,7 +82,7 @@ public class Scenario {
...
@@ -88,7 +82,7 @@ public class Scenario {
}
}
public
String
getName
()
{
public
String
getName
()
{
return
scenarioStore
.
n
ame
;
return
scenarioStore
.
getN
ame
()
;
}
}
public
ScenarioStore
getScenarioStore
()
{
public
ScenarioStore
getScenarioStore
()
{
...
@@ -96,7 +90,7 @@ public class Scenario {
...
@@ -96,7 +90,7 @@ public class Scenario {
}
}
public
List
<
Attributes
>
getModelAttributes
()
{
public
List
<
Attributes
>
getModelAttributes
()
{
return
scenarioStore
.
a
ttributesList
;
return
scenarioStore
.
getA
ttributesList
()
;
}
}
public
AttributesAgent
getAttributesPedestrian
()
{
public
AttributesAgent
getAttributesPedestrian
()
{
...
@@ -104,26 +98,26 @@ public class Scenario {
...
@@ -104,26 +98,26 @@ public class Scenario {
}
}
public
AttributesSimulation
getAttributesSimulation
()
{
public
AttributesSimulation
getAttributesSimulation
()
{
return
scenarioStore
.
a
ttributesSimulation
;
return
scenarioStore
.
getA
ttributesSimulation
()
;
}
}
public
Topography
getTopography
()
{
public
Topography
getTopography
()
{
return
scenarioStore
.
getTopography
();
return
scenarioStore
.
getTopography
();
}
}
public
void
setName
(
String
name
)
{
public
void
setName
(
@NotNull
final
String
name
)
{
this
.
scenarioStore
.
name
=
name
;
this
.
scenarioStore
.
setName
(
name
)
;
}
}
public
void
setAttributesModel
(
List
<
Attributes
>
attributesList
)
{
public
void
setAttributesModel
(
@NotNull
final
List
<
Attributes
>
attributesList
)
{
scenarioStore
.
a
ttributesList
=
attributesList
;
scenarioStore
.
setA
ttributesList
(
attributesList
)
;
}
}
public
void
setAttributesSimulation
(
AttributesSimulation
attributesSimulation
)
{
public
void
setAttributesSimulation
(
@NotNull
final
AttributesSimulation
attributesSimulation
)
{
this
.
scenarioStore
.
a
ttributesSimulation
=
attributesSimulation
;
this
.
scenarioStore
.
setA
ttributesSimulation
(
attributesSimulation
)
;
}
}
public
void
setTopography
(
final
Topography
topography
)
{
public
void
setTopography
(
@NotNull
final
Topography
topography
)
{
scenarioStore
.
setTopography
(
topography
);
scenarioStore
.
setTopography
(
topography
);
}
}
...
@@ -142,7 +136,7 @@ public class Scenario {
...
@@ -142,7 +136,7 @@ public class Scenario {
}
}
public
String
getDisplayName
()
{
public
String
getDisplayName
()
{
return
scenarioStore
.
n
ame
+
(
hasUnsavedChanges
()
?
"*"
:
""
);
return
scenarioStore
.
getN
ame
()
+
(
hasUnsavedChanges
()
?
"*"
:
""
);
}
}
public
void
discardChanges
()
{
public
void
discardChanges
()
{
...
@@ -157,16 +151,16 @@ public class Scenario {
...
@@ -157,16 +151,16 @@ public class Scenario {
}
}
public
String
getDescription
()
{
public
String
getDescription
()
{
return
scenarioStore
.
d
escription
;
return
scenarioStore
.
getD
escription
()
;
}
}
public
void
setDescription
(
String
description
)
{
public
void
setDescription
(
String
description
)
{
scenarioStore
.
d
escription
=
description
;
scenarioStore
.
setD
escription
(
description
)
;
}
}
public
String
readyToRunResponse
()
{
// TODO [priority=medium] [task=check] add more conditions
public
String
readyToRunResponse
()
{
// TODO [priority=medium] [task=check] add more conditions
if
(
scenarioStore
.
m
ainModel
==
null
)
{
if
(
scenarioStore
.
getM
ainModel
()
==
null
)
{
return
scenarioStore
.
n
ame
+
": no mainModel is set"
;
return
scenarioStore
.
getN
ame
()
+
": no mainModel is set"
;
}
}
return
null
;
return
null
;
}
}
...
@@ -175,11 +169,11 @@ public class Scenario {
...
@@ -175,11 +169,11 @@ public class Scenario {
return
dataProcessingJsonManager
;
return
dataProcessingJsonManager
;
}
}
public
void
setDataProcessingJsonManager
(
final
DataProcessingJsonManager
manager
)
{
public
void
setDataProcessingJsonManager
(
@NotNull
final
DataProcessingJsonManager
manager
)
{
this
.
dataProcessingJsonManager
=
manager
;
this
.
dataProcessingJsonManager
=
manager
;
}
}
public
void
saveToOutputPath
(
final
Path
outputPath
)
{
public
void
saveToOutputPath
(
@NotNull
final
Path
outputPath
)
{
try
(
PrintWriter
out
=
new
PrintWriter
(
Paths
.
get
(
outputPath
.
toString
(),
getName
()
+
IOUtils
.
SCENARIO_FILE_EXTENSION
).
toString
()))
{
try
(
PrintWriter
out
=
new
PrintWriter
(
Paths
.
get
(
outputPath
.
toString
(),
getName
()
+
IOUtils
.
SCENARIO_FILE_EXTENSION
).
toString
()))
{
out
.
println
(
JsonConverter
.
serializeScenarioRunManager
(
this
,
true
));
out
.
println
(
JsonConverter
.
serializeScenarioRunManager
(
this
,
true
));
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
...
...
VadereSimulator/src/org/vadere/simulator/projects/ScenarioRun.java
View file @
3da97584
...
@@ -84,7 +84,7 @@ public class ScenarioRun implements Runnable {
...
@@ -84,7 +84,7 @@ public class ScenarioRun implements Runnable {
final
Random
random
=
modelBuilder
.
getRandom
();
final
Random
random
=
modelBuilder
.
getRandom
();
// prepare processors and simulation data writer
// prepare processors and simulation data writer
if
(
scenarioStore
.
a
ttributesSimulation
.
isWriteSimulationData
())
{
if
(
scenarioStore
.
getA
ttributesSimulation
()
.
isWriteSimulationData
())
{
processorManager
=
dataProcessingJsonManager
.
createProcessorManager
(
mainModel
);
processorManager
=
dataProcessingJsonManager
.
createProcessorManager
(
mainModel
);
}
}
...
@@ -97,7 +97,7 @@ public class ScenarioRun implements Runnable {
...
@@ -97,7 +97,7 @@ public class ScenarioRun implements Runnable {
sealAllAttributes
();
sealAllAttributes
();
// Run simulation main loop from start time = 0 seconds
// Run simulation main loop from start time = 0 seconds
simulation
=
new
Simulation
(
mainModel
,
0
,
scenarioStore
.
n
ame
,
scenarioStore
,
passiveCallbacks
,
random
,
processorManager
);
simulation
=
new
Simulation
(
mainModel
,
0
,
scenarioStore
.
getN
ame
()
,
scenarioStore
,
passiveCallbacks
,
random
,
processorManager
);
}
}
simulation
.
run
();
simulation
.
run
();
...
@@ -165,8 +165,8 @@ public class ScenarioRun implements Runnable {
...
@@ -165,8 +165,8 @@ public class ScenarioRun implements Runnable {
}
}
public
String
readyToRunResponse
()
{
// TODO [priority=medium] [task=check] add more conditions
public
String
readyToRunResponse
()
{
// TODO [priority=medium] [task=check] add more conditions
if
(
scenarioStore
.
m
ainModel
==
null
)
{
if
(
scenarioStore
.
getM
ainModel
()
==
null
)
{
return
scenarioStore
.
n
ame
+
": no mainModel is set"
;
return
scenarioStore
.
getN
ame
()
+
": no mainModel is set"
;
}
}
return
null
;
return
null
;
}
}
...
...
VadereSimulator/src/org/vadere/simulator/projects/ScenarioStore.java
View file @
3da97584
...
@@ -3,6 +3,7 @@ package org.vadere.simulator.projects;
...
@@ -3,6 +3,7 @@ package org.vadere.simulator.projects;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
java.util.function.Predicate
;
import
org.apache.commons.codec.digest.DigestUtils
;
import
org.apache.commons.codec.digest.DigestUtils
;
import
org.apache.log4j.LogManager
;
import
org.apache.log4j.LogManager
;
...
@@ -28,11 +29,11 @@ import com.fasterxml.jackson.core.JsonProcessingException;
...
@@ -28,11 +29,11 @@ import com.fasterxml.jackson.core.JsonProcessingException;
public
class
ScenarioStore
{
public
class
ScenarioStore
{
private
static
Logger
logger
=
LogManager
.
getLogger
(
ScenarioStore
.
class
);
private
static
Logger
logger
=
LogManager
.
getLogger
(
ScenarioStore
.
class
);
p
ublic
String
name
;
p
rivate
String
name
;
p
ublic
String
description
;
p
rivate
String
description
;
p
ublic
String
mainModel
;
p
rivate
String
mainModel
;
p
ublic
List
<
Attributes
>
attributesList
;
p
rivate
List
<
Attributes
>
attributesList
;
p
ublic
AttributesSimulation
attributesSimulation
;
p
rivate
AttributesSimulation
attributesSimulation
;
private
Topography
topography
;
private
Topography
topography
;
public
ScenarioStore
(
final
String
name
,
final
String
description
,
final
String
mainModel
,
final
List
<
Attributes
>
attributesModel
,
public
ScenarioStore
(
final
String
name
,
final
String
description
,
final
String
mainModel
,
final
List
<
Attributes
>
attributesModel
,
...
@@ -85,4 +86,52 @@ public class ScenarioStore {
...
@@ -85,4 +86,52 @@ public class ScenarioStore {
public
<
T
extends
Attributes
>
T
getAttributes
(
@NotNull
final
Class
<
T
>
clazz
)
{
public
<
T
extends
Attributes
>
T
getAttributes
(
@NotNull
final
Class
<
T
>
clazz
)
{
return
FindByClass
.
findSingleObjectOfClass
(
attributesList
,
clazz
);
return
FindByClass
.
findSingleObjectOfClass
(
attributesList
,
clazz
);
}
}
public
void
setAttributesList
(
final
List
<
Attributes
>
attributesList
)
{
this
.
attributesList
=
attributesList
;
}
public
void
setAttributesSimulation
(
final
AttributesSimulation
attributesSimulation
)
{
this
.
attributesSimulation
=
attributesSimulation
;
}
public
void
removeAttributesIf
(
@NotNull
final
Predicate
<
Attributes
>
predicate
)
{
attributesList
.
removeIf
(
predicate
);
}
public
void
addAttributes
(
@NotNull
final
Attributes
attributes
)
{
attributesList
.
add
(
attributes
);
}
public
void
setDescription
(
final
String
description
)
{
this
.
description
=
description
;
}
public
void
setMainModel
(
final
String
mainModel
)
{
this
.
mainModel
=
mainModel
;
}
public
void
setName
(
final
String
name
)
{
this
.
name
=
name
;
}
public
AttributesSimulation
getAttributesSimulation
()
{
return
attributesSimulation
;
}
public
List
<
Attributes
>
getAttributesList
()
{
return
attributesList
;
}
public
String
getDescription
()
{
return
description
;
}
public
String
getMainModel
()
{
return
mainModel
;
}
public
String
getName
()
{
return
name
;
}
}
}
VadereSimulator/src/org/vadere/simulator/projects/io/JsonConverter.java
View file @
3da97584
...
@@ -87,8 +87,8 @@ public class JsonConverter {
...
@@ -87,8 +87,8 @@ public class JsonConverter {
}
}
private
static
void
serializeMeta
(
ObjectNode
node
,
boolean
commitHashIncluded
,
ScenarioStore
scenarioStore
)
{
private
static
void
serializeMeta
(
ObjectNode
node
,
boolean
commitHashIncluded
,
ScenarioStore
scenarioStore
)
{
node
.
put
(
"name"
,
scenarioStore
.
n
ame
);
node
.
put
(
"name"
,
scenarioStore
.
getN
ame
()
);
node
.
put
(
"description"
,
scenarioStore
.
d
escription
);
node
.
put
(
"description"
,
scenarioStore
.
getD
escription
()
);
node
.
put
(
"release"
,
HashGenerator
.
releaseNumber
());
node
.
put
(
"release"
,
HashGenerator
.
releaseNumber
());
if
(
commitHashIncluded
)
if
(
commitHashIncluded
)
node
.
put
(
"commithash"
,
HashGenerator
.
commitHash
());
node
.
put
(
"commithash"
,
HashGenerator
.
commitHash
());
...
@@ -97,14 +97,14 @@ public class JsonConverter {
...
@@ -97,14 +97,14 @@ public class JsonConverter {
private
static
ObjectNode
serializeVadereNode
(
ScenarioStore
scenarioStore
)
{
private
static
ObjectNode
serializeVadereNode
(
ScenarioStore
scenarioStore
)
{
ObjectNode
vadereNode
=
StateJsonConverter
.
createObjectNode
();
ObjectNode
vadereNode
=
StateJsonConverter
.
createObjectNode
();
vadereNode
.
put
(
StateJsonConverter
.
MAIN_MODEL_KEY
,
scenarioStore
.
m
ainModel
);
vadereNode
.
put
(
StateJsonConverter
.
MAIN_MODEL_KEY
,
scenarioStore
.
getM
ainModel
()
);
// vadere > attributesModel
// vadere > attributesModel
ObjectNode
attributesModelNode
=
StateJsonConverter
.
serializeAttributesModelToNode
(
scenarioStore
.
a
ttributesList
);
ObjectNode
attributesModelNode
=
StateJsonConverter
.
serializeAttributesModelToNode
(
scenarioStore
.
getA
ttributesList
()
);
vadereNode
.
set
(
"attributesModel"
,
attributesModelNode
);
vadereNode
.
set
(
"attributesModel"
,
attributesModelNode
);
// vadere > attributesSimulation
// vadere > attributesSimulation
vadereNode
.
set
(
"attributesSimulation"
,
StateJsonConverter
.
convertValue
(
scenarioStore
.
a
ttributesSimulation
,
JsonNode
.
class
));
vadereNode
.
set
(
"attributesSimulation"
,
StateJsonConverter
.
convertValue
(
scenarioStore
.
getA
ttributesSimulation
()
,
JsonNode
.
class
));
// vadere > topography
// vadere > topography
ObjectNode
topographyNode
=
StateJsonConverter
.
serializeTopographyToNode
(
scenarioStore
.
getTopography
());
ObjectNode
topographyNode
=
StateJsonConverter
.
serializeTopographyToNode
(
scenarioStore
.
getTopography
());
...
@@ -119,10 +119,10 @@ public class JsonConverter {
...
@@ -119,10 +119,10 @@ public class JsonConverter {
}
}
public
static
ScenarioStore
cloneScenarioStore
(
ScenarioStore
scenarioStore
)
throws
IOException
{
public
static
ScenarioStore
cloneScenarioStore
(
ScenarioStore
scenarioStore
)
throws
IOException
{
JsonNode
attributesSimulationNode
=
StateJsonConverter
.
convertValue
(
scenarioStore
.
a
ttributesSimulation
,
JsonNode
.
class
);
JsonNode
attributesSimulationNode
=
StateJsonConverter
.
convertValue
(
scenarioStore
.
getA
ttributesSimulation
()
,
JsonNode
.
class
);
ObjectNode
attributesModelNode
=
StateJsonConverter
.
serializeAttributesModelToNode
(
scenarioStore
.
a
ttributesList
);
ObjectNode
attributesModelNode
=
StateJsonConverter
.
serializeAttributesModelToNode
(
scenarioStore
.
getA
ttributesList
()
);
ObjectNode
topographyNode
=
StateJsonConverter
.
serializeTopographyToNode
(
scenarioStore
.
getTopography
());
ObjectNode
topographyNode
=
StateJsonConverter
.
serializeTopographyToNode
(
scenarioStore
.
getTopography
());
return
new
ScenarioStore
(
scenarioStore
.
n
ame
,
scenarioStore
.
d
escription
,
scenarioStore
.
m
ainModel
,
return
new
ScenarioStore
(
scenarioStore
.
getN
ame
()
,
scenarioStore
.
getD
escription
()
,
scenarioStore
.
getM
ainModel
()
,
StateJsonConverter
.
deserializeAttributesListFromNode
(
attributesModelNode
),
StateJsonConverter
.
deserializeAttributesListFromNode
(
attributesModelNode
),
StateJsonConverter
.
deserializeAttributesSimulationFromNode
(
attributesSimulationNode
),
StateJsonConverter
.
deserializeAttributesSimulationFromNode
(
attributesSimulationNode
),
StateJsonConverter
.
deserializeTopographyFromNode
(
topographyNode
));
StateJsonConverter
.
deserializeTopographyFromNode
(
topographyNode
));
...
...
VadereUtils/resources/BitonicSort.cl
0 → 100644
View file @
3da97584
/*
*
Copyright
1993-2010
NVIDIA
Corporation.
All
rights
reserved.
*
*
Please
refer
to
the
NVIDIA
end
user
license
agreement
(
EULA
)
associated
*
with
this
source
code
for
terms
and
conditions
that
govern
your
use
of
*
this
software.
Any
use,
reproduction,
disclosure,
or
distribution
of
*
this
software
and
related
documentation
outside
the
terms
of
the
EULA
*
is
strictly
prohibited.
*
*/
#
define
LOCAL_SIZE_LIMIT
16U
inline
void
ComparatorPrivate
(
uint
*keyA,
uint
*valA,
uint
*keyB,
uint
*valB,
uint
dir
)
{
if
(
(
*keyA
>
*keyB
)
==
dir
)
{
uint
t
;
t
=
*keyA
; *keyA = *keyB; *keyB = t;
t
=
*valA
; *valA = *valB; *valB = t;
}
}
inline
void
ComparatorLocal
(
__local
uint
*keyA,
__local
uint
*valA,
__local
uint
*keyB,
__local
uint
*valB,
uint
dir
)
{
if
(
(
*keyA
>
*keyB
)
==
dir
)
{
uint
t
;
t
=
*keyA
; *keyA = *keyB; *keyB = t;
t
=
*valA
; *valA = *valB; *valB = t;
}
}
////////////////////////////////////////////////////////////////////////////////
//
Monolithic
bitonic
sort
kernel
for
short
arrays
fitting
into
local
memory
////////////////////////////////////////////////////////////////////////////////
__kernel
void
bitonicSortLocal
(
__global
uint
*d_DstKey,
__global
uint
*d_DstVal,
__global
uint
*d_SrcKey,
__global
uint
*d_SrcVal,
uint
arrayLength,
uint
dir
)
{
__local
uint
l_key[LOCAL_SIZE_LIMIT]
;
__local
uint
l_val[LOCAL_SIZE_LIMIT]
;
//Offset
to
the
beginning
of
subbatch
and
load
data
d_SrcKey
+=
get_group_id
(
0
)
*
LOCAL_SIZE_LIMIT
+
get_local_id
(
0
)
;
d_SrcVal
+=
get_group_id
(
0
)
*
LOCAL_SIZE_LIMIT
+
get_local_id
(
0
)
;
d_DstKey
+=
get_group_id
(
0
)
*
LOCAL_SIZE_LIMIT
+
get_local_id
(
0
)
;
d_DstVal
+=
get_group_id
(
0
)
*
LOCAL_SIZE_LIMIT
+
get_local_id
(
0
)
;
l_key[get_local_id
(
0
)
+
0]
=
d_SrcKey[
0]
;
l_val[get_local_id
(
0
)
+
0]
=
d_SrcVal[
0]
;
l_key[get_local_id
(
0
)
+
(
LOCAL_SIZE_LIMIT
/
2
)
]
=
d_SrcKey[
(
LOCAL_SIZE_LIMIT
/
2
)
]
;
l_val[get_local_id
(
0
)
+
(
LOCAL_SIZE_LIMIT
/
2
)
]
=
d_SrcVal[
(
LOCAL_SIZE_LIMIT
/
2
)
]
;
for
(
uint
size
=
2
; size < arrayLength; size <<= 1){
//Bitonic
merge