| Home | OR-Objects | Tutorials | Prev | Next |
In this tutorial you will learn to use the exponential and empirical distributions in OR-Objects to simulate passengers entering an elevator system. For simplicity, some of the applet details will be skipped. If you would like all the details then view the complete source.
DistributionI
_arrivalDist;
DiscreteDistributionI
_origDist;
DiscreteDistributionI _destDist;
.....
public void
initArrivals()
{
int[] floors =
{0,1,2,3,4,5,6,7,8,9,10,11};
double[] origProb =
{2,1,1,1,1,2,1,1,1,1, 1, 1};
double[] destProb =
{2,1,1,1,1,1,1,1,1,2, 1, 1};
_arrivalDist = new ExponentialDistribution(5);
_nextArrival = (int)(CPS
* _arrivalDist.getRandomScaler());
_origDist = new EmpiricalDistribution(floors,
new DenseVector(origProb));
_destDist = new EmpiricalDistribution(floors,
new DenseVector(destProb));
}
public void
checkArrivals(int time)
{
if(time < _nextArrival) return;
_nextArrival = (int)(time + CPS * _arrivalDist.getRandomScaler());
int orig = _origDist.getRandomInteger();
int dest = _destDist.getRandomInteger();
while(dest == orig) dest = _destDist.getRandomInteger();
arrival(new Passenger(orig, dest));
}
For the sake of expediency the assignment algorithm used in this tutorial
is very simplistic. To make it otherwise would require a lot of work that
would not significantly enhance the effectiveness of the tutorial.
![]() |
|
![]() |
Copyright (C) 1997-2000 by DRA Systems all rights reserved.