From 5382120f0ef66b3009b96a88b71bb2d5622a5635 Mon Sep 17 00:00:00 2001 From: lbonaldo Date: Mon, 11 Mar 2024 15:11:13 -0400 Subject: [PATCH] Fix write_status with UCommit=1 and ShadowPrices --- src/model/solve_model.jl | 8 -------- src/write_outputs/write_outputs.jl | 10 ++++++++++ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/model/solve_model.jl b/src/model/solve_model.jl index 53f385c38f..2693cea662 100644 --- a/src/model/solve_model.jl +++ b/src/model/solve_model.jl @@ -70,14 +70,6 @@ function solve_model(EP::Model, setup::Dict) println("MILP solved for primal") end - if !has_duals(EP) && setup["WriteShadowPrices"] == 1 - # function to fix integers and linearize problem - fix_integers(EP) - # re-solve statement for LP solution - println("Solving LP solution for duals") - optimize!(EP) - end - ## Record solver time solver_time = time() - solver_start_time elseif setup["ComputeConflicts"]==0 diff --git a/src/write_outputs/write_outputs.jl b/src/write_outputs/write_outputs.jl index 46d5838246..8e88ec0dc1 100644 --- a/src/write_outputs/write_outputs.jl +++ b/src/write_outputs/write_outputs.jl @@ -47,6 +47,16 @@ function write_outputs(EP::Model, path::AbstractString, setup::Dict, inputs::Dic output_settings_d["WriteStatus"] && write_status(path, inputs, setup, EP) + # linearize and re-solve model if duals are not available but ShadowPrices are requested + if !has_duals(EP) && setup["WriteShadowPrices"] == 1 + # function to fix integers and linearize problem + fix_integers(EP) + # re-solve statement for LP solution + println("Solving LP solution for duals") + set_silent(EP) + optimize!(EP) + end + if output_settings_d["WriteCosts"] elapsed_time_costs = @elapsed write_costs(path, inputs, setup, EP) println("Time elapsed for writing costs is")