home *** CD-ROM | disk | FTP | other *** search
Java Source | 1998-02-20 | 1.5 KB | 59 lines |
-
- package examples.warehouse;
-
-
- import simula.*;
- import simula.simset.simulation.*;
- import simula.random.* ;
- /**
- * Activity concerned with outgoing batchs
- * @author Andrea Poltronieri
- * @version 1.0 12 Feb 1998
- */
-
- public class Removals extends simula.simset.simulation.Process {
-
-
-
- /**
- * @param _sim The active Simulation
- */
-
- public Removals (Simulation _sim){
- super(_sim);
- }
- /**
- * Executes actions for this object. Called by simulation on activate
- * @see simula.simset.simulation.Simulation
- */
-
-
-
- public void run() {
- WareHouseSimulation sim = (WareHouseSimulation)this.sim ;
- Negexp negexp=new Negexp(sim.seed,sim.rem) ;
- Randint randint=new Randint(sim.seed,sim.out1,sim.out2) ;
- //declare local integers for size of outgoing batch and number removed, and enter infinite loop
- int size, number;
- try {
- while (true) {
- while (sim.n > 0) {
- sim.hold(negexp.draw().asReal()) ;
- sim.iharea += sim.n * (sim.time()-sim.lastevent) ;
- sim.lastevent = sim.time() ;
- size = randint.draw().asInteger();
- number = (size < sim.n)? size : sim.n;
- sim.n -= number;
- //sim.update() ;
-
- }
- // warehouse is now empty
- //System.err.println(this.toString()+" passivating") ;
- sim.passivate() ;
- }
- } catch (Exception e) {
- System.err.println ("Removals exception caught: " + e) ;
- System.exit(1) ;
- }
- }
- }