Package pec

Examples of pec.Event


   * Mevents and an Observation Event. After that, the main function begins a cycle of removing Events from the PEC
   * and adding new Events if they are generated. The simulation finishes when a
   * finish Exception is caught.
   */
  public void run(){
    Event event;
    LinkedList<ACOEvent> newEventList;//list to hold newly generated events
   
    /*Create a new Adjacency list graph and pass its reference to the
     *SaxParser.*/
    AdjListGraph<Float> graph = new AdjListGraph<Float>();
    try {
      SimParser saxParser = new SimParser(graph, file);
      saxParser.parse();
    }catch (IOException e){
      System.out.println("Failed to open dtd file: The file simulation.dtd must be in the same directory of the " +
          "xml simulation file");
      //e.printStackTrace();
      return;
    }catch (ParserConfigurationException e){
      System.out.println("SAX related Error: "+e.getMessage());
      //e.printStackTrace();
      return;
    }catch (SAXException e){
      System.out.println("SAX related Error: "+e.getMessage());
      //e.printStackTrace();
      return;
    }
    /*Create a new PriorityQueue-PEC and fill it with a new
     *Mevent for each ant in the ant colony*/
    PEC pec = new PQPEC();
    for(int i=0;i<antColSize;i++){
      event = new Mevent(new Float(0), graph);
      pec.addEvent(event);
    }
   
    /*Create the observation Event and put it in the PEC*/
    event = new Observation();
    pec.addEvent(event);
   
    /*PEC event retrieval cycle*/
    while((event = pec.getEvent())!=null){
      try{//Simulate
        newEventList = (LinkedList<ACOEvent>)event.processEvent();
      }catch (FinishException finish){//If the Event processing throws a finish Exception
        //System.out.println("Simulation finished: "+finish.getMessage());
        return;//End of Simulation
      }catch (InvalidGraphException invg){
        System.out.println("Bad Graph Design Error: " + invg.getMessage());
View Full Code Here

TOP

Related Classes of pec.Event

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.