formatting
This commit is contained in:
parent
ba2fb856fa
commit
2189ba86c4
4 changed files with 66 additions and 63 deletions
|
@ -12,22 +12,24 @@ public class EventList{
|
||||||
|
|
||||||
public void InsertEvent(int type, double TimeOfEvent) {
|
public void InsertEvent(int type, double TimeOfEvent) {
|
||||||
Event dummy, predummy;
|
Event dummy, predummy;
|
||||||
|
predummy = this.list;
|
||||||
|
dummy = this.list.next;
|
||||||
|
|
||||||
Event newEvent = new Event();
|
Event newEvent = new Event();
|
||||||
newEvent.eventType = type;
|
newEvent.eventType = type;
|
||||||
newEvent.eventTime = TimeOfEvent;
|
newEvent.eventTime = TimeOfEvent;
|
||||||
predummy = list;
|
|
||||||
dummy = list.next;
|
while ((dummy.eventTime < newEvent.eventTime) && (dummy != last)) {
|
||||||
while ((dummy.eventTime < newEvent.eventTime) & (dummy != last)){
|
|
||||||
predummy = dummy;
|
predummy = dummy;
|
||||||
dummy = dummy.next;
|
dummy = dummy.next;
|
||||||
}
|
}
|
||||||
|
|
||||||
predummy.next = newEvent;
|
predummy.next = newEvent;
|
||||||
newEvent.next = dummy;
|
newEvent.next = dummy;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Event FetchEvent() {
|
public Event FetchEvent() {
|
||||||
Event dummy;
|
Event dummy = list.next;
|
||||||
dummy = list.next;
|
|
||||||
list.next = dummy.next;
|
list.next = dummy.next;
|
||||||
dummy.next = null;
|
dummy.next = null;
|
||||||
return dummy;
|
return dummy;
|
||||||
|
|
|
@ -7,15 +7,17 @@ public class MainSimulation extends GlobalSimulation{
|
||||||
public static void main(String[] args) throws IOException {
|
public static void main(String[] args) throws IOException {
|
||||||
Event actEvent;
|
Event actEvent;
|
||||||
EventList myEventList = new EventList();
|
EventList myEventList = new EventList();
|
||||||
|
|
||||||
State actState = new State(myEventList);
|
State actState = new State(myEventList);
|
||||||
|
|
||||||
myEventList.InsertEvent(ARRIVAL, 0);
|
myEventList.InsertEvent(ARRIVAL, 0);
|
||||||
myEventList.InsertEvent(MEASURE, 5);
|
myEventList.InsertEvent(MEASURE, 5);
|
||||||
while (time < 50000){
|
while (MainSimulation.time < 50000) {
|
||||||
actEvent = myEventList.FetchEvent();
|
actEvent = myEventList.FetchEvent();
|
||||||
time = actEvent.eventTime;
|
MainSimulation.time = actEvent.eventTime;
|
||||||
actState.TreatEvent(actEvent);
|
actState.TreatEvent(actEvent);
|
||||||
}
|
}
|
||||||
System.out.println("Mean number of customers: " + 1.0*actState.accumulated/actState.noMeasurements);
|
System.out.println("Mean number of customers: " + (double) actState.accumulated / actState.noMeasurements);
|
||||||
System.out.println("Number of measurements done: " + actState.noMeasurements);
|
System.out.println("Number of measurements done: " + actState.noMeasurements);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -8,7 +8,7 @@ class State extends GlobalSimulation{
|
||||||
|
|
||||||
private EventList myEventList;
|
private EventList myEventList;
|
||||||
|
|
||||||
Random slump = new Random();
|
static Random slump = new Random();
|
||||||
|
|
||||||
State(EventList x) {
|
State(EventList x) {
|
||||||
myEventList = x;
|
myEventList = x;
|
||||||
|
@ -18,7 +18,6 @@ class State extends GlobalSimulation{
|
||||||
myEventList.InsertEvent(event, timeOfEvent);
|
myEventList.InsertEvent(event, timeOfEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void TreatEvent(Event x) {
|
public void TreatEvent(Event x) {
|
||||||
switch (x.eventType) {
|
switch (x.eventType) {
|
||||||
case ARRIVAL:
|
case ARRIVAL:
|
||||||
|
|
Loading…
Add table
Reference in a new issue