Prev Next Index-> contents reference index search external Up-> CppAD ADFun abs_normal min_nso_linear min_nso_linear.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 min_nso_linear-> min_nso_linear.cpp min_nso_linear.hpp min_nso_linear.cpp Headings-> Purpose Discussion 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 min_nso_linear: Example and Test

Purpose
We minimize the function $f : \B{R}^3 \rightarrow \B{R}$ defined by $$\begin{array}{rcl} f( x_0, x_1, x_2 ) & = & x_0^2 + 2 (x_0 + x_1)^2 + | x_2 | \end{array}$$

Discussion
This routine uses abs_min_linear which uses lp_box , a linear programming algorithm. It is mean to be compared with min_nso_quad.cpp which uses a quadratic programing algorithm for the same problem. To see this comparison, set level = 1 is both examples.

Source

# include "min_nso_linear.hpp"

bool min_nso_linear(void)
{     bool ok = true;
//
//
//
size_t level = 0;    // level of tracing
size_t n     = 3;    // size of x
size_t m     = 1;    // size of y
size_t s     = 1;    // number of data points and absolute values
//
// start recording the function f(x)
for(size_t j = 0; j < n; j++)
ax[j] = double(j + 1);
Independent( ax );
//
ay[0]  =  ax[0] * ax[0];
ay[0] += 2.0 * (ax[0] + ax[1]) * (ax[0] + ax[1]);
ay[0] += fabs( ax[2] );
//
// create its abs_normal representation in g, a
f.abs_normal_fun(g, a);

// check dimension of domain and range space for g
ok &= g.Domain() == n + s;
ok &= g.Range()  == m + s;

// check dimension of domain and range space for a
ok &= a.Domain() == n;
ok &= a.Range()  == s;

// epsilon
d_vector epsilon(2);
double eps = 1e-3;
epsilon[0] = eps;
epsilon[1] = eps;

// maxitr
s_vector maxitr(3);
maxitr[0] = 100;
maxitr[1] = 20;
maxitr[2] = 20;

// b_in
double b_in = 1.0;

// call min_nso_linear
d_vector x_in(n), x_out(n);
for(size_t j = 0; j < n; j++)
x_in[j]  = double(j + 1);

//
}