Skip to content

Commit

Permalink
Fixed bug in storing/restoring storage unit StaticVarConstrUnit (#1133
Browse files Browse the repository at this point in the history
)
  • Loading branch information
rrsadykov authored Feb 21, 2024
1 parent 4944ce0 commit 99c4d3d
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 17 deletions.
5 changes: 3 additions & 2 deletions src/Algorithm/basic/solveipform.jl
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,9 @@ function run!(

optimizer = getoptimizer(spform, optimizer_id)
cbdata = MathProg.PricingCallbackData(spform)
optimizer.user_oracle(cbdata)

TO.@timeit Coluna._to "Pricing callback" begin
optimizer.user_oracle(cbdata)
end
if cbdata.nb_times_dual_bound_set == 0
throw(MissingPricingDualBound())
elseif cbdata.nb_times_dual_bound_set > 1
Expand Down
1 change: 1 addition & 0 deletions src/Algorithm/colgen/default.jl
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,7 @@ function ColGen.insert_columns!(ctx::ColGenContext, phase, columns)
# Then, we add the new columns (i.e. not in the pool).
col_ids = VarId[]
for sol in primal_sols_to_insert
#print(IOContext(stdout, :user_only => true), sol)
col_id = insert_column!(master, sol, "MC")
_set_column_cost!(master, col_id, phase)
push!(col_ids, col_id)
Expand Down
16 changes: 2 additions & 14 deletions src/Algorithm/formstorages.jl
Original file line number Diff line number Diff line change
Expand Up @@ -242,18 +242,6 @@ record_type_from_key(::StaticVarConstrKey) = StaticVarConstrRecord

ClB.storage_unit(::Type{StaticVarConstrUnit}, _) = StaticVarConstrUnit()

# function Base.show(io::IO, record::StaticVarConstrRecord)
# print(io, "[vars:")
# for (id, var) in record.vars
# print(io, " ", MathProg.getuid(id))
# end
# print(io, ", constrs:")
# for (id, constr) in record.constrs
# print(io, " ", MathProg.getuid(id))
# end
# print(io, "]")
# end

function ClB.record(::Type{StaticVarConstrRecord}, id::Int, form::Formulation, unit::StaticVarConstrUnit)
@logmsg LogLevel(-2) string("Storing static vars and consts")
record = StaticVarConstrRecord(Dict{ConstrId,ConstrState}(), Dict{VarId,StaticVarState}())
Expand All @@ -264,7 +252,7 @@ function ClB.record(::Type{StaticVarConstrRecord}, id::Int, form::Formulation, u
end
end
for (id, var) in getvars(form)
if isaStaticDuty(getduty(id)) && isexplicit(form, var) && iscuractive(form, var)
if isaStaticDuty(getduty(id)) && iscuractive(form, var) && (isexplicit(form, var) || isaMasterRepDuty(getduty(id)))
varstate = StaticVarState(
getcurcost(form, var),
getcurlb(form, var),
Expand Down Expand Up @@ -302,7 +290,7 @@ function ClB.restore_from_record!(
end
end
for (id, var) in getvars(form)
if isaStaticDuty(getduty(id)) && isexplicit(form, var)
if isaStaticDuty(getduty(id)) && (isexplicit(form, var) || isaMasterRepDuty(getduty(id)))
@logmsg LogLevel(-4) "Checking " getname(form, var)
if haskey(record.vars, id)
if !iscuractive(form, var)
Expand Down
2 changes: 1 addition & 1 deletion src/MathProg/MathProg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export AbstractFormulation, Formulation, create_formulation!, getvar, getvars,
export Original, DwMaster, BendersMaster, DwSp, BendersSp

# Methods related to duties
export isanArtificialDuty, isaStaticDuty, isaDynamicDuty, isanOriginalRepresentatives
export isanArtificialDuty, isaStaticDuty, isaMasterRepDuty, isaDynamicDuty, isanOriginalRepresentatives

# Types and methods related to variables and constraints
export Variable, Constraint, VarId, ConstrId, VarMembership, ConstrMembership,
Expand Down
5 changes: 5 additions & 0 deletions src/MathProg/duties.jl
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@ function isaStaticDuty(duty::NestedEnum)
duty <= BendSpTechnologicalConstr
end

function isaMasterRepDuty(duty::NestedEnum)
return duty <= MasterRepPricingVar ||
duty <= MasterRepPricingSetupVar
end

function isaDynamicDuty(duty::NestedEnum)
return duty <= MasterCol ||
duty <= MasterBranchOnOrigVarConstr ||
Expand Down

0 comments on commit 99c4d3d

Please sign in to comment.