Skip to content
GitLab
Menu
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
1c79a3ce
Commit
1c79a3ce
authored
Jul 27, 2021
by
Loris Croce
Browse files
update dynamics testing
parent
c9c3f374
Pipeline
#38378
passed with stages
in 4 minutes and 42 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/fr/inrae/agriterix/simulator/dynamics/PopulationDynamics.java
View file @
1c79a3ce
...
...
@@ -15,6 +15,7 @@ import java.util.ArrayList;
import
java.util.List
;
import
java.util.Map
;
@Deprecated
public
class
PopulationDynamics
extends
Dynamics
{
// incoming simulation parameters, may be replaced by complex functions
...
...
src/test/java/fr/inrae/agriterix/simulator/SimulatorTest.java
View file @
1c79a3ce
...
...
@@ -8,6 +8,7 @@ import fr.inrae.agriterix.simulator.dynamics.*;
import
java.io.*
;
import
fr.inrae.agriterix.simulator.dynamics.transmission.TransmissionTendancy
;
import
org.apache.commons.lang3.RandomStringUtils
;
import
org.junit.*
;
...
...
@@ -71,6 +72,7 @@ public class SimulatorTest {
vergerT
.
addTag
(
Tag
.
B
);
List
<
Product
>
products
=
Arrays
.
asList
(
ble
,
mais
,
fourrage
,
legumes
,
verger
,
vergerT
,
legumesT
,
bleT
);
List
<
Product
>
productsL
=
Arrays
.
asList
(
ble
,
mais
,
fourrage
,
legumes
,
verger
);
List
<
Product
>
transformed
=
Arrays
.
asList
(
new
Product
(
"Jus"
,
Unit
.
L
),
new
Product
(
"Bière"
,
Unit
.
L
),
new
Product
(
"Pain"
,
Unit
.
Kg
),
new
Product
(
"Nuggets"
,
Unit
.
Kg
),
new
Product
(
"Soupe"
,
...
...
@@ -117,7 +119,11 @@ public class SimulatorTest {
}
List
<
Dynamics
>
dynamics
=
new
ArrayList
<>();
dynamics
.
add
(
new
PopulationDynamics
());
// dynamics.add(new PopulationDynamics());
dynamics
.
add
(
new
PopulationDynamicsByAgeClass
(
5.31966309
e
-
04
,
3.02391767
e
+
01
,
3.89377418
e
-
01
,
7.46514412
e
+
00
,
4.27098464
e
+
01
,
1.58988450
e
-
01
,
new
TransmissionTendancy
(
0.5
,
0.5
,
3
,
createTransMatrix
(
productsL
))
));
dynamics
.
add
(
new
ProductionDynamics
());
dynamics
.
add
(
new
MarketDynamics
());
dynamics
.
add
(
new
FlowDynamics
());
...
...
@@ -128,6 +134,24 @@ public class SimulatorTest {
directory
=
simulator
.
getTimestampDirectory
();
}
public
static
Map
<
String
,
Map
<
String
,
Double
>>
createTransMatrix
(
List
<
Product
>
products
)
throws
IOException
{
// for test minimal
XStream
xStream
=
new
XStream
();
XStream
.
setupDefaultSecurity
(
xStream
);
xStream
.
allowTypesByRegExp
(
new
String
[]{
".*"
});
Map
<
String
,
Map
<
String
,
Double
>>
transitions
=
new
ConcurrentHashMap
<>();
for
(
int
i
=
0
;
i
<
products
.
size
();
i
++)
{
Map
<
String
,
Double
>
transitionsP
=
new
ConcurrentHashMap
<>();
for
(
int
j
=
0
;
j
<
products
.
size
();
j
++)
{
transitionsP
.
put
(
products
.
get
(
j
).
getLabel
(),
i
==
j
?
0.9
:
0.1
/
(
products
.
size
()
-
1
));
}
transitions
.
put
(
products
.
get
(
i
).
getLabel
(),
transitionsP
);
}
return
transitions
;
}
@After
public
void
tearDown
()
{
}
...
...
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