EventManager interface.
- A Calendar implementation in
delegate-src/src/org/mitre/sim/event/calendar/CalendarImpl.javathat's based on the original paper but has discouraging performance related comments. - A HashSet implementation in
delegate-src/src/org/mitre/sim/event/hashSet/HashSetImpl.javathat uses Java's built in hashset.The important part (dequeueing) is something like this (GPLv2 licensed, © MITRE corporation):
Suffice it to say that evaluating every single event at every single step of the simulation will not get you good performance.Event result = null; double smallestTime = Double.POSITIVE_INFINITY; for (Iterator i = db.iterator(); i.hasNext(); ) { Event nextEvent = (Event)i.next(); if (nextEvent.getNextTime() < smallestTime) { smallestTime = nextEvent.getNextTime(); result = nextEvent; } } db.remove(result); - A TreeMap based implementation in
delegate-src/src/org/mitre/sim/event/treeMap/TreeMapImpl.java. As you might have guessed, this uses the java.util.TreeMap<K,V>. I'm not sure what kind of tree it uses internally, but if it's not a binary heap, performance should be close.
I also just realised that I apparently switch from Dutch to English and back every a few posts, so eh, sorry about that. I honestly didn't notice.
Geen opmerkingen:
Een reactie posten