0

I'm using Optaplanner VRP tool to solve some VRP instances. Is there a way to view the number of vehicles being used in real-time? Also, what algorithm does Optaplanner employ for solving VRP?

Thanks, Mayank

1 Answers1

0

When you're listening to new best solution events in real time (Solver.addSolverListener), it's straightforward to determine the number of vehicles used, by iterating all Vehicle instances and checking if nextVisit isn't null.

Note that if you want to minimize the number of vehicle used, you'll need to add a hard or softt constraint for that, which is simple: when Vehicle(nextVisit != null) then addHard(-1); end

As for the algorithm used to solve VRP: check the solver config XML. We support many algo's, in the vrp benchmark config XML we let them battle against each other to determine the best algo for production.

Geoffrey De Smet
  • 26,223
  • 11
  • 73
  • 120
  • Thanks a lot, Geoff. I was just wondering if the algorithm also supports heterogeneous capacities for vehicles, i.e., Vehicle 1 has capacity 200 and Vehicle 2 has capacity 100... and so on. Thanks again!! – user2876943 Apr 14 '16 at 15:32
  • I'm very new to Optaplanner. I just ran the runExampls.bat to try out few instances of VRP. Following your suggestion, I made changes to the file "vehicleRoutingScoreRules.drl" located at "optaplanner-distribution-6.3.0.Final\examples\sources\src\main\resources\org\optaplanner\examples\vehiclerouting\solver". Is that even correct? I added the constraint: rule "minVehicles" when $vehicle : Vehicle(nextVisit != null) then scoreHolder.addHardConstraintMatch(kcontext, -1); end However, I do not see any effects while using the runExamples.bat file. Is there any link I can refer to? Thanks – user2876943 Apr 14 '16 at 19:03
  • see docs "run examples from source" (the .bat and .sh run them from the jar binaries) – Geoffrey De Smet Apr 17 '16 at 10:21
  • Thanks, Geoff. I was able to run examples from the source. I made the following edit to the vehicleRoutingScoreRules.drl file: rule "minVehicles" when $vehicle : Vehicle(nextVisit != null) then scoreHolder.addHardConstraintMatch(kcontext, -1); end It threw a run-time error. Is there something I'm missing here? Thanks – user2876943 Apr 20 '16 at 14:44
  • Hi Geoff, After looking at the code, it appears to me that you probably meant "nextCustomer" and not "nextVisit". I made that change and the program seems to be working fine now. Just a final question. Every time I make some changes to the .drl file, do I need to do the entire Maven 3 build again? It takes a lot of time to build the projects (as it builds all the projects). Thanks. – user2876943 Apr 21 '16 at 15:20
  • Open the maven 3 project in IntelliJ (or eclipse). Building incrementally should work. When I make a change in a drl file, I just click run in Intellij (no need to build with maven for that) and see the results in the UI or unit tests. – Geoffrey De Smet Apr 22 '16 at 07:02
  • Thanks a lot, Geoff. – user2876943 Apr 23 '16 at 00:48