home *** CD-ROM | disk | FTP | other *** search
Java Source | 1998-02-20 | 2.2 KB | 87 lines |
-
- package examples.priosys;
-
-
- import simula.*;
- import simula.simset.simulation.* ;
- import simula.Lang ;
- /**
- * Main program for priority system simulation
- * @author Andrea Poltronieri
- * @version 1.0 12 Feb 1998
- */
-
- public class PrioSysMain extends SimulationMain {
-
-
-
-
- /**
- * @param _simulation The active Simulation
- * @exception simula.SimulaException Any exception from Korretto API
- */
-
- public PrioSysMain(Simulation _simulation) throws SimulaException {
- super(_simulation);
- }
- /**
- * Executes the main program for the simulation
- */
- public void run() {
- try {
- PrioSysSimulation sim=(PrioSysSimulation)this.sim ;
- //Local variables
-
- Lang.outtext("Number of types of customer?") ;
- sim.k = Lang.inint() ;
- Lang.outtext("Number of servers ?") ;
- sim.c = Lang.inint() ;
-
- //Dimension arrays
- // Should be [1..k]; index 0 is ignored
- sim.numthrough = new int[sim.k + 1] ;
- // Should be [1..k]
- sim.sojourn = new double[sim.k + 1] ;
-
-
- // Should be [1..k]
- sim.queue = new simula.simset.Head[sim.k + 1] ;
-
- // main program actions start here
- Lang.outtext("Random generator seed (odd) ?") ;
- sim.seed = Lang.inint() ;
- Lang.outtext("Simulation length ?") ;
- sim.simtime = Lang.inreal() ;
- sim.top = 1 ;
-
- // Activate arrivals processes
- for (sim.i=1; sim.i<=sim.k; sim.i++){
- sim.queue[sim.i] = new simula.simset.Head() ;
- sim.activate (new Arrivals(sim, sim.i)) ;
- }
- sim.available = new simula.simset.Head() ;
-
- // Activate servers
- for(sim.i=1; sim.i<=sim.c; sim.i++) {
- sim.activate (new Server(sim)) ;
- }
-
- //System.out.println("Holding main!");
- sim.hold(sim.simtime) ;
- //System.out.println("Simulation complete!");
-
- for (sim.i=1; sim.i<=sim.k; sim.i++){
- Lang.outtext("The average sojourn for type") ;
- Lang.outint(sim.i,3) ;
- Lang.outtext("Customer is") ;
- Lang.outfix(((double)(sim.sojourn[sim.i])/((double)(sim.numthrough[sim.i]))),3,10) ;
- Lang.outimage() ;
- }
- sim.end() ;
- System.exit(0) ;
- } catch(SimulaException e) {
- Lang.outtext(" Exception :> " + e+e.getMessage());
- System.exit(1);
- }
- }
- }