Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERROR: KeyError: key MathOptInterface.FEASIBILITY_SENSE not found #242

Closed
freemin7 opened this issue May 22, 2024 · 3 comments · Fixed by #253
Closed

ERROR: KeyError: key MathOptInterface.FEASIBILITY_SENSE not found #242

freemin7 opened this issue May 22, 2024 · 3 comments · Fixed by #253
Labels

Comments

@freemin7
Copy link

I have not narrowed this down to a minimal example yet.

using JuMP, SCIP

n = 8

mmm = [
[
1 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0;
],
[
0 0 0 0 0 0 0 0;
0 1 0 0 0 0 0 0;
0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0;
],
[
0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0;
0 0 1 0 0 0 0 0;
0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0;
],
[
0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0;
0 0 0 1 0 0 0 0;
0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0;
],
[
0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0;
0 0 0 0 1 0 0 0;
0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0;
],
[
0 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 0 0 0 0 0;
0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0;
],
[
0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0;
0 0 0 0 1 0 0 0;
0 0 0 0 0 1 0 0;
0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0;
],
[
0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0;
0 0 0 0 0 0 1 0;
0 0 0 0 0 0 0 1;
0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0;
]
];

lmmm = length(mmm)

#m = Model(SCIP.Optimizer);

using JuMP, Alpine, Ipopt, HiGHS, Juniper
ipopt = optimizer_with_attributes(Ipopt.Optimizer, "print_level" => 0)
highs = optimizer_with_attributes(HiGHS.Optimizer, "output_flag" => false)
juniper =  optimizer_with_attributes(
        Juniper.Optimizer,
        MOI.Silent() => true,
        "mip_solver" => highs,
        "nl_solver" => ipopt,
    )

m = Model(
    optimizer_with_attributes(
        Alpine.Optimizer,
        "nlp_solver" => ipopt,
        "mip_solver" => highs,
        "minlp_solver" => juniper
    ),
)

@variable(m,  Mat[1:n,1:n]);
@variable(m,  MatP[1:n,1:n,1:lmmm]);

@variable(m, Spa[1:n,1:n], Bin);
@variable(m, SpaS[1:n,1:n]);
@variable(m, SpaP[1:n,1:n,1:lmmm], Bin);

for l=1:lmmm
    @constraint(m, MatP[:,:,l] .== Mat*mmm[l]*(Mat'))
end

for i=1:n
    for j=1:n
        @constraint(m, SpaS[i,j] == sum([SpaP[i,j,l] for l=1:lmmm]))
        @constraint(m, SpaS[i,j] <= n*n*Spa[i,j])
        @constraint(m, 2 >= Mat[i,j])
        @constraint(m, Mat[i,j] >= -2)
    end
end

@constraint(m, sum(Spa) <= 32)
#@constraint(m, 12 <= sum(Spa))

for i=1:n
    @constraint(m, sum( Mat[i,:].*Mat[i,:] ) == 1)
end

for i=1:n
    for j=(1+i):n
        @constraint(m, sum( Mat[i,:].*Mat[j,:] ) == 0)
    end
end
#=
set_attribute(m, "constraints/countsols/collect", true)
set_attribute(m, "constraints/countsols/sollimit", 1000000)
set_attribute(m, "heuristics/subnlp/freq", -1)
=#

optimize!(m)

for l=1:lmmm
    for i=1:n
        for j=1:n
    @constraint(m, MatP[i,j,l] <= 10000000000*SpaP[i,j,l])
    @constraint(m, -10000000000*SpaP[i,j,l] <= MatP[i,j,l])
        end
    end

    optimize!(m)

    @show value.(Mat)
end

I get this error output:

Warning: -/+Inf bounds detected on at least 1536 variables. Initializing with values -/+1.0e6. This may affect global optimal values and run times.
Automatically turning OFF 'partition_scaling_factor_branch' due to the size of the problem

PROBLEM STATISTICS
  # Variables = 3008
  # Bin-Int Variables = 1472
  # Constraints = 1829
  # NL Constraints = 1444
  # Linear Constraints = 385
  # Detected convex constraints = 0
  # Detected nonlinear terms = 1120
  # Variables involved in nonlinear terms = 64
  # Potential variables for partitioning = 64
SUB-SOLVERS USED BY ALPINE
  MINLP local solver = Juniper
  MIP solver = HiGHS
ALPINE CONFIGURATION
  Alpine version = 0.5.6
  Maximum iterations (bounding MIPs) =  99
  Relative global optimality gap = 0.01%
  Partition scaling factor = 10
  Bound-tightening presolve = true
  Maximum iterations (OBBT) = 25
PRESOLVE 
  Doing local search
ERROR: KeyError: key MathOptInterface.FEASIBILITY_SENSE not found
Stacktrace:
  [1] getindex
    @ ./dict.jl:484 [inlined]
  [2] update_incumbent(m::Alpine.Optimizer, objval::Float64, sol::Vector{Float64})
    @ Alpine ~/.julia/packages/Alpine/2DP5q/src/utility.jl:119
  [3] local_solve(m::Alpine.Optimizer; presolve::Bool)
    @ Alpine ~/.julia/packages/Alpine/2DP5q/src/main_algorithm.jl:483
  [4] local_solve
    @ ~/.julia/packages/Alpine/2DP5q/src/main_algorithm.jl:390 [inlined]
  [5] presolve(m::Alpine.Optimizer)
    @ Alpine ~/.julia/packages/Alpine/2DP5q/src/main_algorithm.jl:231
  [6] optimize!(m::Alpine.Optimizer)
    @ Alpine ~/.julia/packages/Alpine/2DP5q/src/main_algorithm.jl:157
  [7] optimize!
    @ ~/.julia/packages/MathOptInterface/2rAFb/src/Bridges/bridge_optimizer.jl:380 [inlined]
  [8] optimize!
    @ ~/.julia/packages/MathOptInterface/2rAFb/src/MathOptInterface.jl:85 [inlined]
  [9] optimize!(m::MathOptInterface.Utilities.CachingOptimizer{MathOptInterface.Bridges.LazyBridgeOptimizer{Alpine.Optimizer}, MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}})
    @ MathOptInterface.Utilities ~/.julia/packages/MathOptInterface/2rAFb/src/Utilities/cachingoptimizer.jl:316
 [10] optimize!(model::Model; ignore_optimize_hook::Bool, _differentiation_backend::MathOptInterface.Nonlinear.SparseReverseMode, kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ JuMP ~/.julia/packages/JuMP/Gwn88/src/optimizer_interface.jl:457
 [11] optimize!(model::Model)
    @ JuMP ~/.julia/packages/JuMP/Gwn88/src/optimizer_interface.jl:409
 [12] top-level scope
    @ ./REPL[92]:9
@freemin7 freemin7 added the bug label May 22, 2024
@odow
Copy link
Collaborator

odow commented May 22, 2024

I have not narrowed this down to a minimal example yet

You don't have an objective function.

But this is still a bug.

@harshangrjn
Copy link
Collaborator

harshangrjn commented Jun 28, 2024

From a global optimization perspective, a model without an objective is not relevant for Alpine, as it can always be solved to feasibility using any local solver. But, the error message can be better.

@freemin7
Copy link
Author

freemin7 commented Jun 28, 2024

I am not familiar with the code base but in principle i would be highly surprised if Alpine couldn't also help a local solver find solutions faster on difficult feasibility problems by excluding parts of the search space based on relaxations and focusing the non linear solver on regions of suspected feasibility.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants