# NLP: Attribute ScalarNonlinearFunction is not supported by the model

**URL:** <https://discourse.julialang.org/t/nlp-attribute-scalarnonlinearfunction-is-not-supported-by-the-model/110444>\
**Category:** Optimization (Mathematical)\
**Tags:** jump, nlp\
**Created:** [February 20, 2024, 9:04am UTC](https://discourse.julialang.org/t/nlp-attribute-scalarnonlinearfunction-is-not-supported-by-the-model/110444 "2024-02-20T09:04:53Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shuhua](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/shuhua/32/27618_2.png) [@Shuhua](https://discourse.julialang.org/u/Shuhua)\
**Post date:** [February 20, 2024, 9:04am UTC](https://discourse.julialang.org/t/nlp-attribute-scalarnonlinearfunction-is-not-supported-by-the-model/110444/1 "2024-02-20T09:04:53Z")

</div>

Hi, I am working on an optimization problem as described in the [PDF document](https://github.com/ShuhuaGao/ev-opt/blob/main/doc/problem-formulation.pdf) in the GitHub repository. The nonlinearity is introduced mainly the equation `G` in (16).

I implemented the model following closely the PDF description with JuMP. The code and example data are all provided in the GitHub repository. Since there is a nonlinear term in the objective (10), I chosen the `SCIP` solver and also the `Alpine` solver. Both reported the error below:

```julia
ERROR: MathOptInterface.UnsupportedAttribute{MathOptInterface.ObjectiveFunction{MathOptInterface.ScalarNonlinearFunction}}: 
Attribute MathOptInterface.ObjectiveFunction{MathOptInterface.ScalarNonlinearFunction}() is not supported by the model.

```

After Googling, a suggestion is to replace the nonlinear term in the objective with an auxiliary variable (see `f_obj_aux` in the code [nlp.jl](https://github.com/ShuhuaGao/ev-opt/blob/main/nlp.jl)), and put that term into the constraints. However, I still got a similar error:

```julia
ERROR: MathOptInterface.UnsupportedConstraint{MathOptInterface.ScalarNonlinearFunction, MathOptInterface.LessThan{Float64}}: `MathOptInterface.ScalarNonlinearFunction`-in-`MathOptInterface.LessThan{Float64}` constraint is not supported by the model.

```

- Is it due to the solver? Perhaps there exists some solver capable of handling it.
- Shall I reformulate the problem to make it a better-posed one? But how. This problem may be probably turned into a recognized form but I don’t know. I am no expert in optimization.  
Any suggestion is appreciated.

---

<div class="post-metadata">

**Author:** ![baggepinnen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baggepinnen/32/693_2.png) [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)\
**Post date:** [February 20, 2024, 9:13am UTC](https://discourse.julialang.org/t/nlp-attribute-scalarnonlinearfunction-is-not-supported-by-the-model/110444/2 "2024-02-20T09:13:56Z")

</div>

You could try `Ipopt.Optimizer`, it should handle scalar nonlinear functions.

---

<div class="post-metadata">

**Author:** ![Shuhua](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/shuhua/32/27618_2.png) [@Shuhua](https://discourse.julialang.org/u/Shuhua)\
**Post date:** [February 20, 2024, 9:24am UTC](https://discourse.julialang.org/t/nlp-attribute-scalarnonlinearfunction-is-not-supported-by-the-model/110444/3 "2024-02-20T09:24:12Z")

</div>

Thanks. But I want to get the global optimizer. 🤣

---

<div class="post-metadata">

**Author:** ![blob](https://avatars.discourse-cdn.com/v4/letter/b/ebca7d/32.png) [@blob](https://discourse.julialang.org/u/blob)\
**Post date:** [February 20, 2024, 10:07am UTC](https://discourse.julialang.org/t/nlp-attribute-scalarnonlinearfunction-is-not-supported-by-the-model/110444/4 "2024-02-20T10:07:11Z")

</div>

It seems that SCIP cannot handle [either nonlinear objectives or nonlinear constraints](https://github.com/scipopt/SCIP.jl?tab=readme-ov-file#mathoptinterface-api). Maybe try replacing it with a different solver (some suggestions given [here](https://discourse.julialang.org/t/alpine-jump-gives-error-for-quadratic-functions/70321/5))?

---

<div class="post-metadata">

**Author:** ![Shuhua](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/shuhua/32/27618_2.png) [@Shuhua](https://discourse.julialang.org/u/Shuhua)\
**Post date:** [February 20, 2024, 12:56pm UTC](https://discourse.julialang.org/t/nlp-attribute-scalarnonlinearfunction-is-not-supported-by-the-model/110444/5 "2024-02-20T12:56:28Z")

</div>

More tests.  
None of `SCIP`, `Alpine` and `AMPLWriter` (with backends Couenne and SHOT) worked. All have the same error: they do not support objective functions involving `MathOptInterface.ScalarNonlinearFunction`.

Only `Ipopt` executed with no such errors. Are the above global NLP solvers limited?

---

<div class="post-metadata">

**Author:** ![blob](https://avatars.discourse-cdn.com/v4/letter/b/ebca7d/32.png) [@blob](https://discourse.julialang.org/u/blob)\
**Post date:** [February 20, 2024, 1:13pm UTC](https://discourse.julialang.org/t/nlp-attribute-scalarnonlinearfunction-is-not-supported-by-the-model/110444/6 "2024-02-20T13:13:26Z")

</div>

Global optimization is not easy, so yes, the choice is limited. You can maybe try [KNITRO](https://github.com/jump-dev/KNITRO.jl?tab=readme-ov-file#mathoptinterface-api)+Alpine if you can get the [license to it](https://github.com/jump-dev/KNITRO.jl?tab=readme-ov-file#mathoptinterface-api).

---

<div class="post-metadata">

**Author:** ![Shuhua](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/shuhua/32/27618_2.png) [@Shuhua](https://discourse.julialang.org/u/Shuhua)\
**Post date:** [February 20, 2024, 1:21pm UTC](https://discourse.julialang.org/t/nlp-attribute-scalarnonlinearfunction-is-not-supported-by-the-model/110444/7 "2024-02-20T13:21:45Z")

</div>

A much smaller example that shows the same error: `The solver does not support an objective function of type MathOptInterface.ScalarNonlinearFunction.`

```julia
using JuMP, SCIP, Ipopt, EAGO
using Alpine, HiGHS
using AmplNLWriter, Couenne_jll, SHOT_jll

function solve_model()
    model = JuMP.Model(SCIP.Optimizer)
    # model = JuMP.Model(() -> AmplNLWriter.Optimizer(Couenne_jll.amplexe)) # same error
    @variable(model, -2 <= x[1:4] <= 2)
    @constraint(model, x[1] * x[2] + x[3] <= 3)
    @constraint(model, -3 <= x[2] - 3*x[4] <= 2)
    @objective(model, Min, (x[1] + x[2]*x[4]) / (x[1]^2 + x[2]*x[3] - 2*x[4] + 100))
    optimize!(model)
    @show termination_status(model)
end

solve_model()

```

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [February 20, 2024, 6:32pm UTC](https://discourse.julialang.org/t/nlp-attribute-scalarnonlinearfunction-is-not-supported-by-the-model/110444/8 "2024-02-20T18:32:44Z")

</div>

The underlying cause is [ANN: JuMP v1.15 is released](https://discourse.julialang.org/t/ann-jump-v1-15-is-released/103875)

Some solvers have not been updated. So for SCIP and Alpine, you’ll need to use  
`@NLobjective` instead of `@objective`.

AmplNLWriter with Couenne etc will work if you update your packages to AmplNLWriter v1.2.0.

---

<div class="post-metadata">

**Author:** ![harsha.nagarajan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/harsha.nagarajan/32/29776_2.png) [@harsha.nagarajan](https://discourse.julialang.org/u/harsha.nagarajan)\
**Post date:** [February 20, 2024, 8:34pm UTC](https://discourse.julialang.org/t/nlp-attribute-scalarnonlinearfunction-is-not-supported-by-the-model/110444/9 "2024-02-20T20:34:27Z")

</div>

@Shuhua,

The main issue lies with the objective function, which is a fractional function, and the second constraint, which is a two-sided constraint. Unfortunately, Alpine does not support either of these.

Here is a reformulated version in polynomial form, which seems to run fine without any issues on Alpine. The global optimal value for this objective is `-0.0267602457`. I chose arbitrary bounds for the variable `t`, but you could choose something better based on your specific problem.

I have kept the `mip_solver` as CPLEX, but you could change `"mip_solver" => mip_solver` to `"mip_solver" => mip2_solver` while initializing Alpine solver, if you prefer an open-source solver like Pavito+HiGHS. However, numerically, CPLEX/Gurobi seemed to be more stable and faster.

Let me know if you still see any issues.

```julia
using Alpine
using JuMP
using Ipopt
using CPLEX
using HiGHS
using Pavito

function get_cplex()
    return optimizer_with_attributes(
        CPLEX.Optimizer,
        MOI.Silent() => true,
        "CPX_PARAM_PREIND" => 1,
    )
end

function get_highs()
    return JuMP.optimizer_with_attributes(
        HiGHS.Optimizer,
        "presolve" => "on",
        "log_to_console" => false,
    )
end

function get_ipopt()
    return optimizer_with_attributes(
        Ipopt.Optimizer,
        MOI.Silent() => true,
        "sb" => "yes",
        "max_iter" => Int(1E4),
    )
end

function get_pavito(mip_solver, cont_solver)
    return optimizer_with_attributes(
        Pavito.Optimizer,
        MOI.Silent() => true,
        "mip_solver" => mip_solver,
        "cont_solver" => cont_solver,
        "mip_solver_drives" => false,
    )
end

nlp_solver = get_ipopt() # local continuous solver
mip_solver = get_cplex() # convex mip solver
mip2_solver = get_pavito(mip_solver, nlp_solver)

const alpine = JuMP.optimizer_with_attributes(
    Alpine.Optimizer,
    "nlp_solver" => nlp_solver,
    "mip_solver" => mip_solver,
    "presolve_bt" => true,
    "apply_partitioning" => true,
    "partition_scaling_factor" => 10,
)

function nlp_test(; solver = nothing)
    m = JuMP.Model(solver)

    @variable(m, -2 <= x[1:4] <= 2)
    @variable(m, -1E3 <= t <= 1E3)
    @constraint(m, x[1] * x[2] + x[3] <= 3)
    @constraint(m, x[2] - 3*x[4] <= 2)
    @constraint(m, x[2] - 3*x[4] >= -3)
    @NLconstraint(m, t * (x[1]^2 + x[2]*x[3] - 2*x[4] + 100) == x[1] + (x[2]*x[4]))
    @objective(m, Min, t)
    
    # Original fractional objective
    # @NLobjective(m, Min, (x[1] + x[2]*x[4]) / (x[1]^2 + x[2]*x[3] - 2*x[4] + 100))
    return m
end

m = nlp_test(solver = alpine)

JuMP.optimize!(m)

```

---

<div class="post-metadata">

**Author:** ![Shuhua](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/shuhua/32/27618_2.png) [@Shuhua](https://discourse.julialang.org/u/Shuhua)\
**Post date:** [February 21, 2024, 2:56am UTC](https://discourse.julialang.org/t/nlp-attribute-scalarnonlinearfunction-is-not-supported-by-the-model/110444/10 "2024-02-21T02:56:24Z")

</div>

Thank you. I tried your suggestions with the example on my GitHub.

- It is true that `AmplNLWriter with Couenne etc will work if you update your packages to AmplNLWriter v1.2.0.`.
- It failed even if `use @NLobjective instead of @objective.`. The following error is reported:

```julia
ERROR: Unrecognized function ".*" used in nonlinear expression.

You must register it as a user-defined function before building
the model. 

```

Following the prompts, I did

```julia
register(model, :.*, 2, .*, autodiff=true)
register(model, :.+, 2, .+, autodiff=true)

```

Then, I got another error:

```julia
ERROR: Unexpected array AffExpr[.....] in nonlinear expression. Nonlinear expressions may contain only scalar expressions.
``
The above error happened in the line `@NLObjective`.
```

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [February 21, 2024, 3:00am UTC](https://discourse.julialang.org/t/nlp-attribute-scalarnonlinearfunction-is-not-supported-by-the-model/110444/11 "2024-02-21T03:00:19Z")

</div>

> It failed even if `use @NLobjective instead of @objective.` . The following error is reported:

The legacy nonlinear interface (the `@NL` macros) contain a number of limitations. You cannot use broadcasting or array operations. See:

- [JuMP 1.15.0 is released | JuMP](https://jump.dev/blog/1.15.0-release/)

and the JuMP documentation:

- [Nonlinear Modeling (Legacy) · JuMP](https://jump.dev/JuMP.jl/stable/manual/nlp/#Syntax-notes)

If you can post a small reproducible example like you did above, people may be able to suggest alternative syntax.

---

<div class="post-metadata">

**Author:** ![Shuhua](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/shuhua/32/27618_2.png) [@Shuhua](https://discourse.julialang.org/u/Shuhua)\
**Post date:** [February 21, 2024, 3:03am UTC](https://discourse.julialang.org/t/nlp-attribute-scalarnonlinearfunction-is-not-supported-by-the-model/110444/12 "2024-02-21T03:03:04Z")

</div>

Sorry, but I just edited my previous reply and got a different error.

> If you can post a small reproducible example like you did above, people may be able to suggest alternative syntax.

I will try it. But for now, I can play with Couenne.

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [February 21, 2024, 3:18am UTC](https://discourse.julialang.org/t/nlp-attribute-scalarnonlinearfunction-is-not-supported-by-the-model/110444/13 "2024-02-21T03:18:15Z")

</div>

No, you cannot register the broadcast operators (at one point an error will be thrown saying that the return must be a scalar, but the other error was triggered first).

Nor can you use array operations. _Everything_ must be a scalar expression. So, for example, instead of `sum(x .* y)` you must do `sum(x[i] * y[i] for i in 1:N)`.

This is a major limitation, which is why we rewrote JuMP’s nonlinear interface 😄 Unfortunately, updating some of the solvers like Alpine to use the new interface is non-trivial, which is why they haven’t been updated yet.

> But for now, I can play with Couenne.

👍

---

<div class="post-metadata">

**Author:** ![Stuart\_Rogers](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stuart_rogers/32/10694_2.png) [@Stuart\_Rogers](https://discourse.julialang.org/u/Stuart_Rogers)\
**Post date:** [May 29, 2024, 7:57pm UTC](https://discourse.julialang.org/t/nlp-attribute-scalarnonlinearfunction-is-not-supported-by-the-model/110444/14 "2024-05-29T19:57:51Z")

</div>

I am trying to solve a binary nonlinear program with SCIP. The model is created with JuMP using the code below, but I get the error shown below. I am using Julia v1.10.3 and JuMP v1.22.1.

* * *

```julia
using JuMP
using SCIP

N1 = 5
N = 10
zp = 2
M = zp*N

Br = rand(M,N1)
Bi = rand(M,N1)
s = rand(M,1)

model = Model(SCIP.Optimizer)
@variable(model, y[1:N1], Bin)

@expression(model, yh[n=1:N1], y[n]-.5)
@expression(model, spec_r, Br * yh)
@expression(model, spec_i, Bi * yh)
@NLexpression(model, spec_sq_mag[m=1:M], spec_r[m]^2 + spec_i[m]^2)
@NLexpression(model, gamma, sum((spec_sq_mag[m]-s[m])^2 for m in 1:M))
@NLobjective(model, Min, gamma)

optimize!(model)

```

* * *

ERROR: LoadError: Nonlinear objective not supported by SCIP.jl!  
Stacktrace:  
[1] error(s::String)  
@ Base ./error.jl:35  
[2] set(o::SCIP.Optimizer, ::MathOptInterface.NLPBlock, data::MathOptInterface.NLPBlockData)  
@ SCIP ~/.julia/packages/SCIP/S9mBb/src/MOI\_wrapper/nonlinear\_constraints.jl:10  
[3] set(b::MathOptInterface.Bridges.LazyBridgeOptimizer{SCIP.Optimizer}, attr::MathOptInterface.NLPBlock, value::MathOptInterface.NLPBlockData)  
@ MathOptInterface.Bridges ~/.julia/packages/MathOptInterface/2CULs/src/Bridges/bridge\_optimizer.jl:955  
[4] \_pass\_attribute(dest::MathOptInterface.Bridges.LazyBridgeOptimizer{SCIP.Optimizer}, src::MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}, index\_map::MathOptInterface.Utilities.IndexMap, attr::MathOptInterface.NLPBlock)  
@ MathOptInterface.Utilities ~/.julia/packages/MathOptInterface/2CULs/src/Utilities/copy.jl:51  
[5] pass\_attributes(dest::MathOptInterface.Bridges.LazyBridgeOptimizer{SCIP.Optimizer}, src::MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}, index\_map::MathOptInterface.Utilities.IndexMap)  
@ MathOptInterface.Utilities ~/.julia/packages/MathOptInterface/2CULs/src/Utilities/copy.jl:38  
[6] default\_copy\_to(dest::MathOptInterface.Bridges.LazyBridgeOptimizer{SCIP.Optimizer}, src::MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}})  
@ MathOptInterface.Utilities ~/.julia/packages/MathOptInterface/2CULs/src/Utilities/copy.jl:503  
[7] copy\_to  
@ ~/.julia/packages/MathOptInterface/2CULs/src/Bridges/bridge\_optimizer.jl:455 [inlined]  
[8] optimize!  
@ ~/.julia/packages/MathOptInterface/2CULs/src/MathOptInterface.jl:84 [inlined]  
[9] optimize!(m::MathOptInterface.Utilities.CachingOptimizer{MathOptInterface.Bridges.LazyBridgeOptimizer{SCIP.Optimizer}, MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}})  
@ MathOptInterface.Utilities ~/.julia/packages/MathOptInterface/2CULs/src/Utilities/cachingoptimizer.jl:316  
[10] optimize!(model::Model; ignore\_optimize\_hook::Bool, \_differentiation\_backend::MathOptInterface.Nonlinear.SparseReverseMode, kwargs::@Kwargs{})  
@ 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  
@ ~/julia\_code/Gen7\_BPM/simple\_model.jl:23  
in expression starting at /home/stuart/julia\_code/Gen7\_BPM/simple\_model.jl:23

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [May 29, 2024, 8:47pm UTC](https://discourse.julialang.org/t/nlp-attribute-scalarnonlinearfunction-is-not-supported-by-the-model/110444/15 "2024-05-29T20:47:08Z")

</div>

Per the error message, SCIP does not support nonlinear objective functions. You need to use an epigraph reformulation:

```Julia
using JuMP
using SCIP
N1 = 5
N = 10
zp = 2
M = zp * N
Br = rand(M, N1)
Bi = rand(M, N1)
s = rand(M, 1)
model = Model(SCIP.Optimizer)
@variable(model, y[1:N1], Bin)
@expression(model, yh[n in 1:N1], y[n] - 0.5)
@expression(model, spec_r, Br * yh)
@expression(model, spec_i, Bi * yh)
@NLexpression(model, spec_sq_mag[m in 1:M], spec_r[m]^2 + spec_i[m]^2)
@variable(model, gamma)
@NLconstraint(model, gamma >= sum((spec_sq_mag[m]-s[m])^2 for m in 1:M))
@objective(model, Min, gamma)
optimize!(model)

```

---

<div class="post-metadata">

**Author:** ![Stuart\_Rogers](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stuart_rogers/32/10694_2.png) [@Stuart\_Rogers](https://discourse.julialang.org/u/Stuart_Rogers)\
**Post date:** [May 29, 2024, 11:14pm UTC](https://discourse.julialang.org/t/nlp-attribute-scalarnonlinearfunction-is-not-supported-by-the-model/110444/16 "2024-05-29T23:14:40Z")

</div>

That fixed the error for SCIP, thanks. When I try to use Alpine instead, I get the following error.

```julia
using JuMP
#using SCIP

N1 = 5
N = 10
zp = 2
M = zp*N

Br = rand(M,N1)
Bi = rand(M,N1)
s = rand(M,1)

#model = 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,
    )

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

@variable(model, y[1:N1], Bin)

@expression(model, yh[n=1:N1], y[n]-.5)
@expression(model, spec_r, Br*yh)
@expression(model, spec_i, Bi*yh)
@NLexpression(model, spec_sq_mag[m in 1:M], spec_r[m]^2 + spec_i[m]^2)
@variable(model, gamma)
@NLconstraint(model, gamma >= sum((spec_sq_mag[m]-s[m])^2 for m in 1:M))
@objective(model, Min, gamma)

optimize!(model)

```

* * *

ERROR: LoadError: type Symbol has no field head  
Stacktrace:  
[1] getproperty  
@ ./Base.jl:37 [inlined]  
[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 ~/.julia/packages/Alpine/2DP5q/src/nlexpr.jl:356  
[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) (repeats 4 times)  
@ Alpine ~/.julia/packages/Alpine/2DP5q/src/nlexpr.jl:374  
[4] traverse\_expr\_linear\_to\_affine(expr::Expr)  
@ Alpine ~/.julia/packages/Alpine/2DP5q/src/nlexpr.jl:332  
[5] expr\_linear\_to\_affine(expr::Expr)  
@ Alpine ~/.julia/packages/Alpine/2DP5q/src/nlexpr.jl:287  
[6] expr\_conversion(m::Alpine.Optimizer)  
@ Alpine ~/.julia/packages/Alpine/2DP5q/src/nlexpr.jl:103  
[7] process\_expr(m::Alpine.Optimizer)  
@ Alpine ~/.julia/packages/Alpine/2DP5q/src/nlexpr.jl:10  
[8] load!(m::Alpine.Optimizer)  
@ Alpine ~/.julia/packages/Alpine/2DP5q/src/main\_algorithm.jl:110  
[9] optimize!(m::Alpine.Optimizer)  
@ Alpine ~/.julia/packages/Alpine/2DP5q/src/main\_algorithm.jl:151  
[10] optimize!  
@ ~/.julia/packages/MathOptInterface/2CULs/src/Bridges/bridge\_optimizer.jl:380 [inlined]  
[11] optimize!  
@ ~/.julia/packages/MathOptInterface/2CULs/src/MathOptInterface.jl:85 [inlined]  
[12] optimize!(m::MathOptInterface.Utilities.CachingOptimizer{MathOptInterface.Bridges.LazyBridgeOptimizer{Alpine.Optimizer}, MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}})  
@ MathOptInterface.Utilities ~/.julia/packages/MathOptInterface/2CULs/src/Utilities/cachingoptimizer.jl:316  
[13] optimize!(model::Model; ignore\_optimize\_hook::Bool, \_differentiation\_backend::MathOptInterface.Nonlinear.SparseReverseMode, kwargs::@Kwargs{})  
@ JuMP ~/.julia/packages/JuMP/Gwn88/src/optimizer\_interface.jl:457  
[14] optimize!(model::Model)  
@ JuMP ~/.julia/packages/JuMP/Gwn88/src/optimizer\_interface.jl:409  
[15] top-level scope  
@ ~/julia\_code/Gen7\_BPM/simple\_model.jl:44  
in expression starting at /home/stuart/julia\_code/Gen7\_BPM/simple\_model.jl:44

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [May 29, 2024, 11:44pm UTC](https://discourse.julialang.org/t/nlp-attribute-scalarnonlinearfunction-is-not-supported-by-the-model/110444/17 "2024-05-29T23:44:26Z")

</div>

I’ve seen that before, but I don’t know the cause: [ERROR: type Symbol has no field head · Issue #226 · lanl-ansi/Alpine.jl · GitHub](https://github.com/lanl-ansi/Alpine.jl/issues/226)

---

<div class="post-metadata">

**Author:** ![Stuart\_Rogers](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stuart_rogers/32/10694_2.png) [@Stuart\_Rogers](https://discourse.julialang.org/u/Stuart_Rogers)\
**Post date:** [May 30, 2024, 12:03am UTC](https://discourse.julialang.org/t/nlp-attribute-scalarnonlinearfunction-is-not-supported-by-the-model/110444/18 "2024-05-30T00:03:23Z")

</div>

When I try to use MAiNGO (as per the code below) to solve that problem, it never seems to finish and repeatedly prints the following warning message.

```julia
using MAiNGO
model=Model(optimizer_with_attributes(MAiNGO.Optimizer, "epsilonA"=> 1e-8))

```

Warning: Could not retrieve Farkas’ values from CLP. Continuing with parent LBD…

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [May 30, 2024, 12:04am UTC](https://discourse.julialang.org/t/nlp-attribute-scalarnonlinearfunction-is-not-supported-by-the-model/110444/19 "2024-05-30T00:04:37Z")

</div>

I have a MWE for Alpine: [ERROR: type Symbol has no field head · Issue #226 · lanl-ansi/Alpine.jl · GitHub](https://github.com/lanl-ansi/Alpine.jl/issues/226#issuecomment-2138438379)

I have no experience using MAiNGO. You should contact their developers.

---

<div class="post-metadata">

**Author:** ![Stuart\_Rogers](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stuart_rogers/32/10694_2.png) [@Stuart\_Rogers](https://discourse.julialang.org/u/Stuart_Rogers)\
**Post date:** [June 6, 2024, 6:25pm UTC](https://discourse.julialang.org/t/nlp-attribute-scalarnonlinearfunction-is-not-supported-by-the-model/110444/20 "2024-06-06T18:25:14Z")

</div>

When I write the epigraph formulation of the model using the legacy interface to a .nl file, SCIP generates an error when I read that model in from the .nl file and then try to solve it. Is it possible for JuMP to formulate the legacy interface model when it reads in the .nl file?

```julia
write_to_file(model,"model.nl")

```

* * *

```julia
using JuMP

model = read_from_file("model.nl")

using SCIP
set_optimizer(model, SCIP.Optimizer)

optimize!(model)

```

* * *

$ julia solve\_model\_from\_file.jl  
ERROR: LoadError: Nonlinear objective not supported by SCIP.jl!  
Stacktrace:  
[1] error(s::String)  
@ Base ./error.jl:35  
[2] set(o::SCIP.Optimizer, ::MathOptInterface.NLPBlock, data::MathOptInterface.NLPBlockData)  
@ SCIP ~/.julia/packages/SCIP/XjNY6/src/MOI\_wrapper/nonlinear\_constraints.jl:10  
[3] set(b::MathOptInterface.Bridges.LazyBridgeOptimizer{SCIP.Optimizer}, attr::MathOptInterface.NLPBlock, value::MathOptInterface.NLPBlockData)  
@ MathOptInterface.Bridges ~/.julia/packages/MathOptInterface/2CULs/src/Bridges/bridge\_optimizer.jl:955  
[4] \_pass\_attribute(dest::MathOptInterface.Bridges.LazyBridgeOptimizer{SCIP.Optimizer}, src::MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}, index\_map::MathOptInterface.Utilities.IndexMap, attr::MathOptInterface.NLPBlock)  
@ MathOptInterface.Utilities ~/.julia/packages/MathOptInterface/2CULs/src/Utilities/copy.jl:51  
[5] pass\_attributes(dest::MathOptInterface.Bridges.LazyBridgeOptimizer{SCIP.Optimizer}, src::MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}, index\_map::MathOptInterface.Utilities.IndexMap)  
@ MathOptInterface.Utilities ~/.julia/packages/MathOptInterface/2CULs/src/Utilities/copy.jl:38  
[6] default\_copy\_to(dest::MathOptInterface.Bridges.LazyBridgeOptimizer{SCIP.Optimizer}, src::MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}})  
@ MathOptInterface.Utilities ~/.julia/packages/MathOptInterface/2CULs/src/Utilities/copy.jl:503  
[7] copy\_to  
@ ~/.julia/packages/MathOptInterface/2CULs/src/Bridges/bridge\_optimizer.jl:455 [inlined]  
[8] optimize!  
@ ~/.julia/packages/MathOptInterface/2CULs/src/MathOptInterface.jl:84 [inlined]  
[9] optimize!(m::MathOptInterface.Utilities.CachingOptimizer{MathOptInterface.Bridges.LazyBridgeOptimizer{SCIP.Optimizer}, MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}})  
@ MathOptInterface.Utilities ~/.julia/packages/MathOptInterface/2CULs/src/Utilities/cachingoptimizer.jl:316  
[10] optimize!(model::Model; ignore\_optimize\_hook::Bool, \_differentiation\_backend::MathOptInterface.Nonlinear.SparseReverseMode, kwargs::@Kwargs{})  
@ 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  
@ ~/julia\_code/Gen7\_BPM/solve\_model\_from\_file.jl:8  
in expression starting at /home/stuart/julia\_code/Gen7\_BPM/solve\_model\_from\_file.jl:8

[Next page](https://discourse.julialang.org/t/nlp-attribute-scalarnonlinearfunction-is-not-supported-by-the-model/110444.md?page=2)
