Timewindow vehicles unassigned

23 views
Skip to first unread message

Hariganesh B

unread,
Dec 4, 2025, 11:41:06 AM (2 days ago) Dec 4
to or-tools-discuss
Hello,
Using ORTools 9.12 I have 3000 nodes and 100 vehicles 
Constraints
1. Timewindow
2. Capacity
3. Skill based assignment
Problem I face is few of the nodes went unassigned even though it can set it into existing vehicle even time window , capacity and Skill matches.

Example:
Node 1,3,5,7 assigned to vehicle 1. Node 9 went unassigned
I reran with node 1,3,5,7,9 with vehicle 1 with same constraints its getting assigned. I feel its because of more nodes reassigning is not happening. Can someone help on this

below is my snippet

for (Map.Entry<Long, List<Integer>> entry : appointmentIndexVsAllowedUsersIndex.entrySet()) {

int[] allowedVehicles = entry.getValue().stream().mapToInt(Integer::intValue).toArray();

long nodeIndex = manager.nodeToIndex(entry.getKey().intValue());

routing.setAllowedVehiclesForIndex(allowedVehicles, nodeIndex);

}

for (int v = 0; v < userTimeWindow.length; ++v) {

long startIndex = routing.start(v);

long endIndex = routing.end(v);

int vs = (int) Math.round(this.userTimeWindow[v][0]);

int ve = (int) Math.round(this.userTimeWindow[v][1]);

timeDimension.cumulVar(startIndex).setRange(vs, ve);

timeDimension.cumulVar(endIndex).setRange(vs, ve);

}

for (int i = 0; i < numNodes; ++i) {

routing.addDisjunction(

new long[]{manager.nodeToIndex(i)},

1_000_000_000 // 1e12

);


}

routing.addDimensionWithVehicleCapacity(

demandCallbackIndex,

0, // no capacity slack

userMaxCapacities, // per-vehicle capacities

true, // start cumul to zero

"Capacity" // dimension name

);

RoutingSearchParameters searchParameters = main.defaultRoutingSearchParameters()

.toBuilder()

.setFirstSolutionStrategy(FirstSolutionStrategy.Value.PARALLEL_CHEAPEST_INSERTION)

.setLocalSearchMetaheuristic(LocalSearchMetaheuristic.Value.AUTOMATIC)

.setTimeLimit(Duration.newBuilder().setSeconds(180).build())

.build();


Hariganesh B

unread,
Dec 4, 2025, 11:57:46 AM (2 days ago) Dec 4
to or-tools-discuss


for (int i = 0 ; i < stopTimeWindow.length; ++i) {

long index = manager.nodeToIndex(i);

timeDimension.setCumulVarSoftUpperBound(

index,

Math.round(this.stopTimeWindow[i][1]),

1000 // penalty per minute violated

);

int hardStart = (int)Math.round(stopTimeWindow[i][0]);

int hardEnd = (int)Math.round(stopTimeWindow[i][1]);


IntVar var = timeDimension.cumulVar(index);


// Soft window penalty

timeDimension.setCumulVarSoftLowerBound(index, hardStart, 50000); // penalty before start

timeDimension.setCumulVarSoftUpperBound(index, hardEnd, 50000); // penalty after end


}


Missed this
Reply all
Reply to author
Forward
0 new messages