Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Agriterix
simulator
Commits
231e73ca
Commit
231e73ca
authored
Jul 07, 2021
by
Dumoulin Nicolas
Browse files
Constructor with list of farms removed from the Simulator
parent
50f80b87
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/main/java/fr/inrae/agriterix/simulator/Simulator.java
View file @
231e73ca
...
...
@@ -49,27 +49,6 @@ public class Simulator {
}
this
.
global
=
createGlobal
();
}
public
Simulator
(
Parameters
parameters
,
List
<
Farm
>
farms
,
List
<
Farmer
>
farmers
)
{
this
.
parameters
=
parameters
;
this
.
geoAreas
=
new
ArrayList
<>();
// FIXME duplicate farm/farmers in constructor
for
(
Farm
farm
:
farms
)
{
for
(
Patch
patch
:
farm
.
getPatches
())
{
if
(!
this
.
geoAreas
.
contains
(
patch
.
getGeoArea
()))
{
this
.
geoAreas
.
add
(
patch
.
getGeoArea
());
}
}
}
this
.
farmers
=
farmers
;
this
.
timestamp
=
java
.
time
.
LocalDateTime
.
now
().
toString
();
this
.
dynamicsList
=
parameters
.
getDynamics
();
this
.
initIgnoredFields
();
for
(
Dynamics
dynamics
:
dynamicsList
)
{
dynamics
.
setTimeStamp
(
timestamp
);
}
this
.
global
=
createGlobal
();
}
// quick & dirty method to create a global flow aimed to be replaced by a parameterized version by the generator.
public
Flow
createGlobal
()
{
...
...
src/test/java/fr/inrae/agriterix/simulator/FarmerTest.java
View file @
231e73ca
...
...
@@ -48,8 +48,7 @@ public class FarmerTest {
}
Farmer
farmer
=
new
Farmer
(
54
,
farm
);
Simulator
simulator
=
new
Simulator
(
new
Parameters
(
0
,
new
ArrayList
<>()),
Collections
.
singletonList
(
farm
),
Collections
.
singletonList
(
farmer
));
Simulator
simulator
=
new
Simulator
(
new
Parameters
(
0
,
new
ArrayList
<>()),
Collections
.
singletonList
(
farmer
));
ByteArrayOutputStream
stream
=
new
ByteArrayOutputStream
();
simulator
.
serializeXML
(
stream
);
Simulator
simulator2
=
Simulator
.
loadSimulator
(
new
ByteArrayInputStream
(
stream
.
toByteArray
()));
...
...
src/test/java/fr/inrae/agriterix/simulator/GeoAreaTest.java
View file @
231e73ca
...
...
@@ -45,7 +45,7 @@ public class GeoAreaTest {
farm
.
addPatch
(
new
Patch
(
g
,
25.3f
,
CulturalPractice
.
S
,
new
Product
(
"Chou"
,
Unit
.
Kg
)));
Farmer
farmer
=
new
Farmer
(
30
,
farm
);
Simulator
simulator
=
new
Simulator
(
new
Parameters
(
0
,
new
ArrayList
<>()),
farms
,
Arrays
.
asList
(
farmer
));
Simulator
simulator
=
new
Simulator
(
new
Parameters
(
0
,
new
ArrayList
<>()),
Arrays
.
asList
(
farmer
));
ByteArrayOutputStream
stream
=
new
ByteArrayOutputStream
();
simulator
.
serializeXML
(
stream
);
Simulator
simulator2
=
Simulator
.
loadSimulator
(
new
ByteArrayInputStream
(
stream
.
toByteArray
()));
...
...
src/test/java/fr/inrae/agriterix/simulator/SimulatorMinimalTest.java
View file @
231e73ca
...
...
@@ -146,7 +146,7 @@ public class SimulatorMinimalTest {
List
<
Dynamics
>
dynamics
=
new
ArrayList
<>();
dynamics
.
addAll
(
Arrays
.
asList
(
new
PopulationDynamics
(),
new
ProductionDynamics
(),
new
MarketDynamics
(),
new
FlowDynamics
()));
Simulator
simulator
=
new
Simulator
(
new
Parameters
(
0
,
dynamics
),
farms
,
farmers
);
Simulator
simulator
=
new
Simulator
(
new
Parameters
(
0
,
dynamics
),
farmers
);
simulator
.
serialize
(
"minimal.xml"
);
directory
=
simulator
.
getTimestampDirectory
();
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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