Exemplo n.º 1
0
  public double fitness() {
    double fit = data.getSpot(path[0]).durationObservation(0);

    for (int i = 0; i < path.length - 1; i++) {
      fit +=
          data.getSpot(path[i]).durationObservation((int) fit * (24 * 60 * 60))
              + data.getCost(path[i], path[i + 1]);
      // System.out.println("Tempo :" + data.getSpot(path[i]).durationObservation((int)fit
      // *(24*60*60)) );
    }

    return fit;
  }
Exemplo n.º 2
0
  public RoverCircuit(ObservationData data, String crossoverType, String mutationType) {
    this.data = data;
    this.crossoverType = crossoverType;
    this.mutationType = mutationType;
    path = new int[data.getSize()];

    Integer[] pathAux = new Integer[data.getSize()];

    for (int i = 0; i < data.getSize(); i++) pathAux[i] = i;

    List<Integer> aux = new ArrayList<Integer>(Arrays.asList(pathAux));
    Collections.shuffle(aux);
    pathAux = aux.toArray(pathAux);

    for (int i = 0; i < pathAux.length; i++) {
      path[i] = pathAux[i].intValue();
    }

    // System.out.print("\n" + Arrays.toString(path));

  }