Ejemplo n.º 1
0
  public static void main(String[] args) {

    // System.out.println("In main() on CBSimulation class");

    // we're not using the GUI if we enter via this method...
    useGUI = false;

    /*
     * this starts the run off
     *
     * the parameters for the simulation will ultimately be read from the parameter file
     */
    try {
      String[] tokens = args[1].split("/");
      batchSize = Long.parseLong(tokens[0]);
      batchNumber = Long.parseLong(tokens[1]);
      jobNumber = Long.parseLong(tokens[2]);
    } catch (Exception e) {
      batchSize = defaultBatchSize;
      batchNumber = defaultBatchNumber;
      jobNumber = defaultJobNumber;
    }

    // System.out.println("Batch size is " + batchSize);
    // System.out.println("Maximum batch size is " + maxBatchSize);
    // System.out.println("Batch number is " + batchNumber);
    // System.out.println("Maximum batch number is " + maxBatchNumber);
    // System.out.println("Job number is " + jobNumber);

    seed = (batchSize * maxBatchSize * 10000000);
    seed += (batchNumber * maxBatchNumber * 10000);
    seed += jobNumber;

    // System.out.println("Random number seed used " + seed);
    CBSimulation cbsim = new CBSimulation(seed, args);

    cbsim.start();

    long steps;
    double time;

    do {

      if (!cbsim.schedule.step(cbsim)) // performs the step, and if return is false, stops looping.
      break;

      steps = cbsim.schedule.getSteps(); // How many steps have been performed?
      time = cbsim.schedule.getTime(); // retrieve the current time in the simulation.

      // System.out.println(cbsim + " currently at step: " + steps);

      final long timeNow = System.currentTimeMillis();

      if (timeNow - startTime >= (timeOut * 3600000)) break;

    } while (steps <= (simulationSteps + 4)); // stopping condition.

    cbsim.finish();
  }