-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSimulationDataGenerator.java
More file actions
52 lines (48 loc) · 1.48 KB
/
Copy pathSimulationDataGenerator.java
File metadata and controls
52 lines (48 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/** Klasa rozszerzjąca klasę ArrayList
* Służy do generowania losowego ciągu procesów
* W konstruktorze generuje dane wprowadzane do ArrayListy
* Pobiera dane ze statycznych pól klasy Main
*/
import java.util.ArrayList;
import java.util.Collections;
public class SimulationDataGenerator extends ArrayList<Process>
{
public SimulationDataGenerator()
{
super();
RNG rng = new RNG();
int numberOfProcesses = rng.nextBoundedInt(Main.minAmountOfProcesses, Main.maxAmountOfProcesses);
for (int i=0; i<numberOfProcesses; i++)
{
int submitTime = (rng.nextInt(5)%5)*rng.nextInt(Main.maxSubmitTime)/4;
if (rng.nextInt(5)%5 == 0)
{
add(new Process(rng.nextBoundedInt(Main.minProTimeUs, Main.maxProTimeUs), submitTime));
}
else
{
add(new Process(rng.nextBoundedInt(Main.minProTimeSys, Main.maxProTimeSys), submitTime));
}
}
Collections.sort(this);
}
public String toString()
{
String sb = "\nRandom sequence of processes:\n-------------------------\n";
for(Process p : this)
{
sb = sb + p;
}
return sb;
}
public SimulationDataGenerator clone()
{
SimulationDataGenerator temp = new SimulationDataGenerator();
temp.clear();
for (Process p : this)
{
temp.add(p.clone());
}
return temp;
}
}