Alpine+JuMP for nonlinear integer programming problem with user-defined objective function

Hi,

I am trying to use Alpine to solve an integer programming problem with a user-defined nonlinear objective function.

When I run JuMP.optimize!(m) I get the following error.

ERROR: type Symbol has no field head
Stacktrace:
  [1] getproperty(x::Symbol, f::Symbol)
    @ Base .\Base.jl:33
  [2] traverse_expr_linear_to_affine(expr::Symbol, lhscoeffs::Vector{Any}, lhsvars::Vector{Any}, rhs::Float64, bufferVal::Nothing, bufferVar::Nothing, sign::Float64, coef::Float64, level::Int64)
    @ Alpine C:\Users\kjaya\.julia\packages\Alpine\fkUe3\src\nlexpr.jl:351
  [3] traverse_expr_linear_to_affine(expr::Expr, lhscoeffs::Vector{Any}, lhsvars::Vector{Any}, rhs::Float64, bufferVal::Nothing, bufferVar::Nothing, sign::Float64, coef::Float64, level::Int64)
    @ Alpine C:\Users\kjaya\.julia\packages\Alpine\fkUe3\src\nlexpr.jl:369
  [4] traverse_expr_linear_to_affine
    @ C:\Users\kjaya\.julia\packages\Alpine\fkUe3\src\nlexpr.jl:327 [inlined]
  [5] expr_linear_to_affine(expr::Expr)
    @ Alpine C:\Users\kjaya\.julia\packages\Alpine\fkUe3\src\nlexpr.jl:294
  [6] expr_conversion(m::Alpine.Optimizer)
    @ Alpine C:\Users\kjaya\.julia\packages\Alpine\fkUe3\src\nlexpr.jl:83
  [7] process_expr
    @ C:\Users\kjaya\.julia\packages\Alpine\fkUe3\src\nlexpr.jl:10 [inlined]
  [8] load!(m::Alpine.Optimizer)
    @ Alpine C:\Users\kjaya\.julia\packages\Alpine\fkUe3\src\main_algorithm.jl:110
  [9] optimize!(m::Alpine.Optimizer)
    @ Alpine C:\Users\kjaya\.julia\packages\Alpine\fkUe3\src\main_algorithm.jl:151
 [10] optimize!
    @ C:\Users\kjaya\.julia\packages\MathOptInterface\NCblk\src\Bridges\bridge_optimizer.jl:376 [inlined]   
 [11] optimize!
    @ C:\Users\kjaya\.julia\packages\MathOptInterface\NCblk\src\MathOptInterface.jl:83 [inlined]
 [12] optimize!(m::MathOptInterface.Utilities.CachingOptimizer{MathOptInterface.Bridges.LazyBridgeOptimizer{Alpine.Optimizer}, MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}})    @ MathOptInterface.Utilities C:\Users\kjaya\.julia\packages\MathOptInterface\NCblk\src\Utilities\cachingoptimizer.jl:316
 [13] optimize!(model::Model; ignore_optimize_hook::Bool, _differentiation_backend::MathOptInterface.Nonlinear.SparseReverseMode, kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ JuMP C:\Users\kjaya\.julia\packages\JuMP\yYfHy\src\optimizer_interface.jl:480

Here’s a minimal working example:

using JuMP, Alpine, HiGHS, Ipopt, Juniper, LinearAlgebra, MatrixEquations

# Setting up the solver
nlp_solver = optimizer_with_attributes(Ipopt.Optimizer, MOI.Silent() => true, "sb" => "yes", "max_iter" => Int(1E4), );
mip_solver = JuMP.optimizer_with_attributes(HiGHS.Optimizer, "presolve" => "on", "log_to_console" => false, );
minlp_solver = optimizer_with_attributes(Juniper.Optimizer, MOI.Silent() => true, "mip_solver" => mip_solver, "nl_solver" => nlp_solver, );
const alpine = JuMP.optimizer_with_attributes(Alpine.Optimizer, "minlp_solver" => minlp_solver, "nlp_solver" => nlp_solver, "mip_solver" => mip_solver, "presolve_bt" => true, "apply_partitioning" => true, "partition_scaling_factor" => 10, );

m = JuMP.Model(alpine)

@variable(m, x[1:3], Bin)

function f_objective(x::T...) where {T<:Real}
    return sum([x...])/x[3]
end
register(m, :f_objective, 3, f_objective; autodiff = true)

@NLobjective(m, Min, f_objective(x...))

JuMP.optimize!(m)

I thought we fixed this: ERROR: type Symbol has no field head · Issue #223 · lanl-ansi/Alpine.jl · GitHub

What is import Pkg; Pkg.status()?

Edit: never mind. I can reproduce this. I’ve opened an issue: ERROR: type Symbol has no field head · Issue #226 · lanl-ansi/Alpine.jl · GitHub

For now, I would just use Juniper as a MINLP solver.

Thanks! :slight_smile: