Skip to content
Snippets Groups Projects
Commit c95c6d88 authored by AxelCarayon's avatar AxelCarayon
Browse files

improved asynchronous mode

parent 744ff50a
No related branches found
No related tags found
No related merge requests found
SUCEPTIBLE,EXPOSED,RECOVERED,INFECTED
9995,4,0,1
9988,9,0,3
9957,32,0,11
9881,90,0,29
9795,132,3,70
9666,197,11,126
9520,245,20,215
9307,336,35,322
9093,369,53,485
8817,445,80,658
8495,537,122,846
8172,597,171,1060
7811,663,237,1289
7405,725,319,1551
6958,821,419,1802
6496,863,536,2105
6028,879,668,2425
5539,940,808,2713
5093,899,983,3025
4676,842,1177,3305
4255,822,1389,3534
3793,875,1604,3728
3383,832,1822,3963
2968,827,2050,4155
2577,805,2301,4317
2186,816,2561,4437
1792,818,2811,4579
1373,804,3091,4732
1036,764,3395,4805
763,653,3670,4914
554,519,3953,4974
393,403,4256,4948
301,282,4565,4852
212,218,4873,4697
135,192,5176,4497
86,145,5454,4315
9994,5,0,1
9980,16,0,4
9953,34,0,13
9867,106,0,27
9753,175,0,72
9592,247,5,156
9401,314,13,272
9184,386,27,403
8928,434,54,584
8643,501,88,768
8305,589,144,962
7943,639,197,1221
7544,706,265,1485
7139,754,360,1747
6739,777,472,2012
6333,812,606,2249
5909,808,721,2562
5487,827,880,2806
5051,851,1057,3041
4601,859,1246,3294
4117,918,1432,3533
3638,925,1661,3776
3239,850,1923,3988
2858,780,2167,4195
2482,770,2423,4325
2146,724,2692,4438
1798,699,2954,4549
1505,625,3221,4649
1246,566,3508,4680
1009,490,3783,4718
775,465,4042,4718
577,432,4342,4649
418,363,4626,4593
298,294,4926,4482
222,217,5169,4392
168,157,5428,4247
113,113,5680,4094
76,102,5925,3897
32,98,6168,3702
12,83,6399,3506
3,50,6602,3345
1,29,6821,3149
0,15,7015,2970
0,8,7184,2808
0,4,7345,2651
0,2,7495,2503
0,0,7648,2352
0,0,7798,2202
0,0,7955,2045
0,0,8087,1913
0,0,8210,1790
0,0,8312,1688
0,0,8421,1579
0,0,8519,1481
0,0,8616,1384
0,0,8698,1302
0,0,8788,1212
0,0,8856,1144
0,0,8931,1069
0,0,8992,1008
0,0,9052,948
0,0,9107,893
0,0,9156,844
0,0,9208,792
0,0,9259,741
0,0,9319,681
0,0,9360,640
0,0,9400,600
0,0,9443,557
0,0,9473,527
0,0,9510,490
0,0,9541,459
0,0,9573,427
0,0,9599,401
0,0,9620,380
0,0,9638,362
0,0,9658,342
0,0,9674,326
0,0,9694,306
0,0,9710,290
0,0,9728,272
0,0,9738,262
0,0,9750,250
0,0,9759,241
0,0,9772,228
0,0,9790,210
0,0,9805,195
0,0,9819,181
0,0,9833,167
0,0,9842,158
0,0,9856,144
0,0,9866,134
0,0,9871,129
0,0,9877,123
0,0,9886,114
0,0,9895,105
0,0,9903,97
0,0,9908,92
0,0,9919,81
0,0,9925,75
0,0,9929,71
0,0,9934,66
0,0,9937,63
0,0,9939,61
0,0,9941,59
0,0,9944,56
0,0,9950,50
0,0,9955,45
0,0,9957,43
0,0,9959,41
0,0,9962,38
0,0,9963,37
0,0,9967,33
0,0,9970,30
0,0,9973,27
0,0,9973,27
0,0,9976,24
0,0,9977,23
0,0,9978,22
0,0,9978,22
0,0,9980,20
0,0,9982,18
0,0,9983,17
0,0,9984,16
0,0,9985,15
0,0,9985,15
0,0,9985,15
0,0,9986,14
0,0,9987,13
0,0,9987,13
0,0,9988,12
0,0,9989,11
0,0,9992,8
0,0,9992,8
0,0,9992,8
0,0,9992,8
0,0,9993,7
0,0,9994,6
0,0,9995,5
0,0,9996,4
0,0,9996,4
0,0,9996,4
0,0,9996,4
0,0,9996,4
0,0,9996,4
0,0,9996,4
0,0,9996,4
0,0,9996,4
0,0,9996,4
0,0,9996,4
0,0,9996,4
0,0,9997,3
0,0,9997,3
0,0,9997,3
0,0,9997,3
0,0,9997,3
0,0,9998,2
0,0,9998,2
0,0,9998,2
0,0,9999,1
0,0,9999,1
0,0,9999,1
0,0,9999,1
0,0,9999,1
0,0,9999,1
0,0,9999,1
0,0,9999,1
0,0,9999,1
0,0,9999,1
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
0,0,10000,0
......@@ -4,15 +4,36 @@ import sma.agents.Agent;
import java.util.Arrays;
import java.util.List;
import java.util.Queue;
import java.util.concurrent.*;
import java.util.function.Function;
import java.util.stream.Collectors;
public class FairAsynchronousScheduler implements Scheduler{
private List<Agent> agents;
private ExecutorService executor = Executors.newSingleThreadExecutor();
private Queue<Agent> queue;
public FairAsynchronousScheduler(Agent[] agents) {
this.agents = Arrays.asList(agents);
this.queue = new ConcurrentLinkedQueue<>(Arrays.stream(agents).toList());
}
public void nextCycle() {
agents.stream().parallel().forEach(a -> a.wakeUp());
List<Future<Agent>> results = queue.parallelStream().map(agent -> executor.submit(() -> {agent.wakeUp(); return agent;})).collect(Collectors.toList());
Function<Future<Agent>,Agent> futureTreatment = futureAgent -> {
try {
return futureAgent.get();
} catch (ExecutionException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
return null;
};
List<Agent> nextQueue = results.parallelStream().map(futureTreatment).collect(Collectors.toList());
queue = new ConcurrentLinkedQueue<>(nextQueue);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment