|
22 | 22 | Note: If you have Gurobi, use `grb_model` as `model_builder` instead of `glpk_model`. |
23 | 23 | """ |
24 | 24 | 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, |
26 | 30 | ) |
27 | 31 | (; graph, slacks, intrinsic_delays, vehicle_cost, delay_cost) = instance |
28 | 32 |
|
@@ -53,7 +57,12 @@ function column_generation( |
53 | 57 | optimize!(model) |
54 | 58 | λ_val = value.(λ) |
55 | 59 | (; 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, |
57 | 66 | ) |
58 | 67 | λ_sum = sum(λ_val[v] for v in job_indices if v in p_star) |
59 | 68 | path_cost = delay_cost * c_star + λ_sum + vehicle_cost |
@@ -84,7 +93,13 @@ function column_generation( |
84 | 93 | threshold = (c_upp - c_low - vehicle_cost) / delay_cost |
85 | 94 | λ_val = value.(λ) |
86 | 95 | 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, |
88 | 103 | ) |
89 | 104 |
|
90 | 105 | return value.(λ), |
@@ -130,11 +145,15 @@ function compute_solution_from_selected_columns( |
130 | 145 | optimize!(model) |
131 | 146 |
|
132 | 147 | 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)] |
134 | 149 | end |
135 | 150 |
|
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 | + ) |
138 | 157 | _, _, sol = compute_solution_from_selected_columns(instance, columns) |
139 | 158 | col_solution = solution_from_paths(sol, instance) |
140 | 159 | return col_solution |
|
0 commit comments