did some improvements
This commit is contained in:
parent
59916d04e7
commit
45baf656b8
@ -11,7 +11,7 @@ import analysis.NetworkDumper;
|
||||
import node.Node;
|
||||
|
||||
public class RandomGenerator {
|
||||
public static int initNodeCount = 100;
|
||||
public static int initNodeCount = 250;
|
||||
public static double initBirthRate = 0.50;
|
||||
public static double initDeathRate = 0.20;
|
||||
public static int initRounds = 13;
|
||||
@ -25,6 +25,9 @@ public class RandomGenerator {
|
||||
* @throws IOException
|
||||
*/
|
||||
public static void main(String[] args) throws IOException {
|
||||
double rate;
|
||||
int add = 0;
|
||||
int remove = 0;
|
||||
|
||||
System.setProperty("java.util.logging.config.file",
|
||||
"logging.properties");
|
||||
@ -49,6 +52,7 @@ public class RandomGenerator {
|
||||
}
|
||||
|
||||
switch (cmd) {
|
||||
|
||||
case "dump":
|
||||
nodes.get(0).gatherInformationOfNetwork();
|
||||
try {
|
||||
@ -89,9 +93,6 @@ public class RandomGenerator {
|
||||
System.out.println("Nodecount: " + nodes.size());
|
||||
break;
|
||||
case "simulate":
|
||||
double rate;
|
||||
int add = 0;
|
||||
int remove = 0;
|
||||
if (splitted.length > 1) {
|
||||
rate = Double.valueOf(splitted[2]);
|
||||
for (int i = 0; i < count; i++) {
|
||||
@ -141,6 +142,39 @@ public class RandomGenerator {
|
||||
}
|
||||
System.out.println("Nodecount: " + nodes.size());
|
||||
break;
|
||||
case "prefsim":
|
||||
if (splitted.length > 2) {
|
||||
rate = Double.valueOf(splitted[2]);
|
||||
int neighborcount = Integer.valueOf(splitted[3]);
|
||||
for (int i = 0; i < count; i++) {
|
||||
System.out.println("Round: " + i);
|
||||
System.out.println("NodeCount: " + nodes.size());
|
||||
if (gen.nextDouble() < rate) {
|
||||
add(1);
|
||||
add++;
|
||||
}
|
||||
if (gen.nextDouble() < rate) {
|
||||
removeWithNeighborCount(1, neighborcount);
|
||||
remove++;
|
||||
}
|
||||
if (i % (count / 4) == 0) {
|
||||
nodes.get(0).gatherInformationOfNetwork();
|
||||
try {
|
||||
System.out.println(i);
|
||||
Thread.sleep(500);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
NetworkDumper nd = new NetworkDumper(nodes.get(0));
|
||||
nd.write(nd.networkToDot(nodes.get(0).getNetwork()));
|
||||
}
|
||||
}
|
||||
}
|
||||
System.out.println("Nodecount: " + nodes.size());
|
||||
System.out.println("We added " + add + " Nodes");
|
||||
System.out.println("We removed " + remove + " Nodes");
|
||||
break;
|
||||
default:
|
||||
System.out.println("Unknown command.");
|
||||
break;
|
||||
@ -153,14 +187,14 @@ public class RandomGenerator {
|
||||
if (nodes.size() == 0) {
|
||||
Node newNode = new Node();
|
||||
nodes.add(newNode);
|
||||
neighborCount.add(0);
|
||||
neighborCount.add(1);
|
||||
} else {
|
||||
int index = gen.nextInt(nodes.size());
|
||||
Node newNode = nodes.get(index).spawn();
|
||||
neighborCount.set(index,
|
||||
neighborCount.get(index).intValue() + 1);
|
||||
nodes.add(newNode);
|
||||
neighborCount.add(0);
|
||||
neighborCount.add(1);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user