Commit 1c79a3ce authored by Loris Croce's avatar Loris Croce
Browse files

update dynamics testing

parent c9c3f374
Pipeline #38378 passed with stages
in 4 minutes and 42 seconds
...@@ -15,6 +15,7 @@ import java.util.ArrayList; ...@@ -15,6 +15,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@Deprecated
public class PopulationDynamics extends Dynamics { public class PopulationDynamics extends Dynamics {
// incoming simulation parameters, may be replaced by complex functions // incoming simulation parameters, may be replaced by complex functions
......
...@@ -8,6 +8,7 @@ import fr.inrae.agriterix.simulator.dynamics.*; ...@@ -8,6 +8,7 @@ import fr.inrae.agriterix.simulator.dynamics.*;
import java.io.*; import java.io.*;
import fr.inrae.agriterix.simulator.dynamics.transmission.TransmissionTendancy;
import org.apache.commons.lang3.RandomStringUtils; import org.apache.commons.lang3.RandomStringUtils;
import org.junit.*; import org.junit.*;
...@@ -71,6 +72,7 @@ public class SimulatorTest { ...@@ -71,6 +72,7 @@ public class SimulatorTest {
vergerT.addTag(Tag.B); vergerT.addTag(Tag.B);
List<Product> products = Arrays.asList(ble, mais, fourrage, legumes, verger, vergerT, legumesT, bleT); 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), 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", new Product("Pain", Unit.Kg), new Product("Nuggets", Unit.Kg), new Product("Soupe",
...@@ -117,7 +119,11 @@ public class SimulatorTest { ...@@ -117,7 +119,11 @@ public class SimulatorTest {
} }
List<Dynamics> dynamics = new ArrayList<>(); List<Dynamics> dynamics = new ArrayList<>();
dynamics.add(new PopulationDynamics()); // dynamics.add(new PopulationDynamics());
dynamics.add(new PopulationDynamicsByAgeClass(
5.31966309e-04, 3.02391767e+01, 3.89377418e-01, 7.46514412e+00, 4.27098464e+01, 1.58988450e-01,
new TransmissionTendancy(0.5, 0.5, 3, createTransMatrix(productsL))
));
dynamics.add(new ProductionDynamics()); dynamics.add(new ProductionDynamics());
dynamics.add(new MarketDynamics()); dynamics.add(new MarketDynamics());
dynamics.add(new FlowDynamics()); dynamics.add(new FlowDynamics());
...@@ -128,6 +134,24 @@ public class SimulatorTest { ...@@ -128,6 +134,24 @@ public class SimulatorTest {
directory = simulator.getTimestampDirectory(); 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 @After
public void tearDown() { public void tearDown() {
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment