ed

10-06-2005, 10:57 AM

This question has couple up a couple times recently, so I'll post the solution here for reference. This applies to all the IMSL products, but I'll use JMSL as the example.

Consider the case where you need to bound x as in: x_l \leq x \leq x_u

The LinearProgramming class API explicitly allows bounds on x through the setLowerBound() and setUpperBound() methods, but the QuadraticProgramming class does not include this in the API.

The solution is straightforward, though may not be obvious. You just need to add additional inequality constraints of the form A x \leq b, where A is 1 on the diagonal for the lower bounds, and -1 for the upper bounds.

So the A constraint matrix is:

\left[\begin{array}{cc}x_1&0&0\\0&x_2&0\\0&0&x_3\\-x_1&0&0\\0&-x_2&0\\0&0&-x_3\end{array}\right]

And the B matrix is:

\left[\begin{array}{cc}lb_1\\lb_2\\lb_3\\-ub_1\\-ub_2\\-ub_3\end{array}\right]

Note the necessary change in sign for the upper bounds. Any other inequality constraints for your problem can be appended to these arrays.

Consider the case where you need to bound x as in: x_l \leq x \leq x_u

The LinearProgramming class API explicitly allows bounds on x through the setLowerBound() and setUpperBound() methods, but the QuadraticProgramming class does not include this in the API.

The solution is straightforward, though may not be obvious. You just need to add additional inequality constraints of the form A x \leq b, where A is 1 on the diagonal for the lower bounds, and -1 for the upper bounds.

So the A constraint matrix is:

\left[\begin{array}{cc}x_1&0&0\\0&x_2&0\\0&0&x_3\\-x_1&0&0\\0&-x_2&0\\0&0&-x_3\end{array}\right]

And the B matrix is:

\left[\begin{array}{cc}lb_1\\lb_2\\lb_3\\-ub_1\\-ub_2\\-ub_3\end{array}\right]

Note the necessary change in sign for the upper bounds. Any other inequality constraints for your problem can be appended to these arrays.