Esempio n. 1
0
  /**
   * This method is called to start the simulation. the run parameters are copied to the results
   * output directory. The run output file is created ready for writing.
   */
  public void start() {
    super.start(); // call supertype's start method.

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

    // need to read the parameter file
    readParameters(true);

    // And I want to write the random number seed used for this run - for record keeping

    PrintWriter dataOutput;

    new File(resultFilePath + "/" + description + "/" + runFilePath).mkdirs();
    File runSeedFile =
        new File(resultFilePath + "/" + description + "/" + runFilePath + "/simRunSeed");
    System.out.println("Creating output file " + runSeedFile.getName());

    String paramCopyFile =
        resultFilePath + "/" + description + "/" + runFilePath + "/" + paramCopyName;
    copyFile(xmlFileLocation, paramCopyFile);

    try {
      dataOutput = new PrintWriter(runSeedFile);
      dataOutput.print(seed);
      dataOutput.close();
    } catch (Exception e) {
      e.printStackTrace();
    }

    // I'll need to instantiate the data store here
    // I'll schedule it from the constructor...
    dataStore = new DataStore(this);
    // System.out.println("Created DataStore object " + dataStore);

  }
Esempio n. 2
0
  /*
   * This method is called to wind down the simulation.
   */
  public void finish() {
    super.finish();

    System.out.println("Terminating the simulation");

    /*
     * write CSV and XML output from simulation
     */
    File csvDataFile =
        new File(resultFilePath + "/" + description + "/" + runFilePath + "/simOutputData.csv");
    System.out.println("Output written to " + csvDataFile);

    // File xmlDataFile = new File(resultFilePath + "/" + description + "/Results/" + runFilePath +
    // "/simOutputData.xml");

    PrintWriter dataOutput;

    try {
      dataOutput = new PrintWriter(csvDataFile);
      dataOutput.print(dataStore.compileTableToString());
      dataOutput.close();

      //	dataStore.compileXMLOutput(xmlDataFile);
    } catch (Exception e) {
      e.printStackTrace();
    }

    System.out.println("Run took " + (System.currentTimeMillis() - startTime) + " milliseconds");
  }
Esempio n. 3
0
  /** Resets and starts a simulation */
  public void start() {
    super.start(); // clear out the schedule

    // make new grids
    createGrids();
    for (int x = 0; x < gridWidth; x++)
      for (int y = 0; y < gridHeight; y++) {
        schedule.scheduleRepeating(new Agent(x, y));
      }
  }