virtual bool get_bounds_info(Index n, Number* x_l, Number* x_u,
Index m, Number* g_l, Number* g_u)
Give IPOPT the value of the bounds on the variables and constraints.
In our example, the first constraint has a lower bound of
and no upper
bound, so we set the lower bound of constraint [0] to
and
the upper bound to some number greater than
. The second
constraint is an equality constraint and we set both bounds to
. IPOPT recognizes this as an equality constraint and does not
treat it as two inequalities.
bool HS071_NLP::get_bounds_info(Index n, Number* x_l, Number* x_u,
Index m, Number* g_l, Number* g_u)
{
// here, the n and m we gave IPOPT in get_nlp_info are passed back to us.
// If desired, we could assert to make sure they are what we think they are.
assert(n == 4);
assert(m == 2);
// the variables have lower bounds of 1
for (Index i=0; i<4; i++) {
x_l[i] = 1.0;
}
// the variables have upper bounds of 5
for (Index i=0; i<4; i++) {
x_u[i] = 5.0;
}
// the first constraint g1 has a lower bound of 25
g_l[0] = 25;
// the first constraint g1 has NO upper bound, here we set it to 2e19.
// Ipopt interprets any number greater than nlp_upper_bound_inf as
// infinity. The default value of nlp_upper_bound_inf and nlp_lower_bound_inf
// is 1e19 and can be changed through ipopt options.
g_u[0] = 2e19;
// the second constraint g2 is an equality constraint, so we set the
// upper and lower bound to the same value
g_l[1] = g_u[1] = 40.0;
return true;
}