next up previous contents
Next: Method get_starting_point Up: Coding the Problem Representation Previous: Method get_nlp_info   Contents

Method get_bounds_info

with prototype
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. The values of n and m that you specified in get_nlp_info are passed to you for debug checking. Setting a lower bound to a value less than or equal to the value of the option nlp_lower_bound_inf will cause IPOPT to assume no lower bound. Likewise, specifying the upper bound above or equal to the value of the option nlp_upper_bound_inf will cause IPOPT to assume no upper bound. These options, nlp_lower_bound_inf and nlp_upper_bound_inf, are set to $ -10^{19}$ and $ 10^{19}$ , respectively, by default, but may be modified by changing the options (see Section 5).

In our example, the first constraint has a lower bound of $ 25$ and no upper bound, so we set the lower bound of constraint [0] to $ 25$ and the upper bound to some number greater than $ 10^{19}$ . The second constraint is an equality constraint and we set both bounds to $ 40$ . 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;
}


next up previous contents
Next: Method get_starting_point Up: Coding the Problem Representation Previous: Method get_nlp_info   Contents
Andreas Waechter 2008-08-26