Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Fairness - balance number of locations serviced per vehicle

Open
#1 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
28/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
cpp
Domain
backend

Research direction

No file or test is named. Start by locating the vehicle-routing model and its optional-constraint configuration, then inspect how the underlying solver exposes Distribute, Deviation, and finalizer minimization. Done means an optional flag enables balanced per-vehicle location counts and the solver minimizes their deviation.

Written by the indexing model from the issue text.

Description

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

  • Establish a vehicle vars <-> vehicle counts relationship via the Distribute constraint
  • Add a Deviation constraint for vehicle counts targeting the deviation var
  • Minimizing the deviation var

Roughly as follows:

std::vector<IntVar*> vehicleCounts;

for (auto vehicle = 0; vehicle < numVehicles; ++vehicle)
  vehicleCounts.push_back(solver->MakeIntVar(0, numNodes));

solver->AddConstraint(solver->MakeDistribute(vehicleVars, vehicleCounts));

auto* deviationVar = solver->MakeIntVar(0, numNodes * numNodes);

solver->AddConstraint(solver->MakeDeviation(vehicleCounts, deviationVar, numNodes));

model.AddVariableMinimizedByFinalizer(deviationVar);
Dominant language
C++
Stars
155
Forks
47
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from mapbox/node-or-tools

All issues in mapbox/node-or-tools

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.