home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 21 / IOPROG_21.ISO / SOFT / JSL.ZIP / JSL20 / examples / warehouse / WareHouseMain.java < prev    next >
Encoding:
Java Source  |  1998-02-20  |  2.4 KB  |  80 lines

  1.  
  2. package examples.warehouse;
  3.  
  4.  
  5. import simula.*;
  6. import simula.simset.simulation.* ;
  7. import simula.Lang ;
  8. /**
  9.  * Main program for warehouse simulation
  10.  * @author Andrea Poltronieri
  11.  * @version 1.0 12 Feb 1998
  12.  */
  13.  
  14. public class WareHouseMain extends SimulationMain {
  15.  
  16.  
  17.  
  18. /**
  19. * @param _simulation The active Simulation
  20. * @exception simula.SimulaException Any exception from Korretto API
  21. */
  22.         public WareHouseMain(Simulation _simulation) throws SimulaException {
  23.           super(_simulation);
  24.         }
  25. /**     
  26.   * Executes the main program for the simulation
  27. */
  28.         public void run() {
  29.                 try {
  30.                         WareHouseSimulation sim=(WareHouseSimulation)this.sim ;
  31.                         // main program actions start here
  32.                         Lang.outtext("Arrivals frequency [arrivals for unit of time] ?") ;
  33.                         sim.arr=Lang.inreal() ;
  34.                         Lang.outtext("Removal frequency [removals for unit of time] ?") ;
  35.                         sim.rem=Lang.inreal() ;
  36.                         Lang.outtext("Simulation length [units of time] ?") ;
  37.                         sim.simperiod=Lang.inreal() ;
  38.                         Lang.outtext("Input batch size range :") ;
  39.                         Lang.outtext("  Lower bound ?") ;
  40.                         sim.in1=Lang.inint() ;
  41.                         Lang.outtext("  Upper bound ?") ;
  42.                         sim.in2=Lang.inint() ;
  43.                         Lang.outtext("Output batch size range :") ;
  44.                         Lang.outtext("  Lower bound ?") ;
  45.                         sim.out1=Lang.inint() ;
  46.                         Lang.outtext("  Upper bound ?") ;
  47.                         sim.out2=Lang.inint() ;
  48.                         Lang.outtext("Storage units available ?") ;
  49.                         sim.m = Lang.inint() ;
  50.                         Lang.outtext("Random generator seed (odd) ?") ;
  51.                         sim.seed=Lang.inint() ;
  52.  
  53.                         sim.n = 0; // No units are present in warehouse at time 0: experiment on this
  54.                         sim.rejected = 0; // No batches are initially rejected
  55.                         sim.arrived = 0; // And no one is arrived
  56.                         sim.iharea = 0;
  57.                         sim.lastevent = 0;
  58.  
  59.                         sim.activate(new Arrivals(sim));
  60.  
  61.                         sim.worker = new Removals(sim) ;
  62.                         sim.activate(sim.worker) ;
  63.  
  64.  
  65.                         sim.hold(sim.simperiod) ;
  66.                         
  67.                         //System.out.println("Sono proprio io") ;
  68.                         Lang.outtext("The proportion of rejected batches is ") ;
  69.                         Lang.outfix((double) sim.rejected/sim.arrived,3,10); Lang.outimage() ;
  70.                         Lang.outtext("Average No. of items in warehouse=") ;
  71.                         Lang.outfix((double) sim.iharea/sim.simperiod,3,10) ;Lang.outimage() ;
  72.                         sim.end() ;
  73.                         System.exit(0) ;
  74.  
  75.                  } catch(SimulaException e) {
  76.                    Lang.outtext(" Exception :> " + e+e.getMessage());
  77.                  System.exit(1);
  78.                 }
  79.         }
  80. }