mapbox / node-or-tools

Node.js bindings for or-tools vehicle routing problems
MIT License
146 stars 48 forks source link

Developer needed #41

Closed joaopiopedreira closed 6 years ago

joaopiopedreira commented 6 years ago

Hi @daniel-j-h , what a wonderful project you've got here! We at letsjobit.com have an app that does order management and planning alongside with route optimisation. Our app is built with Meteor.js (thus, in the nodejs world) but the optimiser is a customized version or o-tools, built in C++.

Our optimisation servers are nodejs services running C++ binaries with child_process basically.

After seeing your project, I'm sure this is the way to go, but we lack the expertise on some of the libraries you're using (like NAN).

Would you be willing to point us in the right direction here or sharing the contact of someone that could assist?

Many thanks and well done!!

daniel-j-h commented 6 years ago

Great to hear this project is useful for you!

Hm I don't really know how to help you here - if you need features implemented in this project feel free to open detailed tickets - maybe someone from the community will step up. I'm also happy to give you some guidance into the right direction but I'm not able to run features out for you.

What features are you looking for specifically?

joaopiopedreira commented 6 years ago

Hi @daniel-j-h , we have those features implemented in our own vrp.cc, in pure C++. Let me give you an example. Below an extract of our vpr.cc.

feature: enforcing a max distance per route:

implementation: (jsonObj is the json object with the algorithm input - we use the nlohmann/json library

(...)
using operations_research::ServiceTimePlusTransition;
using operations_research::RoutingModel;
(...)
RoutingModel routing(2*numShipments + numServices + numTotalDifferentDepots,
      numVehicles, vDepots);  
(...)
// Adding a maximun distance constraint
  const int64 kMaxDistance = 999999999;
  std::vector<int64> vMaxDistance (numVehicles);
  const int64 kTimePerDemandUnitFake = 0;//Using a fake value
  for (int i=0; i<numVehicles; i++){
      if(jsonObj["vehicles"][i].count("max_distance")==0){
          vMaxDistance[i]=kMaxDistance;
      } else {
          vMaxDistance[i]=jsonObj["vehicles"][i]["max_distance"];
      }
  }
  ServiceTimePlusTransition distance(
      kTimePerDemandUnitFake, NewPermanentCallback(&demand, &DeterministicDemand::ServiceTime),
      NewPermanentCallback(&locations, &LocationContainer::DistanceBetweenNodes));
  routing.AddDimensionWithVehicleCapacity(
      NewPermanentCallback(&distance, &ServiceTimePlusTransition::Compute),
      kMaxDistance, vMaxDistance, /*fix_start_cumul_to_zero=*/true, kDistance);
  const operations_research::RoutingDimension& distance_dimension =
      routing.GetDimensionOrDie(kDistance);
  std::cout << "Done Max Dist\n";
(...)

Question: How would we translate this bit of code in order to add it to your existing vrp.cc in node-or-tools? Many thanks.

daniel-j-h commented 6 years ago

Interaction with the solver happens in the vrp worker here. You need to parse the parameter from the JavaScript side in vrp_params.h, store it, and pass it on to the worker in vrp.cc.