home *** CD-ROM | disk | FTP | other *** search
Java Source | 1998-02-20 | 1.6 KB | 67 lines |
-
- package examples.network;
-
-
- import simula.*;
- import simula.simset.* ;
- import simula.simset.simulation.*;
- import simula.random.* ;
- /**
- * The process that brings jobs into the system
- * @author Andrea Poltronieri
- * @version 1.0 12 Feb 1998
- */
-
- public class Arrivals extends simula.simset.simulation.Process {
-
-
-
- /**
- * @param _sim The active Simulation
- */
-
- public Arrivals (Simulation _sim) {
- super(_sim);
- }
- /**
- * Executes actions for this object. Called by simulation on activate
- * @see simula.simset.simulation.Simulation
- */
-
-
- public void run() {
- NetworkSimulation sim = (NetworkSimulation)this.sim ;
- double sum = 0;
- try {
- double arr ;
- double[] q= new double[sim.n+1] ;
- Job newjob ;
- int j ;
-
- // actions
- Lang.outtext("Arrivals manager initialization") ;
- Lang.outtext(" Arrival rate [arrivals per unit of time]?") ;
- arr=Lang.inreal() ;
- Negexp negexp=new Negexp(sim.seed,arr) ;
- for(j=0;j<=sim.n;j++){
- if (j == 0)
- Lang.outtext(" Probability of not even entering the network [0,1]?");
- else
- Lang.outtext(" Probability of entering the network at station "+j+" [0," + (1.0 - sum) + "]?") ;
-
- q[j]=Lang.inreal() ;
- if (q[j] > (1.0 - sum)) q[j] = 1.0 - sum;
- sum = sum + q[j];
- }
- while (true) {
- sim.hold(negexp.draw().asReal()) ;
- newjob = new Job(sim) ;
- newjob.arrtime=sim.time() ;
- newjob.move(sim.n,q) ;
- }
- } catch (Exception e ) {
- System.err.println ("Exception caught in " + this.toString() + " :\n" + e) ;
- System.exit(1) ;
- }
- }
- }