Comments (3)
Hi @daniel-j-h,
I have tried implementing your solution and came up with the following code, very similar to yours:
// vehicleCounts[i] == # of nodes being serviced by vehicle i
std::vector<operations_research::IntVar*> vehicleCounts;
// vehicleVars[i] == vehicle attending node i
std::vector<operations_research::IntVar*> vehicleVars;
for (auto vehicle = 0; vehicle < numVehicles; ++vehicle) {
vehicleCounts.push_back(solver->MakeIntVar(0, numNodes));
}
for (auto node = 0; node < numNodes; ++node) {
vehicleVars.push_back(model.VehicleVar(model.NodeToIndex((NodeIndex)(node))));
}
// Definition of vehicleCounts
solver->AddConstraint(solver->MakeDistribute(vehicleVars, vehicleCounts));
// Holds deviation from ideally balanced route assignment
auto* deviationVar = solver->MakeIntVar(0, numNodes * numNodes);
// Definition of the deviation from the ideally balanced route assignment
solver->AddConstraint(solver->MakeDeviation(vehicleCounts, deviationVar, numNodes));
// Minimize the deviation
model.AddVariableMinimizedByFinalizer(deviationVar);
model.CloseModel();
I more or less understand the meaning of the constraints and how they work together with the minimisation rule to implement the balancing but I am clearly missing something, as the solutions are still unbalanced, with some vehicles being unused. Do you have any idea on how to get it working?
from node-or-tools.
hi all. I'm also interested in such model. But I'm not totally sure that proposed approach will work.
Because, AddVariableMinimizedByFinalizer is working "after" solution is found, not during the search process. In this case I assume it cannot change the solution dramatically.
What were the assumptions that such approach will lead to required distribution?
from node-or-tools.
@albertsgrc could you check whether following approach will work:
- You create a solution with your existing model, add deviationVar to the assignment (if its possible) and check its' value when solution is found
- By some technic, for example incrementally decreasing the Max value (horizon) for deviationVar domain, try to find another solution. And with several iterations compare solutions
from node-or-tools.
Related Issues (20)
- npm ERR! .... HOT 1
- What is durations? And how to declare demands? HOT 1
- `ACTION binding_gyp_action_before_build_target_install_deps mason_packages` is called twice on Node 10 HOT 2
- RouteLocks is for establish starting points in order, or to assign points to route to visit optimized?
- Time windows array must include depot?
- Problem when providing pair of pickup and delivery indices
- Problem when considering vehicles with different vehicle speed and capacity in Google OR tools python
- How to minimize number of vehicles and enforce routes to maximize usage
- Inconsistent results when giving additional vehicle even if not required
- Not giving the best (shortest and fastest) route
- Size too large for deployment. Possibilities to reduce size? HOT 1
- [email protected] and [email protected] HOT 6
- How to package google official ortools into static link library
- can't use the package in mac
- how to declare demands ? HOT 1
- Ouput examples on a local webserver
- Windows build
- Usage/Installation on node-alpine
- BUG: amazonaws links not accessible
- Pre build binaries missing for v1.1.0 (OSX + node 14.20.1)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-or-tools.