-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fairness - balance number of locations serviced per vehicle #1
Comments
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? |
hi all. I'm also interested in such model. But I'm not totally sure that proposed approach will work. |
@albertsgrc could you check whether following approach will work:
|
We want to be able to balance the number of locations serviced by each vehicle to be as even as possible. The use-case is for example drivers who are getting paid (at least partially) by number of deliveries.
This constraint should be behind a flag and optional.
Implementation: use the underlying solver to
Distribute
constraintDeviation
constraint for vehicle counts targeting thedeviation
vardeviation
varRoughly as follows:
The text was updated successfully, but these errors were encountered: