Skip to content

Commit

Permalink
do not check master lp solution feasibility in phase 1 of colgen (#842)
Browse files Browse the repository at this point in the history
  • Loading branch information
guimarqu authored Apr 26, 2023
1 parent fcfd847 commit d6ed80f
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 54 deletions.
2 changes: 2 additions & 0 deletions src/Algorithm/colgen/default.jl
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,8 @@ function _violates_essential_cuts!(master, master_lp_primal_sol, env)
return cutcb_output.nb_cuts_added > 0
end

ColGen.check_primal_ip_feasibility!(_, ctx::ColGenContext, ::ColGenPhase1, _, _) = nothing, false

function ColGen.check_primal_ip_feasibility!(master_lp_primal_sol, ctx::ColGenContext, phase, reform, env)
# Check if feasible.
if contains(master_lp_primal_sol, varid -> isanArtificialDuty(getduty(varid)))
Expand Down
92 changes: 46 additions & 46 deletions src/Algorithm/colgenstabilization.jl
Original file line number Diff line number Diff line change
@@ -1,49 +1,49 @@
# mutable struct ColGenStabilizationUnit <: AbstractNewStorageUnit
# basealpha::Float64 # "global" alpha parameter
# curalpha::Float64 # alpha parameter during the current misprice sequence
# nb_misprices::Int64 # number of misprices during the current misprice sequence
# pseudo_dual_bound::DualBound # pseudo dual bound, may be non-valid, f.e. when the pricing problem solved heuristically
# valid_dual_bound::DualBound # valid dual bound
# stabcenter::Union{Nothing,DualSolution} # current stability center, correspond to cur_dual_bound
# newstabcenter::Union{Nothing,DualSolution} # to keep temporarily stab. center after update
# basestabcenter::Union{Nothing,DualSolution} # stability center, corresponding to valid_dual_bound
# end

# function ClB.new_storage_unit(::Type{ColGenStabilizationUnit}, master::Formulation{DwMaster})
# return ColGenStabilizationUnit(
# 0.5, 0.0, 0, DualBound(master), DualBound(master), nothing, nothing, nothing
# )
# end

# mutable struct ColGenStabRecord <: AbstractNewRecord
# alpha::Float64
# dualbound::DualBound
# stabcenter::Union{Nothing,DualSolution}
# end

# struct ColGenStabKey <: AbstractStorageUnitKey end

# key_from_storage_unit_type(::Type{ColGenStabilizationUnit}) = ColGenStabKey()
# record_type_from_key(::ColGenStabKey) = ColGenStabRecord

# function ClB.new_record(::Type{ColGenStabRecord}, id::Int, form::Formulation, unit::ColGenStabilizationUnit)
# alpha = unit.basealpha < 0.5 ? 0.5 : unit.basealpha
# return ColGenStabRecord(alpha, unit.valid_dual_bound, unit.basestabcenter)
# end

# ClB.record_type(::Type{ColGenStabilizationUnit}) = ColGenStabRecord
# ClB.storage_unit_type(::Type{ColGenStabRecord}) = ColGenStabilizationUnit



# function ClB.restore_from_record!(
# ::Formulation, unit::ColGenStabilizationUnit, state::ColGenStabRecord
# )
# unit.basealpha = state.alpha
# unit.valid_dual_bound = state.dualbound
# unit.basestabcenter = state.stabcenter
# return
# end
mutable struct ColGenStabilizationUnit <: AbstractNewStorageUnit
basealpha::Float64 # "global" alpha parameter
curalpha::Float64 # alpha parameter during the current misprice sequence
nb_misprices::Int64 # number of misprices during the current misprice sequence
pseudo_dual_bound::DualBound # pseudo dual bound, may be non-valid, f.e. when the pricing problem solved heuristically
valid_dual_bound::DualBound # valid dual bound
stabcenter::Union{Nothing,DualSolution} # current stability center, correspond to cur_dual_bound
newstabcenter::Union{Nothing,DualSolution} # to keep temporarily stab. center after update
basestabcenter::Union{Nothing,DualSolution} # stability center, corresponding to valid_dual_bound
end

function ClB.new_storage_unit(::Type{ColGenStabilizationUnit}, master::Formulation{DwMaster})
return ColGenStabilizationUnit(
0.5, 0.0, 0, DualBound(master), DualBound(master), nothing, nothing, nothing
)
end

mutable struct ColGenStabRecord <: AbstractNewRecord
alpha::Float64
dualbound::DualBound
stabcenter::Union{Nothing,DualSolution}
end

struct ColGenStabKey <: AbstractStorageUnitKey end

key_from_storage_unit_type(::Type{ColGenStabilizationUnit}) = ColGenStabKey()
record_type_from_key(::ColGenStabKey) = ColGenStabRecord

function ClB.new_record(::Type{ColGenStabRecord}, id::Int, form::Formulation, unit::ColGenStabilizationUnit)
alpha = unit.basealpha < 0.5 ? 0.5 : unit.basealpha
return ColGenStabRecord(alpha, unit.valid_dual_bound, unit.basestabcenter)
end

ClB.record_type(::Type{ColGenStabilizationUnit}) = ColGenStabRecord
ClB.storage_unit_type(::Type{ColGenStabRecord}) = ColGenStabilizationUnit



function ClB.restore_from_record!(
::Formulation, unit::ColGenStabilizationUnit, state::ColGenStabRecord
)
unit.basealpha = state.alpha
unit.valid_dual_bound = state.dualbound
unit.basestabcenter = state.stabcenter
return
end

# # function ColGenStabilizationUnit(master::Formulation)
# # return ColGenStabilizationUnit(
Expand Down
3 changes: 0 additions & 3 deletions src/ColGen/interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -356,9 +356,6 @@ function run_colgen_iteration!(context, phase, env, ip_primal_sol)
sp_db = get_dual_bound(pricing_result)
if !isnothing(sp_db)
sps_db[sp_id] = sp_db
# else
# sps_db[sp_id] = 0
# end
end

sp_to_solve_it = pricing_strategy_iterate(pricing_strategy, state)
Expand Down
10 changes: 5 additions & 5 deletions test/e2e_extra/gap/gap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function gap_node_limit()
@test JuMP.objective_bound(model) 1547.3889
@test JuMP.termination_status(model) == MathOptInterface.OTHER_LIMIT
end
register!(e2e_extra_tests, "gap", gap_node_limit; x = true)
register!(e2e_extra_tests, "gap", gap_node_limit)

function gap_colgen_max_nb_iterations()
data = ClD.GeneralizedAssignment.data("smallgap3.txt")
Expand All @@ -64,7 +64,7 @@ function gap_colgen_max_nb_iterations()
@test JuMP.termination_status(problem) == MOI.OPTIMAL # Problem with final dual bound ?
@test ClD.GeneralizedAssignment.print_and_check_sol(data, problem, x)
end
register!(e2e_extra_tests, "gap", gap_colgen_max_nb_iterations; x = true)
register!(e2e_extra_tests, "gap", gap_colgen_max_nb_iterations)

function gap_pure_master_variables()
data = ClD.GeneralizedAssignment.data("smallgap3.txt")
Expand Down Expand Up @@ -96,7 +96,7 @@ function gap_maximisation_objective_function()
@test JuMP.termination_status(problem) == MOI.OPTIMAL
@test abs(JuMP.objective_value(problem) - 580.0) <= 0.00001
end
register!(e2e_extra_tests, "gap", gap_maximisation_objective_function; x = true)
register!(e2e_extra_tests, "gap", gap_maximisation_objective_function)

function gap_infeasible_master()
data = ClD.GeneralizedAssignment.data("master_infeas.txt")
Expand Down Expand Up @@ -167,7 +167,7 @@ function gap_with_all_phases_in_colgen()
JuMP.optimize!(problem)
@test abs(JuMP.objective_value(problem) - 31895.0) <= 0.00001
end
register!(e2e_extra_tests, "gap", gap_with_all_phases_in_colgen; x = true)
register!(e2e_extra_tests, "gap", gap_with_all_phases_in_colgen)

function gap_with_max_obj_pure_master_vars_and_stab()
data = ClD.GeneralizedAssignment.data("gapC-5-100.txt")
Expand All @@ -190,7 +190,7 @@ function gap_with_max_obj_pure_master_vars_and_stab()
@test JuMP.objective_value(model) 3520.1
@test JuMP.termination_status(model) == MOI.OPTIMAL
end
register!(e2e_extra_tests, "gap", gap_with_max_obj_pure_master_vars_and_stab; x = true)
register!(e2e_extra_tests, "gap", gap_with_max_obj_pure_master_vars_and_stab)

function gap_with_no_solver()
data = ClD.GeneralizedAssignment.data("play2.txt")
Expand Down

0 comments on commit d6ed80f

Please sign in to comment.