coin-or / Ipopt

COIN-OR Interior Point Optimizer IPOPT
https://coin-or.github.io/Ipopt
Other
1.43k stars 284 forks source link

nnz_jac_g and nnz_h_lag #688

Closed matheusdiogenesandrade closed 1 year ago

matheusdiogenesandrade commented 1 year ago

Hello.

Folks! I am writing a C++ Ipopt model for the Quadratic Assignment Problem (QAP), and I am in doubt with two parameters: nnz_jac_g and nnz_h_lag. How do I find the value of these two parameters?

Thanks and regards.

svigerske commented 1 year ago

There is documentation on the C++ interface in https://coin-or.github.io/Ipopt/INTERFACES.html#INTERFACE_CPP.

nnz_jac_g essentially counts all appearances of variables in all constraints. For a QAP, where you have only linear constraints, this should be the number of nonzero coefficients in your constraint matrix.

nnz_h_lag is the number of nonzero entries in the Hessian of the Lagrangian. Since you have only linear constraints and a quadratic objective function, this is the number of nonzeros in the quadratic coefficients matrix. Here, assume it is a symmetric matrix and count only the nonzeros in the lower-left triangle.

Note that Ipopt can only find locally optimal solutions to continuous nonlinear programs (no binary variables).

matheusdiogenesandrade commented 1 year ago

Thank you very much.