diff --git a/.gitignore b/.gitignore
index 7a3900f72c4434fd3e8902456ef3fa789c378992..9d6abaaf603c3fd934b149212cf1882c800f6950 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
.settings
.classpath
-.project
\ No newline at end of file
+.project
+/target/
diff --git a/.project b/.project
deleted file mode 100644
index 3cbcb0fbe72c973eddc7a77633906465a38f5c86..0000000000000000000000000000000000000000
--- a/.project
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
- Mesure_RI
-
-
-
-
-
- org.eclipse.jdt.core.javabuilder
-
-
-
-
- org.eclipse.m2e.core.maven2Builder
-
-
-
-
-
- org.eclipse.jdt.core.javanature
- org.eclipse.m2e.core.maven2Nature
-
-
diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs
deleted file mode 100644
index f9fe34593fcd3624a964478aeb438b0d44fe7237..0000000000000000000000000000000000000000
--- a/.settings/org.eclipse.core.resources.prefs
+++ /dev/null
@@ -1,4 +0,0 @@
-eclipse.preferences.version=1
-encoding//src/main/java=UTF-8
-encoding//src/test/java=UTF-8
-encoding/=UTF-8
diff --git a/.settings/org.eclipse.m2e.core.prefs b/.settings/org.eclipse.m2e.core.prefs
deleted file mode 100644
index f897a7f1cb2389f85fe6381425d29f0a9866fb65..0000000000000000000000000000000000000000
--- a/.settings/org.eclipse.m2e.core.prefs
+++ /dev/null
@@ -1,4 +0,0 @@
-activeProfiles=
-eclipse.preferences.version=1
-resolveWorkspaceProjects=true
-version=1
diff --git a/README.md b/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..19fb813f58df424831a777d96177261c0f9c4b99
--- /dev/null
+++ b/README.md
@@ -0,0 +1,2 @@
+# Mesure_RI
+
diff --git a/src/main/java/Propagation/Epidemie.java b/src/main/java/Propagation/Epidemie.java
index 214cbf15cd656ecf31c1458cf12f8bcdb7373a89..48fb1d17de5abaeecb97781853532c44c4046bf9 100644
--- a/src/main/java/Propagation/Epidemie.java
+++ b/src/main/java/Propagation/Epidemie.java
@@ -1,10 +1,19 @@
package Propagation;
+<<<<<<< HEAD
+import java.io.BufferedWriter;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Random;
+=======
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.stream.Collectors;
+>>>>>>> master
import org.graphstream.graph.Edge;
import org.graphstream.graph.Graph;
import org.graphstream.graph.Node;
@@ -14,6 +23,17 @@ public class Epidemie {
final int NOTHING = 0;
final int ALEA = 1;
final int SELECT = 2;
+<<<<<<< HEAD
+ final double TRANSMISSION_PROBABILITY = 0.142857143;
+ final double RECOVERY_PROBABILITY = 0.071428571;
+ final double IMMUNE_PROBABILITY = 0.5;
+
+ private static Graph g;
+ private int immune;
+ private String of;
+ private List contamine;
+ private List immunise;
+=======
final double TRANSMISSION_PROBABILITY = 1/7;
final double RECOVERY_PROBABILITY = 1/14;
@@ -21,11 +41,30 @@ public class Epidemie {
@SuppressWarnings("unused")
private int immune;
private List contamine;
+>>>>>>> master
public Epidemie(Graph graph, int immune) {
g = graph;
+<<<<<<< HEAD
+ if(immune == 0) {
+
+ this.immune = NOTHING;
+ this.of = "src/main/ressources/nothing/cases.csv";
+ } else if(immune == 1) {
+
+ this.immune = ALEA;
+ this.of = "src/main/ressources/alea/cases.csv";
+ } else {
+
+ this.immune = SELECT;
+ this.of = "src/main/ressources/select/cases.csv";
+ }
+
+ contamine = new ArrayList<>();
+ immunise = new ArrayList<>();
+=======
switch(immune) {
case 0 : this.immune = NOTHING;
case 1 : this.immune = ALEA;
@@ -33,14 +72,41 @@ public class Epidemie {
}
contamine = new ArrayList<>();
+>>>>>>> master
}
public void runSimulation(int initialInfectedNodes, int simulationSteps) {
initializeSimulation(initialInfectedNodes);
for (int step = 0; step < simulationSteps; ++step) {
+<<<<<<< HEAD
+
+ int ci = countInfected();
+ System.out.println("Step " + step + ": Infected Count = " + ci);
+
+ try (BufferedWriter writer = new BufferedWriter(new FileWriter(of))) {
+
+ writer.write(step + "," + ci + "\n");
+ } catch (IOException e) {
+
+ e.printStackTrace();
+ }
+
+ updateEpidemicState();
+ }
+
+ System.out.println("Step " + simulationSteps + ": Infected Count = " + countInfected());
+
+ try (BufferedWriter writer = new BufferedWriter(new FileWriter(of))) {
+
+ writer.write(simulationSteps + "," + countInfected() + "\n");
+ } catch (IOException e) {
+
+ e.printStackTrace();
+=======
updateEpidemicState();
System.out.println("Step " + step + ": Infected Count = " + countInfected());
+>>>>>>> master
}
}
@@ -54,8 +120,22 @@ public class Epidemie {
}
for (Node node : g) {
+<<<<<<< HEAD
+
+ if(immune == ALEA) {
+
+ if(!(node.hasAttribute("infected")) && Math.random() < IMMUNE_PROBABILITY) {
+
+ node.setAttribute("immune", true);
+ immunise.add(node);
+ }
+ }
+
+ if(!(node.hasAttribute("infected")) && !(immunise.contains(node))) {
+=======
if(!(node.hasAttribute("infected"))) {
+>>>>>>> master
node.setAttribute("infected", false);
}
@@ -66,23 +146,61 @@ public class Epidemie {
for (Node node : g) {
boolean infected = (boolean) node.getAttribute("infected");
+<<<<<<< HEAD
+ if(immune == NOTHING) {
+
+ if (infected) {
+=======
if (infected) {
+>>>>>>> master
for (Node neighbor : getNeighbours(node)) {
boolean neighborInfected = (boolean) neighbor.getAttribute("infected");
+<<<<<<< HEAD
+ if (!neighborInfected && Math.random() < TRANSMISSION_PROBABILITY) {
+=======
if (!neighborInfected && getRand() < TRANSMISSION_PROBABILITY) {
+>>>>>>> master
neighbor.setAttribute("infected", true);
contamine.add(neighbor);
}
}
+<<<<<<< HEAD
+ if (Math.random() < RECOVERY_PROBABILITY) {
+=======
if (getRand() < RECOVERY_PROBABILITY) {
+>>>>>>> master
node.setAttribute("infected", false);
contamine.remove(node);
}
+<<<<<<< HEAD
+ }
+ } else if (immune == ALEA) {
+
+ if (infected) {
+ for (Node neighbor : getNeighbours(node)) {
+
+ boolean neighborInfected = (boolean) neighbor.getAttribute("infected");
+
+ if (!neighborInfected && !(immunise.contains(neighbor)) && Math.random() < TRANSMISSION_PROBABILITY) {
+
+ neighbor.setAttribute("infected", true);
+ contamine.add(neighbor);
+ }
+ }
+
+ if (Math.random() < RECOVERY_PROBABILITY) {
+
+ node.setAttribute("infected", false);
+ contamine.remove(node);
+ }
+ }
+=======
+>>>>>>> master
}
}
}
@@ -94,7 +212,17 @@ public class Epidemie {
private static List getNeighbours(Node n) {
+<<<<<<< HEAD
+ List le = new ArrayList<>();
+
+ for(Edge e : n) {
+
+ le.add(e);
+ }
+
+=======
List le = n.leavingEdges().collect(Collectors.toList());
+>>>>>>> master
List voisins = new ArrayList<>();
for(Edge e : le) {
@@ -104,6 +232,11 @@ public class Epidemie {
return voisins;
}
+<<<<<<< HEAD
+
+ public static void go(Graph g, int step, int immune) {
+
+=======
public static double getRand() {
@@ -113,6 +246,7 @@ public class Epidemie {
public static void go(Graph g, int step, int immune) {
System.out.println("coucou");
+>>>>>>> master
Epidemie simulation = new Epidemie(g, immune);
simulation.runSimulation(1, step);
}
diff --git a/src/main/java/Propagation/Main.java b/src/main/java/Propagation/Main.java
index 729e14341e002ee6d0594640e337db55289d516a..1d3c0ecec37062bc58e1ce113dae88ecf5e21969 100644
--- a/src/main/java/Propagation/Main.java
+++ b/src/main/java/Propagation/Main.java
@@ -81,7 +81,10 @@ public class Main {
private static void simulEpid() {
+ Epidemie.go(g, 10, 0);
+ System.out.println();
+ Epidemie.go(g, 10, 1);
System.out.println("couco");
Epidemie.go(g, 12, 0);
}
-}
\ No newline at end of file
+}
diff --git a/src/main/ressources/alea/cases.csv b/src/main/ressources/alea/cases.csv
new file mode 100644
index 0000000000000000000000000000000000000000..2ba37dedc3f15168560b0ae5fdf5015740ea5acc
--- /dev/null
+++ b/src/main/ressources/alea/cases.csv
@@ -0,0 +1 @@
+10,202785
diff --git a/src/main/ressources/nothing/cases.csv b/src/main/ressources/nothing/cases.csv
new file mode 100644
index 0000000000000000000000000000000000000000..d4d3279416f1021dc7a82f3cbc8ac2f285bf973b
--- /dev/null
+++ b/src/main/ressources/nothing/cases.csv
@@ -0,0 +1 @@
+10,98832
diff --git a/src/main/ressources/select/cases.csv b/src/main/ressources/select/cases.csv
new file mode 100644
index 0000000000000000000000000000000000000000..8eaf110a3306688c7877add4c379741a46938d33
--- /dev/null
+++ b/src/main/ressources/select/cases.csv
@@ -0,0 +1 @@
+10,1