Prev Next Index-> contents reference index search external Up-> CppAD ADFun abs_normal lp_box CppAD-> Install Introduction AD ADFun preprocessor multi_thread utility ipopt_solve Example speed Appendix 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 lp_box-> lp_box.cpp lp_box.hpp Headings-> Syntax Prototype Source Problem Vector level A b c d maxitr xout ok Example

$\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: Solve a Linear Program With Box Constraints

Syntax
ok = lp_box(      level, A, b, c, d, maxitr, xout )

Prototype

template <class Vector>
bool lp_box(
size_t        level   ,
const Vector& A       ,
const Vector& b       ,
const Vector& c       ,
const Vector& d       ,
size_t        maxitr  ,
Vector&       xout    )

Source
This following is a link to the source code for this example: lp_box.hpp .

Problem
We are given $A \in \B{R}^{m \times n}$, $b \in \B{R}^m$, $c \in \B{R}^n$, $d \in \B{R}^n$, This routine solves the problem $$\begin{array}{rl} \R{minimize} & c^T x \; \R{w.r.t} \; x \in \B{R}^n \\ \R{subject \; to} & A x + b \leq 0 \; \R{and} \; - d \leq x \leq d \end{array}$$

Vector
The type Vector is a simple vector with elements of type double.

level
This value is less that or equal two. If level == 0 , no tracing is printed. If level >= 1 , a trace of the lp_box operations is printed. If level >= 2 , the objective and primal variables $x$ are printed at each simplex_method iteration. If level == 3 , the simplex tableau is printed at each simplex iteration.

A
This is a row-major representation of the matrix $A$ in the problem.

b
This is the vector $b$ in the problem.

c
This is the vector $c$ in the problem.

d
This is the vector $d$ in the problem. If $d_j$ is infinity, there is no limit for the size of $x_j$.

maxitr
This is the maximum number of newton iterations to try before giving up on convergence.

xout
This argument has size is n and the input value of its elements does no matter. Upon return it is the primal variables $x$ corresponding to the problem solution.

ok
If the return value ok is true, an optimal solution was found.

Example
The file lp_box.cpp contains an example and test of lp_box. It returns true if the test passes and false otherwise.
Input File: example/abs_normal/lp_box.hpp