@Override
  protected double computeHeuristicValue(StateObservation actualState) {

    final Vector2d avPos = actualState.getAvatarPosition();

    final ArrayList<Observation>[] observables = this.getObservables(actualState);

    if (observables == null || observables.length == 0) {
      return 0;
    }

    double nearest = Double.MAX_VALUE;

    int counter = 0;

    double distSum = 0.0;

    for (ArrayList<Observation> observableList : observables) {
      for (Observation observable : observableList) {
        if (this.tabooMap.containsKey(observable.obsID)) {
          continue;
        }

        counter++;
        double xDist = (observable.position.x - avPos.x);
        double yDist = (observable.position.y - avPos.y);

        double mhDist = observable.position.dist(avPos); // Math.abs(xDist + yDist);

        distSum += mhDist;

        if (mhDist < nearest) {
          nearest = mhDist;
        }
      }
    }

    //		System.out.println(this.objectiveName + ": " + counter +  " - " + nearest);

    if (counter == 0) {
      return 0.0;
    }

    double height = actualState.getWorldDimension().getHeight() * actualState.getBlockSize();
    double width = actualState.getWorldDimension().getWidth() * actualState.getBlockSize();

    nearest = Utils.normalise(nearest, 0, height * height + width * width);

    switch (this.valType) {
      case MINIMIZE:
        return -counter;
      case MINIMIZE_NEAREST:
        return -(counter + nearest);
      case NEAREST:
        return -nearest;
      default:
        return -nearest;
    }
  }
Example #2
0
 public static void reduceAllPrices(List<Tour> list, User user) {
   for (Tour tour : list) {
     Utils.reducePrice(tour, user);
   }
 }