From 3ec9885b5f26011d4ae2e711af79fd8f857e95d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Legat?= Date: Wed, 8 Oct 2025 21:54:16 +0200 Subject: [PATCH] Allocation-free range --- src/iis.jl | 7 ++++--- src/solver.jl | 18 +++++++++++------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/iis.jl b/src/iis.jl index 90b1245..919c25c 100644 --- a/src/iis.jl +++ b/src/iis.jl @@ -53,7 +53,7 @@ Base.@kwdef mutable struct Optimizer # # iis attributes time_limit::Float64 = Inf - verbose::Bool = false + verbose::Bool = true skip_feasibility_check::Bool = false stop_if_infeasible_bounds::Bool = true stop_if_infeasible_ranges::Bool = true @@ -258,7 +258,7 @@ function MOI.compute_conflict!(optimizer::Optimizer) println("Starting bound analysis.") end bounds_consistent, variables, lb_con, ub_con = - _bound_infeasibility!(optimizer, T) + @time _bound_infeasibility!(optimizer, T) bound_infeasibilities = length(optimizer.results) if optimizer.verbose println( @@ -281,7 +281,7 @@ function MOI.compute_conflict!(optimizer::Optimizer) println("Starting range analysis.") end range_consistent = - _range_infeasibility!(optimizer, T, variables, lb_con, ub_con) + @time _range_infeasibility!(optimizer, T, variables, lb_con, ub_con) range_infeasibilities = length(optimizer.results) - bound_infeasibilities if optimizer.verbose println( @@ -291,6 +291,7 @@ function MOI.compute_conflict!(optimizer::Optimizer) if length(optimizer.results) > 0 optimizer.status = MOI.CONFLICT_FOUND end + return if (!range_consistent && optimizer.stop_if_infeasible_ranges) || !_in_time(optimizer) diff --git a/src/solver.jl b/src/solver.jl index 952a11e..57503cc 100644 --- a/src/solver.jl +++ b/src/solver.jl @@ -84,24 +84,30 @@ function _elastic_filter(optimizer::Optimizer) de_elastisized = [] - changed_obj = false - # all (affine, non-bound) constraints are relaxed at this point - # we will try to set positive slacks to zero until the model infeasible - # the constraints of the fixed slacks are a IIS candidate + # we will try to set positive slacks to zero until the model becomes + # infeasible. The constraints of the fixed slacks then form a IIS candidate. for i in 1:max_iterations if !_in_time(optimizer) return nothing end + if optimizer.verbose + println("Solving iteration $i...") + end MOI.optimize!(model) + if optimizer.verbose + println("Iteration $i solved.") + end status = MOI.get(model, MOI.TerminationStatus()) if status in ( # possibily primal unbounded statuses MOI.INFEASIBLE_OR_UNBOUNDED, MOI.DUAL_INFEASIBLE, MOI.ALMOST_DUAL_INFEASIBLE, ) - # + if optimizer.verbose + @warn("Termination status is $status") + end end if status in (MOI.INFEASIBLE, MOI.ALMOST_INFEASIBLE, MOI.LOCALLY_INFEASIBLE) @@ -143,8 +149,6 @@ function _elastic_filter(optimizer::Optimizer) # consider deleting all no iis constraints # be careful with intervals - obj_type = MOI.get(model, MOI.ObjectiveFunctionType()) - obj_func = MOI.get(model, MOI.ObjectiveFunction{obj_type}()) obj_sense = MOI.get(model, MOI.ObjectiveSense()) candidates = MOI.ConstraintIndex[]