/** @param args */
  public static void main(String[] args) {
    long startTime = System.currentTimeMillis();

    try {
      Class<?> problemClass = Class.forName("problems.Problem" + args[0]);
      Problem problemInstance = (Problem) problemClass.newInstance();
      problemInstance.solve();
    } catch (ClassNotFoundException
        | SecurityException
        | InstantiationException
        | IllegalAccessException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    long endTime = System.currentTimeMillis();
    System.out.println("Done [Elapsed: " + ((endTime - startTime) / 1000.0) + "\"]");
  }
Example #2
0
    public void onTick() {
      String type;
      int delay;
      String description;
      Flight flight;
      CrewMember crew;

      int warningAircraft = 50;
      int warningCrew = 25;
      int warningPax = 35;

      Warning warning;
      CrewProblem crewProblem;
      AircraftProblem airProblem;
      PaxProblem paxProblem;
      Problem problem;
      HashMap<Flight, Problem> problems = new HashMap<Flight, Problem>();
      HashMap<Flight, Warning> warnings = new HashMap<Flight, Warning>();

      warning = null;
      crewProblem = null;
      airProblem = null;
      problem = null;
      paxProblem = null;

      // criar delay na an�lise de eventos

      // ler dados evento
      type = events.get(num_rows).getType();
      System.out.println("Type:" + type);
      delay = events.get(num_rows).getDelay();
      System.out.println("Delay: " + delay);
      description = events.get(num_rows).getDescription();
      System.out.println("Description: " + description);
      flight = events.get(num_rows).getFlight();
      System.out.println("Num voo" + flight.getFlightNumber());

      if (type.equalsIgnoreCase("aircraft")) {
        if (delay < warningAircraft) {

          if (problems.get(flight) == null) {

            warning = new Warning(flight, type, description, delay);

            if (warnings.get(flight) != null) {
              if (warnings.get(flight).getMinutesDelay() < delay) {
                warnings.remove(flight);
                warnings.put(flight, warning);
              }
            } else {
              warnings.put(flight, warning);
            }

            frame_voos.addWarning_Panel(warning);
          }
        } else {
          airProblem = new AircraftProblem(description, delay);

          if (warnings.get(flight) != null) warnings.remove(flight);

          if (problems.get(flight) != null) {
            problem = problems.get(flight);
            problems.remove(flight);
            problem.addAirProbs(airProblem);
          } else {
            problem = new Problem(flight);
            problem.addAirProbs(airProblem);
          }
          problems.put(flight, problem);

          frame_voos.addProblem_Panel(airProblem);
        }

      } else if (type.equalsIgnoreCase("crewmember")) {
        if (delay < warningCrew) {
          if (problems.get(flight) == null) {
            warning = new Warning(flight, type, description, delay);

            if (warnings.get(flight) != null) {
              if (warnings.get(flight).getMinutesDelay() < delay) {
                warnings.remove(flight);
                warnings.put(flight, warning);
              }
            } else {
              warnings.put(flight, warning);
            }
          }
        } else {
          crewProblem = new CrewProblem(events.get(num_rows).getCrewMember(), description, delay);

          if (warnings.get(flight) != null) warnings.remove(flight);

          if (problems.get(flight) != null) {
            problem = problems.get(flight);
            problems.remove(flight);
            problem.addCrewProbs(crewProblem);
          } else {
            problem = new Problem(flight);
            problem.addCrewProbs(crewProblem);
          }

          problems.put(flight, problem);
        }

      } else {
        if (delay < warningPax) {
          if (problems.get(flight) == null) {
            warning = new Warning(flight, type, description, delay);

            if (warnings.get(flight) != null) {
              if (warnings.get(flight).getMinutesDelay() < delay) {
                warnings.remove(flight);
                warnings.put(flight, warning);
              }
            } else {
              warnings.put(flight, warning);
            }
          }
        } else {
          paxProblem = new PaxProblem(description, delay, events.get(num_rows).getNumPax());

          if (warnings.get(flight) != null) warnings.remove(flight);

          if (problems.get(flight) != null) {
            problem = problems.get(flight);
            problems.remove(flight);
            problem.addPaxProbs(paxProblem);
          } else {
            problem = new Problem(flight);
            problem.addPaxProbs(paxProblem);
          }

          problems.put(flight, problem);
        }
      }
      num_rows++;

      Set set = problems.entrySet();

      Iterator i = set.iterator();

      while (i.hasNext()) {
        Map.Entry me = (Map.Entry) i.next();
        ((Problem) me.getValue()).print();
        EnviaProblema envProb = new EnviaProblema(myAgent, (Problem) me.getValue(), esc);
        addBehaviour(envProb);
      }
    }