Skip to content

Commit 2d80305

Browse files
committed
Fix bug in policy evaluation
1 parent 4b073c5 commit 2d80305

File tree

10 files changed

+383
-156
lines changed

10 files changed

+383
-156
lines changed

anticipative_animation.gif

-108 KB
Binary file not shown.

compare.gif

-183 KB
Binary file not shown.

dvrptw_animation.gif

-109 KB
Binary file not shown.

dvrptw_epochs.png

-140 KB
Binary file not shown.

greedy_animation.gif

-122 KB
Binary file not shown.

src/DynamicVehicleScheduling/anticipative_solver.jl

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ function anticipative_solver(
5454
)
5555
if reset_env
5656
reset!(env; reset_rng=true, seed)
57+
scenario = env.scenario
5758
end
5859

5960
@assert !is_terminated(env)
@@ -91,14 +92,14 @@ function anticipative_solver(
9192
job_indices = 2:nb_nodes
9293
epoch_indices = T
9394

94-
@variable(model, y[i = 1:nb_nodes, j = 1:nb_nodes, t = epoch_indices]; binary=true)
95+
@variable(model, y[i=1:nb_nodes, j=1:nb_nodes, t=epoch_indices]; binary=true)
9596

9697
@objective(
9798
model,
9899
Max,
99100
sum(
100-
-duration[i, j] * y[i, j, t] for
101-
i in 1:nb_nodes, j in 1:nb_nodes, t in epoch_indices
101+
-duration[i, j] * y[i, j, t] for i in 1:nb_nodes, j in 1:nb_nodes,
102+
t in epoch_indices
102103
)
103104
)
104105

@@ -170,12 +171,14 @@ function anticipative_solver(
170171
routes = epoch_routes[i]
171172
epoch_customers = epoch_indices[i]
172173

173-
y_true = VSPSolution(
174-
Vector{Int}[
175-
map(idx -> findfirst(==(idx), epoch_customers), route) for route in routes
176-
];
177-
max_index=length(epoch_customers),
178-
).edge_matrix
174+
y_true =
175+
VSPSolution(
176+
Vector{Int}[
177+
map(idx -> findfirst(==(idx), epoch_customers), route) for
178+
route in routes
179+
];
180+
max_index=length(epoch_customers),
181+
).edge_matrix
179182

180183
location_indices = customer_index[epoch_customers]
181184
new_coordinates = env.instance.static_instance.coordinate[location_indices]
@@ -199,8 +202,7 @@ function anticipative_solver(
199202
is_must_dispatch[2:end] .= true
200203
else
201204
is_must_dispatch[2:end] .=
202-
planning_start_time .+ epoch_duration .+ @view(new_duration[1, 2:end]) .>
203-
new_start_time[2:end]
205+
planning_start_time .+ epoch_duration .+ @view(new_duration[1, 2:end]) .> new_start_time[2:end]
204206
end
205207
is_postponable[2:end] .= .!is_must_dispatch[2:end]
206208
# TODO: avoid code duplication with add_new_customers!

0 commit comments

Comments
 (0)