Package jmt.engine.simEngine

Examples of jmt.engine.simEngine.Simulation$SimMeasure


    try {
      //add class
      JobClass[] classes = new JobClass[1];
      classes[0] = new JobClass("prima");
      Simulation sim = new Simulation(-1, testName);
      sim.addClasses(classes);

      //terminal
      RandomStrategy[] rrs_term = new RandomStrategy[1];
      rrs_term[0] = new RandomStrategy();

      int[] numJobs = { N }; //variable population

      ServiceTimeStrategy[] ds = { new ServiceTimeStrategy(DelayExp[0], DelayPar[0]) };

      sim.addNode("terminal", new Terminal(numJobs), new Delay(ds), new Router(rrs_term));

      //server 1
      ServiceStrategy[] serv_strat1 = new ServiceStrategy[1];
      serv_strat1[0] = new ServiceTimeStrategy(serverExp1[0], serverPar1[0]);

      RandomStrategy[] rrs_serv1 = new RandomStrategy[1];
      rrs_serv1[0] = new RandomStrategy();

      sim.addNode("server1", new Queue(-1, false, null, null), new Server(1, null, serv_strat1), new Router(rrs_serv1));

      //server 2
      ServiceStrategy[] serv_strat2 = new ServiceStrategy[1];
      serv_strat2[0] = new ServiceTimeStrategy(serverExp2[0], serverPar2[0]);

      RandomStrategy[] rrs_serv2 = new RandomStrategy[1];
      rrs_serv2[0] = new RandomStrategy();

      sim.addNode("server2", new Queue(-1, false, null, null), new Server(1, null, serv_strat2), new Router(rrs_serv2));

      //connections
      sim.addConnection("terminal", "server1");
      sim.addConnection("server1", "server2");
      sim.addConnection("server2", "terminal");

      //measure

      jmt.engine.dataAnalysis.Measure mis3_s1 = new InverseMeasure(testName + "_x1.out", .1, .1, 1000000, true);
      jmt.engine.dataAnalysis.Measure mis3_s2 = new InverseMeasure(testName + "_x2.out", .1, .1, 1000000, true);

      int through = SimConstants.THROUGHPUT;

      sim.addMeasure(through, "server1", mis3_s1, classes[0].getName());
      //sim.addMeasure(through, "server2", mis3_s2, classes[0].getName());

      sim.initialize();
      sim.run();

      System.out.println("tot time = " + NetSystem.getElapsedTime());

    } catch (Exception e) {
      e.printStackTrace();
View Full Code Here


    try {
      //File model = new File(path);
      //FileInputStream is = new FileInputStream(model);
      SimLoader loader = new SimLoader(path);
      Simulation sim = loader.getSim();
      sim.initialize();

      start = System.currentTimeMillis();
      sim.run();
      stop = System.currentTimeMillis();
      elapsed = stop - start;
      //System.out.println("Duration execution "+i+": ");
      //System.out.println(Long.toString(elapsed));
    } catch (FileNotFoundException e) {
View Full Code Here

    try {
      //File model = new File(path);
      //FileInputStream is = new FileInputStream(model);
      SimLoader loader = new SimLoader(path);
      Simulation sim = loader.getSim();

      //TODO: fixed seed
      sim.setRandomEngineSeed(seed);

      sim.initialize();

      start = System.currentTimeMillis();
      sim.run();
      stop = System.currentTimeMillis();
      elapsed = stop - start;
      //System.out.println("Duration execution "+i+": ");
      //System.out.println(Long.toString(elapsed));
    } catch (FileNotFoundException e) {
View Full Code Here

    try {
      //File model = new File(path);
      //FileInputStream is = new FileInputStream(model);
      SimLoader loader = new SimLoader(path);
      Simulation sim = loader.getSim();
      sim.initialize();
      start = System.currentTimeMillis();
      sim.run();
      stop = System.currentTimeMillis();
      elapsed = stop - start;
      //System.out.println("Duration execution "+i+": ");
      System.out.println(Long.toString(elapsed));
    } catch (FileNotFoundException e) {
View Full Code Here

  public static void test2() {

    try {

      SimLoader loader = new SimLoader("D://sim_test_2open.xml");
      Simulation sim = loader.getSim();
      sim.initialize();
      sim.run();
      double elapsed = NetSystem.getElapsedTime();
      System.out.println(elapsed);

    } catch (FileNotFoundException e) {
      System.out.println("Errore, file non trovato...");
View Full Code Here

    for (int i = 0; i < N; i++) {

      try {

        SimLoader loader = new SimLoader("D://sim_prova.xml");
        Simulation sim = loader.getSim();
        sim.initialize();
        start = System.currentTimeMillis();

        sim.run();

        stop = System.currentTimeMillis();
        elapsed = stop - start;
        //System.out.println("Duration execution "+i+": ");
        System.out.println(Long.toString(elapsed));
View Full Code Here

      //add class
      JobClass[] classes = new JobClass[1];
      classes[0] = new JobClass("prima");

      long simTime = 200;
      Simulation sim = new Simulation(-1, "SimulationWithTimer", simTime);

      sim.addClasses(classes);

      //terminal
      RoundRobinStrategy[] rrs_term = new RoundRobinStrategy[1];
      rrs_term[0] = new RoundRobinStrategy();

      int[] numJobs = { 6 };

      ServiceTimeStrategy[] ds = { new ServiceTimeStrategy(DelayExp[0], DelayPar[0]) };

      sim.addNode("terminal", new Terminal(numJobs), new Delay(ds), new Router(rrs_term));

      //server
      ServiceStrategy[] serv_strat = new ServiceStrategy[1];
      serv_strat[0] = new ServiceTimeStrategy(serverExp[0], serverPar[0]);

      RoundRobinStrategy[] rrs_serv = new RoundRobinStrategy[1];
      rrs_serv[0] = new RoundRobinStrategy();

      sim.addNode("server", new Queue(-1, false, null, null), new Server(1, null, serv_strat), new Router(rrs_serv));

      //connections
      sim.addConnection("terminal", "server");
      sim.addConnection("server", "terminal");

      //measure

      jmt.engine.dataAnalysis.Measure mis1 = new jmt.engine.dataAnalysis.Measure("queuelength_s.out", .1, .1, 1000000, false, null);
      jmt.engine.dataAnalysis.Measure mis11 = new jmt.engine.dataAnalysis.Measure("queuelength_t.out", .1, .1, 1000000, false, null);
      jmt.engine.dataAnalysis.Measure mis2 = new jmt.engine.dataAnalysis.Measure("utilization_s.out", .1, .1, 1000000, false, null);
      jmt.engine.dataAnalysis.Measure mis3 = new InverseMeasure("throughput_s.out", .1, .1, 1000000, false);
      jmt.engine.dataAnalysis.Measure mis4 = new jmt.engine.dataAnalysis.Measure("queuetime_s.out", .1, .1, 1000000, false, null);
      jmt.engine.dataAnalysis.Measure mis5 = new jmt.engine.dataAnalysis.Measure("residencetime_s.out", .1, .1, 1000000, false, null);

      jmt.engine.dataAnalysis.Measure mis6 = new jmt.engine.dataAnalysis.Measure("utilization_t.out", .1, .1, 1000000, false, null);
      jmt.engine.dataAnalysis.Measure mis7 = new InverseMeasure("throughput_t.out", .1, .1, 1000000, false);
      jmt.engine.dataAnalysis.Measure mis8 = new jmt.engine.dataAnalysis.Measure("residencetime_t.out", .1, .1, 1000000, false, null);
      jmt.engine.dataAnalysis.Measure mis9 = new jmt.engine.dataAnalysis.Measure("responsetime_s.out", .1, .1, 1000000, false, null);
      jmt.engine.dataAnalysis.Measure mis10 = new jmt.engine.dataAnalysis.Measure("responsetime_t.out", .1, .1, 1000000, false, null);

      int queue_l = SimConstants.QUEUE_LENGTH;
      int utiliz = SimConstants.UTILIZATION;
      int through = SimConstants.THROUGHPUT;
      int queue_t = SimConstants.QUEUE_TIME;
      int resid_t = SimConstants.RESIDENCE_TIME;;
      int resp_t = SimConstants.RESPONSE_TIME;

      //sim.addMeasure(queue_l, "server", mis1, classes[0].getName());
      //sim.addMeasure(queue_l, "terminal", mis11, classes[0].getName());
      sim.addMeasure(utiliz, "server", mis2, classes[0].getName());
      sim.addMeasure(utiliz, "terminal", mis6, classes[0].getName());
      sim.addMeasure(through, "server", mis3, classes[0].getName());
      sim.addMeasure(through, "terminal", mis7, classes[0].getName());
      //sim.addMeasure(resid_t, "server", mis5, classes[0].getName());
      //sim.addMeasure(resid_t, "terminal", mis8, classes[0].getName());
      //sim.addMeasure(resp_t, "server", mis9, classes[0].getName());
      //sim.addMeasure(resp_t, "terminal", mis10, classes[0].getName());

      sim.initialize();
      sim.run();

      System.out.println("tot time = " + NetSystem.getElapsedTime());

    } catch (Exception e) {
      e.printStackTrace();
View Full Code Here

    //sim model successfully created
    //now prepare simulation
    try {
      SimLoader simLoader = new SimLoader(simModelDefinitionPath);
      Simulation sim = simLoader.getSim();

      //sets in the Simulation object the path of the original (i.e. MVA)
      //xml model definition
      sim.setXmlModelDefPath(modelDefinitionPath);

      if (!automaticSeed) {
        //if automaticSeed == false, then a user defined seed is present
        sim.setRandomEngineSeed(simulationSeed);
        sim.initialize();

        logger.debug("jSIM correctly initialized with simulation seed = " + simulationSeed);
      } else {
        sim.initialize();
        logger.debug("jSIM correctly initialized");
      }

      //Avoid saturation
      if (sim.getAllRegions() == null) {
        //if there are no regions...
        boolean sufficientProcessingCapacity = checkProcessingCapacity();

        if (!sufficientProcessingCapacity) {
          logger.warn("Current workload causes system saturation. Simulation will not be started.");
          return false;
        }
      }

      simStarted = true;
      net = sim.getNetwork();

      long start, stop;
      double elapsed;

      //Start time
      start = System.currentTimeMillis();

      sim.run();

      //stop time
      stop = System.currentTimeMillis();
      elapsed = ((stop - start)) / 1000.0;
View Full Code Here

    //sim model successfully created
    //now prepare simulation
    try {
      SimLoader simLoader = new SimLoader(simModelDefinitionPath);
      Simulation sim = simLoader.getSim();
      //sim.MONITOR_BLOCKING_REGION = true;           
      //sets in the Simulation object the path of the original (i.e. MVA)
      //xml model definition
      sim.setXmlModelDefPath(modelDefinitionPath);

      if (!automaticSeed) {
        //if automaticSeed == false, then a user defined seed is present
        sim.setRandomEngineSeed(simulationSeed);
        sim.initialize();

        logger.debug("jSIM correctly initialized with simulation seed = " + simulationSeed);
      } else {
        sim.initialize();
        logger.debug("jSIM correctly initialized");
      }

      //Avoid saturation
      if (sim.getAllRegions() == null) {
        //if there are no regions...
        boolean sufficientProcessingCapacity = inputModel.checkSaturation() == ExactModel.NO_SATURATION;

        if (!sufficientProcessingCapacity) {
          logger.warn("Current workload causes system saturation. Simulation will not be started.");
          return false;
        }
      }

      simStarted = true;
      net = sim.getNetwork();

      long start, stop;
      double elapsed;

      //Start time
      start = System.currentTimeMillis();

      sim.run();

      //stop time
      stop = System.currentTimeMillis();
      elapsed = ((stop - start)) / 1000.0;
View Full Code Here

TOP

Related Classes of jmt.engine.simEngine.Simulation$SimMeasure

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.