Print optimization problem using Ipopt

Hello all,

I am building a pretty complex optimization problem with the Ipopt solver (NLP). Since the results are not as I expected, I guess that I made a mistake in the model definition. Therefore, I would like to print out the optimization problem to get a better overview of the model.

I used a macro function to create the model and used print(model) within the function. When I run the function, Julia breaks down - I think because of the print(model) command.

Is there any other way to see the whole optimization problem printed in a nice way?

Thanks a lot for your help (and sorry if my question is confusing you - I am new to Julia)

When happens when you call print? Can you post the error?

Hey, so I tried to do the same for a linear problem with CPLEX at the same happens - either Julia breaks down (page is frozen) or it solves the problem and returns [Math Processing Error] and therefore doesn’t return the printed optimization problem.

The model structure of the linear version is the following:

function example(Set, Results, size::Int, limit::Int)

m = direct_model(CPLEX.Optimizer())

[at]variables(m, begin

[at]expression(m, …)
[at]expression(m, …)
OBJ_VAR = [at]expression(m, …)

[at]constraints(m, begin

[at]constraints(m, begin

[at]objective(m, Max, OBJ_VAR)




Then I call the function at a later point after having scaled the model and would expect to get the printed model displayed. What am I doing wrong?

Julia breaks down (page is frozen) or it solves the problem and returns [Math Processing Error]

How are you running the problem? Is this in IJulia? Where is the [Math Processing Error] coming from?

How big is your model (# of variables and constraints)?

Do you have a reproducible example?


yes I am running the problem in IJulia in the Jupyter notebook.

Concerning your question on the size of the model - it is pretty big, here the Ipopt output after having solved it:

Number of nonzeros in equality constraint Jacobian…: 3840
Number of nonzeros in inequality constraint Jacobian.: 960
Number of nonzeros in Lagrangian Hessian…: 0

Total number of variables…: 10206
variables with only lower bounds: 10206
variables with lower and upper bounds: 0
variables with only upper bounds: 0
Total number of equality constraints…: 1056
Total number of inequality constraints…: 576
inequality constraints with only lower bounds: 192
inequality constraints with lower and upper bounds: 0
inequality constraints with only upper bounds: 384

And I do not really have a reproducible example unfortunately as the model is very big (how-ever it is non-convex).

In IJulia we use Javascript to render the formulation as LaTeX. It seems that the model is too big and so the Javascript backend crashes [Math Processing Error].

However, do you expect that printing a 10^4 by 10^3 size problem would be readable? Why do you want to print it? There are likely too many constraints and too many terms to read to find the mistake.

The printing really only works for models with ~10 variables and constraints.

Thanks for your help! Indeed it probably doesn’t make sense to print the problem like that.

1 Like