Hi,
I've uncovered a small bug in the nl.tudelft.simulation.dsol.formalisms.Resource class. When you call the requestCapacity method, a smaller capacity request can sneak in front of already waiting requests. For example, resource 'a' has a capacity of 2, and a claimed capacity of 1 and a waiting request of 2, then a new (later arriving) request with the size of 1 will be assigned the remaining capacity. I'm not sure this is a 'feature' or a bug, but it can lead to some confusing behaviour. The fix is to remove these lines:
210 if ((this.claimedCapacity + amount) <= this.capacity)
211 {
212 this.alterClaimedCapacity(amount);
213 this.simulator.scheduleEvent(0, this, requestor,
214 "receiveRequestedResource", new Object[] {
215 new Double(amount), this });
216 } else
...And to add, a call to releaseCapacity(0) instead:
this.releaseCapacity(0.0d);
...Which will assign the resources correctly. I've written a 'newer' version, which also allows cancellations, but will break binary compatibility. It's attached to the report.
Regards Herman van Hovell
Resource