# Nonlinear expression without scalar expressions

**URL:** <https://discourse.julialang.org/t/nonlinear-expression-without-scalar-expressions/71544>\
**Category:** Optimization (Mathematical)\
**Created:** [November 16, 2021, 10:01am UTC](https://discourse.julialang.org/t/nonlinear-expression-without-scalar-expressions/71544 "2021-11-16T10:01:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![chupin](https://avatars.discourse-cdn.com/v4/letter/c/f07891/32.png) [@chupin](https://discourse.julialang.org/u/chupin)\
**Post date:** [November 16, 2021, 10:01am UTC](https://discourse.julialang.org/t/nonlinear-expression-without-scalar-expressions/71544/1 "2021-11-16T10:01:22Z")

</div>

Hi, I’ve read that nonlinear optimization has limited support. Unfortunately, my objective function cannot be written with scalar expressions and my matrix variable is at least 1000x1000 and I need to call several functions to build my objective function (the variable is a support function, that I need to differentiate, and construct a parametric function that I have to integrate…). The code required to compute `aireSurface(h)` or `volumeSurface(h)` has 200 lines.

My code is something like that

```julia
    model = Model(Ipopt.Optimizer)
    register(model, :aireSurface, 1, aireSurface; autodiff = true)
    set_optimizer_attribute(model, "print_level", 1)
    @variables(
        model,
        begin
        h[1:N,1:M]<=b/2.0
        end
    )
    @NLobjective( 
        model,
        Max,
        aireSurface(h)
    )
    @constraint(
        # convexity
        model,
        convexity(h) .>= 0
    )
    @constraint(
        # volume
        model,
        volumeSurface(h) == lambdaI*4.0/3.0*pi*((b/2.0)^3),
    )

```

Is there any workaround to do that ? Thanks

---

<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:** [November 16, 2021, 5:33pm UTC](https://discourse.julialang.org/t/nonlinear-expression-without-scalar-expressions/71544/2 "2021-11-16T17:33:37Z")

</div>

No, there is no work-around for JuMP.

You might want to try Nonconvex.jl instead: [Getting started · Nonconvex.jl](https://julianonconvex.github.io/Nonconvex.jl/stable/)

---

<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:** [November 16, 2021, 5:34pm UTC](https://discourse.julialang.org/t/nonlinear-expression-without-scalar-expressions/71544/3 "2021-11-16T17:34:52Z")

</div>

But I will say, you have a black-box function with 1,000,000 variables. That’s going to be challenging to solve. Have you considered alternative approaches?
