コード例 #1
0
  @Override
  public double evaluate() {
    DeterministicMaxWorkTimeNodes wton = new DeterministicMaxWorkTimeNodes();

    int vehiType = -1;
    int departureNode, arrivalNode;
    double timeSpent = 0, speed;
    Request req;

    // each route
    for (Route r : Solution.getRoutes()) {
      vehiType = (r.isHasType() ? r.getType() : -1);
      if (Instance.getRequest(r.getRequests().get(0).getId()).getAttribute("serviceTime") != null)
        timeSpent +=
            ((DoubleValue)
                    Instance.getRequest(r.getRequests().get(0).getId())
                        .getAttribute("serviceTime")
                        .get(0))
                .getValue();

      for (int reqIndex = 1; reqIndex < r.getRequests().size(); reqIndex++) {
        req = r.getRequests().get(reqIndex);
        arrivalNode = req.getNodeId();
        departureNode = r.getRequests().get(reqIndex - 1).getNodeId();

        if (vehiType != -1)
          speed =
              wton.getSpeed(Instance.getVehicle(vehiType).getAttribute("speedProfile"), timeSpent);
        else
          speed =
              wton.getSpeed(Instance.getVehicle(vehiType).getAttribute("speedProfile"), timeSpent);
        timeSpent += DistanceCalculator.calculateDistance(departureNode, arrivalNode) / speed;
        if (Instance.getRequest(req.getId()).getAttribute("serviceTime") != null)
          timeSpent +=
              ((DoubleValue) Instance.getRequest(req.getId()).getAttribute("serviceTime").get(0))
                  .getValue();
      }
    }

    return timeSpent;
  }
 private void checkDemands(VehicleCResult vcr) {
   double capacityMax;
   Compartment compartement;
   for (int pId : vcr.getProductIds()) {
     compartement = (Compartment) Instance.getVehicle().getAttribute("compartment").get(pId);
     capacityMax = compartement.getMax();
     if (vcr.getSumDemands().get(pId) > capacityMax) {
       cEval.addMessage(
           "Deterministic capacity Single Vehicle Multi Product|Vehicle capacity , Product Id "
               + pId
               + " - "
               + vcr.getSumDemands().get(pId)
               + " greater than "
               + capacityMax);
     }
   }
 }