home *** CD-ROM | disk | FTP | other *** search
Java Source | 1998-02-20 | 2.4 KB | 80 lines |
-
- package examples.warehouse;
-
-
- import simula.*;
- import simula.simset.simulation.* ;
- import simula.Lang ;
- /**
- * Main program for warehouse simulation
- * @author Andrea Poltronieri
- * @version 1.0 12 Feb 1998
- */
-
- public class WareHouseMain extends SimulationMain {
-
-
-
- /**
- * @param _simulation The active Simulation
- * @exception simula.SimulaException Any exception from Korretto API
- */
- public WareHouseMain(Simulation _simulation) throws SimulaException {
- super(_simulation);
- }
- /**
- * Executes the main program for the simulation
- */
- public void run() {
- try {
- WareHouseSimulation sim=(WareHouseSimulation)this.sim ;
- // main program actions start here
- Lang.outtext("Arrivals frequency [arrivals for unit of time] ?") ;
- sim.arr=Lang.inreal() ;
- Lang.outtext("Removal frequency [removals for unit of time] ?") ;
- sim.rem=Lang.inreal() ;
- Lang.outtext("Simulation length [units of time] ?") ;
- sim.simperiod=Lang.inreal() ;
- Lang.outtext("Input batch size range :") ;
- Lang.outtext(" Lower bound ?") ;
- sim.in1=Lang.inint() ;
- Lang.outtext(" Upper bound ?") ;
- sim.in2=Lang.inint() ;
- Lang.outtext("Output batch size range :") ;
- Lang.outtext(" Lower bound ?") ;
- sim.out1=Lang.inint() ;
- Lang.outtext(" Upper bound ?") ;
- sim.out2=Lang.inint() ;
- Lang.outtext("Storage units available ?") ;
- sim.m = Lang.inint() ;
- Lang.outtext("Random generator seed (odd) ?") ;
- sim.seed=Lang.inint() ;
-
- sim.n = 0; // No units are present in warehouse at time 0: experiment on this
- sim.rejected = 0; // No batches are initially rejected
- sim.arrived = 0; // And no one is arrived
- sim.iharea = 0;
- sim.lastevent = 0;
-
- sim.activate(new Arrivals(sim));
-
- sim.worker = new Removals(sim) ;
- sim.activate(sim.worker) ;
-
-
- sim.hold(sim.simperiod) ;
-
- //System.out.println("Sono proprio io") ;
- Lang.outtext("The proportion of rejected batches is ") ;
- Lang.outfix((double) sim.rejected/sim.arrived,3,10); Lang.outimage() ;
- Lang.outtext("Average No. of items in warehouse=") ;
- Lang.outfix((double) sim.iharea/sim.simperiod,3,10) ;Lang.outimage() ;
- sim.end() ;
- System.exit(0) ;
-
- } catch(SimulaException e) {
- Lang.outtext(" Exception :> " + e+e.getMessage());
- System.exit(1);
- }
- }
- }