From a1cf5d87b0980eb471754be79f253c59fdf38350 Mon Sep 17 00:00:00 2001 From: Guillaume Marques Date: Wed, 12 Apr 2023 09:47:40 +0200 Subject: [PATCH] check if primal sol feasible and integral --- src/Algorithm/colgen/default.jl | 11 +++++++++-- src/Algorithm/colgen/printer.jl | 10 +++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/Algorithm/colgen/default.jl b/src/Algorithm/colgen/default.jl index 26380e84e..0e6a0be16 100644 --- a/src/Algorithm/colgen/default.jl +++ b/src/Algorithm/colgen/default.jl @@ -17,7 +17,7 @@ mutable struct ColGenContext <: ColGen.AbstractColGenContext opt_rtol::Float64 opt_atol::Float64 - incumbent_primal_solution::PrimalSolution + incumbent_primal_solution::Union{Nothing,PrimalSolution} # # Information to solve the master # master_solve_alg @@ -39,7 +39,8 @@ mutable struct ColGenContext <: ColGen.AbstractColGenContext alg.throw_column_already_inserted_warning, alg.max_nb_iterations, alg.opt_rtol, - alg.opt_atol + alg.opt_atol, + nothing ) end end @@ -219,10 +220,16 @@ function ColGen.update_master_constrs_dual_vals!(ctx::ColGenContext, phase, refo end function ColGen.check_primal_ip_feasibility(master_lp_primal_sol, ::ColGenContext, phase, reform) + # Check if feasible. + if contains(master_lp_primal_sol, varid -> isanArtificialDuty(getduty(varid))) + return nothing + end + # Check if integral. primal_sol_is_integer = MathProg.proj_cols_is_integer(master_lp_primal_sol) if !primal_sol_is_integer return nothing end + # Returns projection on original variables if feasible and integral. return MathProg.proj_cols_on_rep(master_lp_primal_sol) end diff --git a/src/Algorithm/colgen/printer.jl b/src/Algorithm/colgen/printer.jl index ee45f9971..66e49f453 100644 --- a/src/Algorithm/colgen/printer.jl +++ b/src/Algorithm/colgen/printer.jl @@ -76,10 +76,18 @@ end ColGen.before_colgen_iteration(ctx::ColGenPrinterContext, phase) = nothing +function _get_inc_pb(ctx::ColGenPrinterContext) + sol = ctx.inner.incumbent_primal_solution + if isnothing(sol) + return Inf + end + return getvalue(sol) +end + function _iter_str(ctx::ColGenPrinterContext, phase, env, colgen_iteration, colgen_iter_output::ColGen.AbstractColGenIterationOutput) mlp = colgen_iter_output.mlp db = colgen_iter_output.db - pb = 100000 + pb = _get_inc_pb(ctx) phase_string = " " if ctx.phase == 1