Commit e9b1ad76 authored by Dumoulin Nicolas's avatar Dumoulin Nicolas
Browse files

Revert "Merge remote-tracking branch 'refs/remotes/origin/master'"

This reverts commit 6eb27f0d
parent 6eb27f0d
Pipeline #37076 canceled with stages
in 1 minute and 58 seconds
<fr.inrae.agriterix.simulator.Product-array>
<fr.inrae.agriterix.simulator.Product>
<label>Blé</label>
<unit>Kg</unit>
<tags/>
<yield>1.0</yield>
</fr.inrae.agriterix.simulator.Product>
<fr.inrae.agriterix.simulator.Product>
<label>Carottes</label>
<unit>Kg</unit>
<tags/>
<yield>1.0</yield>
</fr.inrae.agriterix.simulator.Product>
<fr.inrae.agriterix.simulator.Product>
<label>Raisins</label>
<unit>Kg</unit>
<tags/>
<yield>1.0</yield>
</fr.inrae.agriterix.simulator.Product>
</fr.inrae.agriterix.simulator.Product-array>
\ No newline at end of file
<concurrent-hash-map>
<entry>
<string>Verger</string>
<concurrent-hash-map>
<entry>
<string>Verger</string>
<double>0.2</double>
</entry>
<entry>
<string>Légumes</string>
<double>0.3</double>
</entry>
<entry>
<string>Fourrage</string>
<double>0.3</double>
</entry>
<entry>
<string>Maïs</string>
<double>0.1</double>
</entry>
<entry>
<string>Blé</string>
<double>0.1</double>
</entry>
</concurrent-hash-map>
</entry>
<entry>
<string>Légumes</string>
<concurrent-hash-map>
<entry>
<string>Verger</string>
<double>0.5</double>
</entry>
<entry>
<string>Légumes</string>
<double>0.2</double>
</entry>
<entry>
<string>Fourrage</string>
<double>0.1</double>
</entry>
<entry>
<string>Maïs</string>
<double>0.1</double>
</entry>
<entry>
<string>Blé</string>
<double>0.1</double>
</entry>
</concurrent-hash-map>
</entry>
<entry>
<string>Fourrage</string>
<concurrent-hash-map>
<entry>
<string>Verger</string>
<double>0.3</double>
</entry>
<entry>
<string>Légumes</string>
<double>0.1</double>
</entry>
<entry>
<string>Fourrage</string>
<double>0.2</double>
</entry>
<entry>
<string>Maïs</string>
<double>0.1</double>
</entry>
<entry>
<string>Blé</string>
<double>0.3</double>
</entry>
</concurrent-hash-map>
</entry>
<entry>
<string>Maïs</string>
<concurrent-hash-map>
<entry>
<string>Verger</string>
<double>0.2</double>
</entry>
<entry>
<string>Légumes</string>
<double>0.2</double>
</entry>
<entry>
<string>Fourrage</string>
<double>0.3</double>
</entry>
<entry>
<string>Maïs</string>
<double>0.2</double>
</entry>
<entry>
<string>Blé</string>
<double>0.1</double>
</entry>
</concurrent-hash-map>
</entry>
<entry>
<string>Blé</string>
<concurrent-hash-map>
<entry>
<string>Verger</string>
<double>0.1</double>
</entry>
<entry>
<string>Légumes</string>
<double>0.1</double>
</entry>
<entry>
<string>Fourrage</string>
<double>0.1</double>
</entry>
<entry>
<string>Maïs</string>
<double>0.3</double>
</entry>
<entry>
<string>Blé</string>
<double>0.4</double>
</entry>
</concurrent-hash-map>
</entry>
</concurrent-hash-map>
\ No newline at end of file
......@@ -4,7 +4,7 @@ import java.util.*;
public class Product {
private final String label;
private String label;
private final Unit unit;
//@XStreamImplicit
private List<Tag> tags;
......@@ -45,6 +45,10 @@ public class Product {
return label + " " + unit + " " + tags;
}
public void setLabel(String label) {
this.label = label;
}
public String getLabel() {
return label;
}
......
......@@ -33,7 +33,7 @@ public class PopulationDynamics extends Dynamics {
private Product transitionProduct = new Product("Soja", Unit.Kg);
private Map<Product, Map<Product, Double>> transitionMatrix;
private Map<String, Map<String, Double>> transitionMatrix;
public PopulationDynamics() {
configPath = "config/transitions.xml";
......@@ -55,7 +55,7 @@ public class PopulationDynamics extends Dynamics {
XStream.setupDefaultSecurity(xStream);
xStream.allowTypesByRegExp(new String[]{".*"});
FileInputStream fileInputStream = new FileInputStream(configPath);
transitionMatrix = (Map<Product, Map<Product, Double>>) xStream.fromXML(fileInputStream);
transitionMatrix = (Map<String, Map<String, Double>>) xStream.fromXML(fileInputStream);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
......@@ -154,8 +154,13 @@ public class PopulationDynamics extends Dynamics {
List<Patch> patchesToRemove = new ArrayList<>();
for (Patch patch : newcomer.getFarm().getPatches()) {
if (context.nextDouble() >= PATCH_CHANGE_CHANCE) {
transitionProduct = context.nextMapObjectWithDistributionInKeysBis(transitionMatrix
.get(patch.getProduction().getProduct()));
if (transitionMatrix.get(patch.getProduction()
.getProduct().getLabel()) == null) {
System.out.println(transitionMatrix);
System.out.println(patch.getProduction().getProduct());
}
transitionProduct.setLabel(context.nextMapObjectWithDistributionInKeysBis(transitionMatrix
.get(patch.getProduction().getProduct().getLabel())));
patchesChanged.add(new Patch(patch.getGeoArea(), patch.getSurface(), transitionPractice,
transitionProduct));
patchesToRemove.add(patch);
......@@ -232,8 +237,8 @@ public class PopulationDynamics extends Dynamics {
List<Patch> patchesToRemove = new ArrayList<>();
for (Patch patch : current.getFarm().getPatches()) {
if (context.nextDouble() >= PATCH_CHANGE_CHANCE) {
transitionProduct = context.nextMapObjectWithDistributionInKeysBis(transitionMatrix
.get(patch.getProduction().getProduct()));
transitionProduct.setLabel(context.nextMapObjectWithDistributionInKeysBis(transitionMatrix
.get(patch.getProduction().getProduct().getLabel())));
patchesChanged.add(new Patch(patch.getGeoArea(), patch.getSurface(), transitionPractice,
transitionProduct));
patchesToRemove.add(patch);
......
......@@ -305,4 +305,4 @@ public class SimulatorMinimalTest {
.forEach(File::delete);
}
}
\ No newline at end of file
}
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