Uploaded image for project: 'OptaPlanner'
  1. OptaPlanner
  2. PLANNER-1801

Use Constraint Streams in OptaWeb Vehicle Routing

XMLWordPrintable

    • 2020 Week 16-18 (from Apr 13)
    • 3
    • NEW
    • NEW

      Use Constraint Streams on vehicle routing domain to identify missing API features on Constraint Streams.

      DRL scoring rules:

      // Hard constraints
      
      rule "vehicleCapacity"
          when
              $vehicle : PlanningVehicle($capacity : capacity)
              accumulate(
                          PlanningVisit(
                              vehicle == $vehicle,
                              $demand : demand);
                          $demandTotal : sum($demand);
                          $demandTotal > $capacity
                      )
          then
              scoreHolder.addHardConstraintMatch(kcontext, $capacity - $demandTotal);
      end
      
      // Soft constraints
      
      rule "distanceToPreviousStandstill"
          when
              $visit : PlanningVisit(previousStandstill != null, $distanceFromPreviousStandstill : distanceFromPreviousStandstill)
          then
              scoreHolder.addSoftConstraintMatch(kcontext, - $distanceFromPreviousStandstill);
      end
      
      rule "distanceFromLastCustomerToDepot"
          when
              $visit : PlanningVisit(previousStandstill != null)
              not PlanningVisit(previousStandstill == $visit)
          then
              PlanningVehicle vehicle = $visit.getVehicle();
              scoreHolder.addSoftConstraintMatch(kcontext, - $visit.getDistanceTo(vehicle));
      end
      

            jlocker Jiří Locker
            jlocker Jiří Locker
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: