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

NLExpressions and multiplication / division with numbers #571

Closed
anriseth opened this issue Sep 4, 2015 · 2 comments · Fixed by #638
Closed

NLExpressions and multiplication / division with numbers #571

anriseth opened this issue Sep 4, 2015 · 2 comments · Fixed by #638

Comments

@anriseth
Copy link
Contributor

anriseth commented Sep 4, 2015

I guess this is an issue with the complexity of dealing with nonlinear expressions, so this is more of a note for people who might have the same problems:

The Hessian sparsity changes drastically depending on how you set your objectives in nonlinear optimisation. Division is bad, so is multiplication with something like (1 - a) for some scalar a.
The way around these issues is using multiplication with dummy-variables. In the following, let nf2 be a ParametricExpression defined by @defNLExpr:

julia> @setNLObjective(m, :Min, nf2*(1-a))
julia> solve(m)
This is Ipopt version 3.11.9, running with linear solver mumps.
NOTE: Other linear solvers might be more efficient (see Ipopt documentation).

Number of nonzeros in equality constraint Jacobian...:        0
Number of nonzeros in inequality constraint Jacobian.:      355
Number of nonzeros in Lagrangian Hessian.............:    61075
*snip*

julia> num = (1-a)
julia> @setNLObjective(m, :Min, nf2*num)
julia> solve(m)
This is Ipopt version 3.11.9, running with linear solver mumps.
NOTE: Other linear solvers might be more efficient (see Ipopt documentation).

Number of nonzeros in equality constraint Jacobian...:        0
Number of nonzeros in inequality constraint Jacobian.:      355
Number of nonzeros in Lagrangian Hessian.............:     1495

Likewise, if you want @setNLObjective(m, :Min, nf2 / a). It is better to use b = 1/a and @setNLObjective(m, :Min, nf2 * b)

@mlubin
Copy link
Member

mlubin commented Sep 4, 2015

Yes, there are a few heuristics in the sparsity detection code. Will be
addressed in the next rewrite.
On Sep 4, 2015 5:22 AM, "Asbjørn Nilsen Riseth" notifications@github.com
wrote:

I guess this is an issue with the complexity of dealing with nonlinear
expressions, so this is more of a note for people who might have the same
problems:

The Hessian sparsity changes drastically depending on how you set your
objectives in nonlinear optimisation. Division is bad, so is multiplication
with something like (1 - a) for some scalar a.
The way around these issues is using multiplication with dummy-variables.
In the following, let nf2 be a ParametricExpression defined by @defNLExpr:

julia> @setNLObjective(m, :Min, nf2*(1-a))
julia> solve(m)
This is Ipopt version 3.11.9, running with linear solver mumps.
NOTE: Other linear solvers might be more efficient (see Ipopt documentation).

Number of nonzeros in equality constraint Jacobian...: 0
Number of nonzeros in inequality constraint Jacobian.: 355
Number of nonzeros in Lagrangian Hessian.............: 61075_snip_

julia> num = (1-a)
julia> @setNLObjective(m, :Min, nf2*num)
julia> solve(m)
This is Ipopt version 3.11.9, running with linear solver mumps.
NOTE: Other linear solvers might be more efficient (see Ipopt documentation).

Number of nonzeros in equality constraint Jacobian...: 0
Number of nonzeros in inequality constraint Jacobian.: 355
Number of nonzeros in Lagrangian Hessian.............: 1495

Likewise, if you want @setNLObjective(m, :Min, nf2 / a). It is better to
use b = 1/a and @setNLObjective(m, :Min, nf2 * b)


Reply to this email directly or view it on GitHub
#571.

@mlubin
Copy link
Member

mlubin commented Sep 4, 2015

I'd recommend using IpoptNLSolver from the AmplNLWriter package as a workaround, but there are some open issues with that.

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

Successfully merging a pull request may close this issue.

2 participants