I'm trying to understand an optimization problem from IPOPT package.
* Problem hs071 looks like this
*
* min x1*x4*(x1 + x2 + x3) + x3
* s.t. x1*x2*x3*x4 >= 25
* x1**2 + x2**2 + x3**2 + x4**2 = 40
* 1 <= x1,x2,x3,x4 <= 5
*
* Starting point:
* x = (1, 5, 5, 1)
*
* Optimal solution:
* x = (1.00000000, 4.74299963, 3.82114998, 1.37940829)
However, in the other file it is stated
// The problem described in HS071_NLP.hpp has 4 variables, x[0] through x[3]
n = 4;
// one equality constraint and one inequality constraint
m = 2;
// in this example the jacobian is dense and contains 8 nonzeros
nnz_jac_g = 8;
// the Hessian is also dense and has 16 total nonzeros, but we
// only need the lower left corner (since it is symmetric)
nnz_h_lag = 10;
So we have $4$ variables and $2$ constraints. But then somehow, they put $8$ non-zeroes in Jacobian. Why? Should not it be only $4$, as cost function is $f: \mathbb{R}^4 \to \mathbb{R}$?
Moreover, Hessian is clearly stated as $16$, i.e. a $4 \times 4$ matrix, as expected.
Apparently, they are not talking about the $\nabla f$, but rather about the Jacobian of the constraints. Which then are treated as $G: \mathbb{R}^4 \to \mathbb{R}^2$, hence $J_G$ has $8$ entries.