Skip to content

Commit

Permalink
Fix feasibility pump with ScalarNonlinearFunction constraints (#264)
Browse files Browse the repository at this point in the history
  • Loading branch information
odow authored Jan 29, 2024
1 parent b02b5e4 commit 3d6dd7c
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/filter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,12 @@ function MOI.get(f::LinearFilter, attr::MOI.ListOfModelAttributesSet)
end
end
function MOI.get(f::LinearFilter, attr::MOI.ListOfConstraintTypesPresent)
return filter(MOI.get(f.inner, attr)) do FS
F = FS[1]
return !(
F <: MOI.ScalarQuadraticFunction ||
F <: MOI.VectorQuadraticFunction
return filter(MOI.get(f.inner, attr)) do (F, _)
return (
F <: MOI.VariableIndex ||
F <: MOI.ScalarAffineFunction ||
F <: MOI.VectorOfVariables ||
F <: MOI.VectorAffineFunction
)
end
end
Expand Down
32 changes: 32 additions & 0 deletions test/fpump.jl
Original file line number Diff line number Diff line change
Expand Up @@ -292,4 +292,36 @@ include("basic/gamsworld.jl")
end
@test JuMP.objective_value(m) 0.0
end

@testset "FP: Issue 263: FPump with ScalarNonlinearFunction" begin
println("==================================")
println("FP: Issue 263: FPump with ScalarNonlinearFunction")
println("==================================")
ipopt_solver = JuMP.optimizer_with_attributes(
Ipopt.Optimizer,
"print_level" => 0,
"sb" => "yes",
"max_iter" => 50000,
)
highs_solver = JuMP.optimizer_with_attributes(
HiGHS.Optimizer,
"output_flag" => false,
)
juniper_solver = JuMP.optimizer_with_attributes(
Juniper.Optimizer,
"nl_solver" => ipopt_solver,
"mip_solver" => highs_solver,
"log_levels" => [],
)
m = Model(juniper_solver)
@variable(m, x[1:3], Int)
@variable(m, y)
@constraint(m, x[1] * x[2] * x[3] * y >= 5)
optimize!(m)
for i in 1:3
xval = JuMP.value(x[i])
@test isapprox(round(xval) - xval, 0; atol = sol_atol)
end
@test JuMP.objective_value(m) 0.0
end
end

0 comments on commit 3d6dd7c

Please sign in to comment.