Skip to content

Commit 31a6f9e

Browse files
committed
close gap option in column generation
1 parent 5d06cec commit 31a6f9e

File tree

5 files changed

+34
-4
lines changed

5 files changed

+34
-4
lines changed

src/FixedSizeShortestPath/FixedSizeShortestPath.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,5 +146,6 @@ function Utils.generate_statistical_model(bench::FixedSizeShortestPathBenchmark)
146146
end
147147

148148
export FixedSizeShortestPathBenchmark
149+
export generate_dataset, generate_maximizer, generate_statistical_model
149150

150151
end

src/PortfolioOptimization/PortfolioOptimization.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,5 +124,6 @@ function Utils.generate_statistical_model(bench::PortfolioOptimizationBenchmark)
124124
end
125125

126126
export PortfolioOptimizationBenchmark
127+
export generate_dataset, generate_maximizer, generate_statistical_model
127128

128129
end

src/StochasticVehicleScheduling/StochasticVehicleScheduling.jl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,22 @@ function Utils.generate_dataset(
100100
]
101101
end
102102

103+
"""
104+
$TYPEDSIGNATURES
105+
"""
103106
function Utils.generate_maximizer(bench::StochasticVehicleSchedulingBenchmark)
104107
return vsp_maximizer
105108
end
109+
110+
"""
111+
$TYPEDSIGNATURES
112+
"""
106113
function Utils.generate_statistical_model(bench::StochasticVehicleSchedulingBenchmark)
107114
return Chain(Dense(20 => 1; bias=false), vec)
108115
end
109116

110117
export StochasticVehicleSchedulingBenchmark
111-
118+
export generate_dataset, generate_maximizer, generate_statistical_model
112119
export compact_linearized_mip,
113120
compact_mip, column_generation_algorithm, evaluate_solution, is_feasible
114121

src/StochasticVehicleScheduling/solution/exact_algorithms/column_generation.jl

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ function column_generation(
9090

9191
c_low = objective_value(model)
9292
columns = unique(cat(initial_paths, new_paths; dims=1))
93-
return columns
93+
return columns, c_low, value.(λ)
9494
end
9595

9696
"""
@@ -155,18 +155,38 @@ function column_generation_algorithm(
155155
bounding=true,
156156
use_convex_resources=true,
157157
silent=true,
158+
close_gap=false,
158159
)
159160
Ω = isnothing(scenario_range) ? (1:get_nb_scenarios(instance)) : scenario_range
160-
columns = column_generation(
161+
columns, c_low, λ_val = column_generation(
161162
instance;
162163
bounding=bounding,
163164
use_convex_resources=use_convex_resources,
164165
scenario_range=Ω,
165166
silent=silent,
166167
)
167-
_, _, sol = compute_solution_from_selected_columns(
168+
c_upp, _, sol = compute_solution_from_selected_columns(
168169
instance, columns; scenario_range=Ω, silent=silent
169170
)
171+
172+
if close_gap && abs(c_upp - c_low) > 1e-6
173+
(; vehicle_cost, delay_cost, graph, slacks) = instance
174+
intrinsic_delays = instance.intrinsic_delays[:, Ω]
175+
slacks = deepcopy(instance.slacks)
176+
for edge in edges(graph)
177+
slacks[src(edge), dst(edge)] = slacks[src(edge), dst(edge)][Ω]
178+
end
179+
threshold = (c_upp - c_low - vehicle_cost) / delay_cost
180+
additional_paths, _ = stochastic_routing_shortest_path_with_threshold(
181+
graph, slacks, intrinsic_delays, λ_val ./ delay_cost; threshold
182+
)
183+
columns = unique(cat(columns, additional_paths; dims=1))
184+
185+
_, _, sol = compute_solution_from_selected_columns(
186+
instance, columns; scenario_range=Ω, silent=silent
187+
)
188+
end
189+
170190
col_solution = solution_from_paths(sol, instance)
171191
return col_solution
172192
end

src/SubsetSelection/SubsetSelection.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,5 +88,6 @@ function Utils.generate_statistical_model(bench::SubsetSelectionBenchmark; seed=
8888
end
8989

9090
export SubsetSelectionBenchmark
91+
export generate_dataset, generate_maximizer, generate_statistical_model
9192

9293
end

0 commit comments

Comments
 (0)