Prev Next Index-> contents reference index search external Up-> CppAD ADFun abs_normal qp_box qp_box.cpp ADFun-> record_adfun drivers Forward Reverse sparsity_pattern sparse_derivative optimize abs_normal FunCheck check_for_nan abs_normal-> abs_normal_fun abs_print_mat abs_eval simplex_method lp_box abs_min_linear min_nso_linear qp_interior qp_box abs_min_quad min_nso_quad qp_box-> qp_box.cpp qp_box.hpp qp_box.cpp Headings-> Problem Source

$\newcommand{\W}[1]{ \; #1 \; } \newcommand{\R}[1]{ {\rm #1} } \newcommand{\B}[1]{ {\bf #1} } \newcommand{\D}[2]{ \frac{\partial #1}{\partial #2} } \newcommand{\DD}[3]{ \frac{\partial^2 #1}{\partial #2 \partial #3} } \newcommand{\Dpow}[2]{ \frac{\partial^{#1}}{\partial {#2}^{#1}} } \newcommand{\dpow}[2]{ \frac{ {\rm d}^{#1}}{{\rm d}\, {#2}^{#1}} }$
abs_normal qp_box: Example and Test

Problem
Our original problem is $$\begin{array}{rl} \R{minimize} & x_0 - x_1 \; \R{w.r.t} \; x \in \B{R}^2 \\ \R{subject \; to} & -2 \leq x_0 \leq +2 \; \R{and} \; -2 \leq x_1 \leq +2 \end{array}$$

Source

# include <limits>
# include "qp_box.hpp"

bool qp_box(void)
{     bool ok = true;
//
size_t n = 2;
size_t m = 0;
vector a(n), b(n), c(m), C(m), g(n), G(n*n), xin(n), xout(n);
a[0] = -2.0;
a[1] = -2.0;
b[0] = +2.0;
b[1] = +2.0;
g[0] = +1.0;
g[1] = -1.0;
for(size_t i = 0; i < n * n; i++)
G[i] = 0.0;
//
// (0, 0) is feasible.
xin[0] = 0.0;
xin[1] = 0.0;
//
size_t level   = 0;
double epsilon = 99.0 * std::numeric_limits<double>::epsilon();
size_t maxitr  = 20;
//
}