Commit 5a632892 authored by Loris Croce's avatar Loris Croce
Browse files

StateDynamics

parent 77d109e9
Pipeline #38494 passed with stages
in 4 minutes and 50 seconds
package fr.inrae.agriterix.simulator.dynamics;
import fr.inrae.agriterix.simulator.*;
import java.io.IOException;
import java.util.List;
/**
* Here we can log global state of the simulator at each timestep, i.e. Farmers numbers, global products stocks etc.
*/
public class StateDynamics extends Dynamics {
@Override
public void process(SimulationContext context, List<GeoArea> geoAreas, List<Farmer> farmers, Flow global,
Parameters parameters, TimeUnit timeUnit) throws IOException {
StringBuilder report = new StringBuilder();
report.append("Total farmers : ");
report.append(farmers.size());
logger.log(context.getTimestep(), report.toString());
}
@Override
public void initLogger() {
logger = new DynamicsLogger(this.getClass().getSimpleName(), super.timeStamp);
}
@Override
public void initParameters() {
}
}
......@@ -2,6 +2,7 @@ package fr.inrae.agriterix.simulator;
import fr.inrae.agriterix.simulator.dynamics.FlowDynamics;
import fr.inrae.agriterix.simulator.dynamics.MarketDynamics;
import fr.inrae.agriterix.simulator.dynamics.StateDynamics;
import org.junit.*;
import static org.junit.Assert.*;
......@@ -121,7 +122,6 @@ public class DynamicsTest {
@Test
public void playground() {
}
......
......@@ -145,7 +145,7 @@ public class SimulatorMinimalTest {
// Dynamics
List<Dynamics> dynamics = new ArrayList<>();
dynamics.addAll(Arrays.asList(new PopulationDynamics(), new ProductionDynamics(), new MarketDynamics(),
new FlowDynamics()));
new FlowDynamics(), new StateDynamics()));
Simulator simulator = new Simulator(new Parameters(0, dynamics, "data/in/config/"), farmers);
simulator.serialize("minimal.xml");
directory = simulator.getTimestampDirectory();
......
Markdown is supported
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