Skip to content

Commit f451364

Browse files
committed
bugfix
1 parent 64224bb commit f451364

File tree

2 files changed

+26
-7
lines changed

2 files changed

+26
-7
lines changed

src/StochasticVehicleScheduling/solution/exact_algorithms/column_generation.jl

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ end
2222
Note: If you have Gurobi, use `grb_model` as `model_builder` instead of `glpk_model`.
2323
"""
2424
function column_generation(
25-
instance::Instance; only_relaxation=false, model_builder=highs_model
25+
instance::Instance;
26+
only_relaxation=false,
27+
model_builder=highs_model,
28+
bounding,
29+
use_convex_resources,
2630
)
2731
(; graph, slacks, intrinsic_delays, vehicle_cost, delay_cost) = instance
2832

@@ -53,7 +57,12 @@ function column_generation(
5357
optimize!(model)
5458
λ_val = value.(λ)
5559
(; c_star, p_star) = stochastic_routing_shortest_path(
56-
graph, slacks, intrinsic_delays, λ_val ./ delay_cost
60+
graph,
61+
slacks,
62+
intrinsic_delays,
63+
λ_val ./ delay_cost;
64+
bounding,
65+
use_convex_resources,
5766
)
5867
λ_sum = sum(λ_val[v] for v in job_indices if v in p_star)
5968
path_cost = delay_cost * c_star + λ_sum + vehicle_cost
@@ -84,7 +93,13 @@ function column_generation(
8493
threshold = (c_upp - c_low - vehicle_cost) / delay_cost
8594
λ_val = value.(λ)
8695
additional_paths, costs = stochastic_routing_shortest_path_with_threshold(
87-
graph, slacks, intrinsic_delays, λ_val ./ delay_cost; threshold
96+
graph,
97+
slacks,
98+
intrinsic_delays,
99+
λ_val ./ delay_cost;
100+
threshold,
101+
bounding=true,
102+
use_convex_resources=false,
88103
)
89104

90105
return value.(λ),
@@ -130,11 +145,15 @@ function compute_solution_from_selected_columns(
130145
optimize!(model)
131146

132147
sol = value.(y)
133-
return objective_value(model), sol, paths[[sol[p] for p in paths] .== 1.0]
148+
return objective_value(model), sol, paths[isapprox.([sol[p] for p in paths], 1.0)]
134149
end
135150

136-
function column_generation_algorithm(instance::Instance)
137-
_, _, columns, _, _ = column_generation(instance)
151+
function column_generation_algorithm(
152+
instance::Instance; bounding=false, use_convex_resources=false
153+
)
154+
_, _, columns, _, _ = column_generation(
155+
instance; bounding=bounding, use_convex_resources=use_convex_resources
156+
)
138157
_, _, sol = compute_solution_from_selected_columns(instance, columns)
139158
col_solution = solution_from_paths(sol, instance)
140159
return col_solution

src/StochasticVehicleScheduling/solution/solution.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ function is_feasible(solution::Solution, instance::Instance)
355355
end
356356

357357
if !all(sum(solution.path_value; dims=1) .== 1)
358-
@warn "One task done by more than one vehicle"
358+
@warn "One task done by more than one vehicle (or less than once)"
359359
return false
360360
end
361361

0 commit comments

Comments
 (0)