/**
   * 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);

  }
Beispiel #2
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));
      }
  }