Skip to content

Commit

Permalink
close gap option in column generation
Browse files Browse the repository at this point in the history
  • Loading branch information
BatyLeo committed Dec 17, 2024
1 parent 5d06cec commit 31a6f9e
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/FixedSizeShortestPath/FixedSizeShortestPath.jl
Original file line number Diff line number Diff line change
Expand Up @@ -146,5 +146,6 @@ function Utils.generate_statistical_model(bench::FixedSizeShortestPathBenchmark)
end

export FixedSizeShortestPathBenchmark
export generate_dataset, generate_maximizer, generate_statistical_model

end
1 change: 1 addition & 0 deletions src/PortfolioOptimization/PortfolioOptimization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -124,5 +124,6 @@ function Utils.generate_statistical_model(bench::PortfolioOptimizationBenchmark)
end

export PortfolioOptimizationBenchmark
export generate_dataset, generate_maximizer, generate_statistical_model

end
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,22 @@ function Utils.generate_dataset(
]
end

"""
$TYPEDSIGNATURES
"""
function Utils.generate_maximizer(bench::StochasticVehicleSchedulingBenchmark)
return vsp_maximizer
end

"""
$TYPEDSIGNATURES
"""
function Utils.generate_statistical_model(bench::StochasticVehicleSchedulingBenchmark)
return Chain(Dense(20 => 1; bias=false), vec)
end

export StochasticVehicleSchedulingBenchmark

export generate_dataset, generate_maximizer, generate_statistical_model
export compact_linearized_mip,
compact_mip, column_generation_algorithm, evaluate_solution, is_feasible

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ function column_generation(

c_low = objective_value(model)
columns = unique(cat(initial_paths, new_paths; dims=1))
return columns
return columns, c_low, value.(λ)
end

"""
Expand Down Expand Up @@ -155,18 +155,38 @@ function column_generation_algorithm(
bounding=true,
use_convex_resources=true,
silent=true,
close_gap=false,
)
Ω = isnothing(scenario_range) ? (1:get_nb_scenarios(instance)) : scenario_range
columns = column_generation(
columns, c_low, λ_val = column_generation(
instance;
bounding=bounding,
use_convex_resources=use_convex_resources,
scenario_range=Ω,
silent=silent,
)
_, _, sol = compute_solution_from_selected_columns(
c_upp, _, sol = compute_solution_from_selected_columns(
instance, columns; scenario_range=Ω, silent=silent
)

if close_gap && abs(c_upp - c_low) > 1e-6
(; vehicle_cost, delay_cost, graph, slacks) = instance
intrinsic_delays = instance.intrinsic_delays[:, Ω]
slacks = deepcopy(instance.slacks)
for edge in edges(graph)
slacks[src(edge), dst(edge)] = slacks[src(edge), dst(edge)][Ω]
end
threshold = (c_upp - c_low - vehicle_cost) / delay_cost
additional_paths, _ = stochastic_routing_shortest_path_with_threshold(
graph, slacks, intrinsic_delays, λ_val ./ delay_cost; threshold
)
columns = unique(cat(columns, additional_paths; dims=1))

_, _, sol = compute_solution_from_selected_columns(
instance, columns; scenario_range=Ω, silent=silent
)
end

col_solution = solution_from_paths(sol, instance)
return col_solution
end
1 change: 1 addition & 0 deletions src/SubsetSelection/SubsetSelection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,6 @@ function Utils.generate_statistical_model(bench::SubsetSelectionBenchmark; seed=
end

export SubsetSelectionBenchmark
export generate_dataset, generate_maximizer, generate_statistical_model

end

0 comments on commit 31a6f9e

Please sign in to comment.