Changeset 1637


Ignore:
Timestamp:
Jan 27, 2010 2:09:30 AM (10 years ago)
Author:
bradbell
Message:

/home/bradbell/cppad/trunk:

check_doxygen.sh: take advantage of error/warnings being in doxygen.err.
doxyfile.in: separate member functions, use doxygen.err for warnings.
*/makefile.in: changes transfered from corresponding makefile.am.
speed.cpp: change count ot eval_r_count.
cppad_ipopt_nlp.hpp: developer documentation and improvement in speed.
jac_g_map.cpp: use cross reference to complex equation.
hes_fg_map.cpp: use cross reference to complex equation.
cppad_ipopt_nlp.cpp: developer documentation and improvement in speed.
build.sh: simplify by using doxygen.err file.
whats_new_10.omh: user's view of the changes.

Location:
trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/build.sh

    r1634 r1637  
    447447if [ "$1" = "doxygen" ]
    448448then
    449         # avoid warning in mid sentence of other log output by separating them
    450         echo "doxygen doxyfile 1> doxygen.log 2> doxygen.$$"
    451         if ! doxygen doxyfile 1> doxygen.log 2> doxygen.$$
    452         then
    453                 echo "Error: during doxygen"
    454                 exit 1
    455         fi
    456         echo "cat doxygen.$$ >> doxygen.log"
    457         if ! cat doxygen.$$ >> doxygen.log
     449        echo "build.sh doxygen"
     450        # remove old error or warning file, check_doxygen.sh will make sure
     451        # a new one is created.
     452        list="
     453                doxygen.err
     454                doxydoc
     455        "
     456        for name in $list
     457        do
     458                if [ -e $name ]
     459                then
     460                        if ! rm -r $name
     461                        then
     462                                echo "Error: cannot remove old $name"
     463                                exit 1
     464                        fi
     465                fi
     466        done
     467        # create doxydoc directory to avoid warning
     468        mkdir doxydoc
     469        #
     470        echo "doxygen doxyfile > doxygen.log "
     471        if ! doxygen doxyfile > doxygen.log
     472        then
     473                echo "Error: during doxygen; see doxygen.err"
     474                exit 1
     475        fi
     476        echo "cat doxygen.err >> doxygen.log"
     477        if ! cat doxygen.err >> doxygen.log
    458478        then
    459479                echo "Error: cannot add errors and warnings to doxygen.log"
    460                 exit 1
    461         fi
    462         echo "rm doxygen.$$"
    463         if ! rm doxygen.$$
    464         then
    465                 echo "Error: cannot remove doxygen.$$"
    466480                exit 1
    467481        fi
     
    611625        done
    612626        # Test developer documentation ---------------------------------------
    613         # avoid warning in mid sentence of other log output by separating them
    614         echo "doxygen doxyfile 1> doxygen.log 2> doxygen.$$"
    615         if ! doxygen doxyfile 1> doxygen.log 2> doxygen.$$
    616         then
    617                 echo "Error: during doxygen"
    618                 exit 1
    619         fi
    620         echo "cat doxygen.$$ >> doxygen.log"
    621         if ! cat doxygen.$$ >> doxygen.log
     627        # remove old error or warning file, check_doxygen.sh will make sure
     628        # a new one is created.
     629        list="
     630                doxygen.err
     631                doxydoc
     632        "
     633        for name in $list
     634        do
     635                if [ -e $name ]
     636                then
     637                        if ! rm -r $name
     638                        then
     639                                echo "Error: cannot remove old $name"
     640                                exit 1
     641                        fi
     642                fi
     643        done
     644        # create doxydoc directory to avoid warning
     645        mkdir doxydoc
     646        echo "doxygen doxyfile > doxygen.log"
     647        if ! doxygen doxyfile > doxygen.log
     648        then
     649                echo "Error: during doxygen; see doxygen.err"
     650                exit 1
     651        fi
     652        echo "cat doxygen.err >> doxygen.log"
     653        if ! cat doxygen.err >> doxygen.log
    622654        then
    623655                echo "Error: cannot add errors and warnings to doxygen.log"
    624                 exit 1
    625         fi
    626         echo "rm doxygen.$$"
    627         if ! rm doxygen.$$
    628         then
    629                 echo "Error: cannot remove doxygen.$$"
    630656                exit 1
    631657        fi
  • trunk/check_doxygen.sh

    r1636 r1637  
    1111# Please visit http://www.coin-or.org/CppAD/ for information on other licenses.
    1212# -----------------------------------------------------------------------------
     13if [ ! -e "doxygen.err" ]
     14then
     15        echo "check_doxygen.sh: cannot find doxygen.err"
     16        exit 1
     17fi
    1318doxygen_version=`doxygen --version  | sed -e 's|\.|*100+|' -e's|\.|*10+|'`
    1419let doxygen_version=$doxygen_version
     
    2025        exit 0
    2126fi
    22 #
    23 # classes that have been completely documented
    24 class_list="
    25         player
    26         recorder
    27         sparse_pack
    28         sparse_set
    29 "
    30 #
    31 # member functions names that begin with the following have been documented
    32 # (but the corresponding class has not yet been completely documented).
    33 member_list="
    34         SparseJacobian
    35 "
    36 # files that have been completely documented
    37 file_list="
    38         abs_op.hpp
    39         add_op.hpp
    40         acos_op.hpp
    41         asin_op.hpp
    42         cond_op.hpp
    43         configure.hpp
    44         cos_op.hpp
    45         cosh_op.hpp
    46         csum_op.hpp
    47         cppad_assert.hpp
    48         define.hpp
    49         discrete_op.hpp
    50         div_op.hpp
    51         forward0sweep.hpp
    52         forward_sweep.hpp
    53         for_jac_sweep.hpp
    54         for_sparse_jac.hpp
    55         fun_construct.hpp
    56         hash_code.hpp
    57         load_op.hpp
    58         log_op.hpp
    59         mul_op.hpp
    60         op_code.hpp
    61         optimize.hpp
    62         player.hpp
    63         print_op.hpp
    64         pow_op.hpp
    65         prototype_op.hpp
    66         recorder.hpp
    67         reverse_sweep.hpp
    68         rev_hes_sweep.hpp
    69         rev_jac_sweep.hpp
    70         rev_sparse_hes.hpp
    71         rev_sparse_jac.hpp
    72         sin_op.hpp
    73         sinh_op.hpp
    74         sparse_binary_op.hpp
    75         sparse_map2vec.hpp
    76         sparse_unary_op.hpp
    77         sqrt_op.hpp
    78         store_op.hpp
    79         sub_op.hpp
    80         sparse_jacobian.hpp
    81         sparse_hessian.hpp
    82         sparse_pack.hpp
    83         sparse_set.hpp
    84 
    85         fun_record.hpp
    86         hes_fg_map.cpp
    87         jac_g_map.cpp
    88         sparse_map2vec.cpp
    89         vec_fun_pattern.cpp
    90 "
    91 # --------------------------------------------------------------------------
    92 for class in $class_list
    93 do
    94         if grep -i "warning:.*$class::" doxygen.log
    95         then
    96                 echo "Unexpected doxygen error or warning for $file."
    97                 exit 1
    98         fi
    99 done
    100 # --------------------------------------------------------------------------
    101 for member in $member_list
    102 do
    103         if grep -i "warning:.*member.*$member" doxygen.log
    104         then
    105                 echo "Unexpected doxygen error or warning for $file."
    106                 exit 1
    107         fi
    108 done
    109 # --------------------------------------------------------------------------
    110 for file in $file_list
    111 do
    112         found="no"
    113         for dir in cppad cppad/local cppad_ipopt/src
    114         do
    115                 if [ -e $dir/$file ]
    116                 then
    117                         found="yes"
    118                 fi
    119         done
    120         if [ $found == "no" ]
    121         then
    122                 echo "check_doxygen.sh: cannot find file $file"
    123                 exit 1
    124         fi
    125         if grep -i "$file.*warning" doxygen.log
    126         then
    127                 echo "Unexpected doxygen error or warning for $file."
    128                 exit 1
    129         fi
    130 done
     27list=`head doxygen.err`
     28if [ "$list" == "" ]
     29then
     30        exit 0
     31fi
     32echo "check_doxygen.sh: Doxygen errors or warnings; see doxygen.err"
     33exit 1
  • trunk/cppad_ipopt/speed/makefile.in

    r1636 r1637  
    9191CYGPATH_W = @CYGPATH_W@
    9292
    93 # $Id: makefile.am 1634 2010-01-24 08:44:17Z bradbell $
     93# $Id: makefile.am 1636 2010-01-25 04:57:24Z bradbell $
    9494# -----------------------------------------------------------------------------
    9595# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-10 Bradley M. Bell
  • trunk/cppad_ipopt/speed/speed.cpp

    r1636 r1637  
    2626        name    = "simple_retape_yes";
    2727        seconds = ode_speed(name, count);
    28         printf("ode %20s: seconds = %5.2f: count = %d\n", name, seconds, count);
     28        printf("ode %20s: seconds = %5.2f: eval_r_count = %d\n",
     29                name, seconds, count);
    2930
    3031        name    = "simple_retape_no";
    3132        seconds = ode_speed(name, count);
    32         printf("ode %20s: seconds = %5.2f: count = %d\n", name, seconds, count);
     33        printf("ode %20s: seconds = %5.2f: eval_r_count = %d\n",
     34                name, seconds, count);
    3335
    3436        name    = "fast_retape_yes";
    3537        seconds = ode_speed(name, count);
    36         printf("ode %20s: seconds = %5.2f: count = %d\n", name, seconds, count);
     38        printf("ode %20s: seconds = %5.2f: eval_r_count = %d\n",
     39                name, seconds, count);
    3740
    3841        name    = "fast_retape_no";
    3942        seconds = ode_speed(name, count);
    40         printf("ode %20s: seconds = %5.2f: count = %d\n", name, seconds, count);
     43        printf("ode %20s: seconds = %5.2f: eval_r_count = %d\n",
     44                name, seconds, count);
    4145       
    4246        return 0;
  • trunk/cppad_ipopt/src/cppad_ipopt_nlp.cpp

    r1636 r1637  
    1717# include "fun_record.hpp"
    1818
    19 // define as 0 for false or 1 for true
    20 # define  CPPAD_NLP_TRACE 0
    21 
    22 # if CPPAD_NLP_TRACE
     19/*!
     20\file cppad_ipopt_nlp.cpp
     21\brief Member functions for the cppad_ipopt_nlp class.
     22*/
     23
     24/// If 0 tracing is off, otherwise tracing is on.
     25# define  CPPAD_IPOPT_NLP_TRACE 0
     26
     27# if CPPAD_IPOPT_NLP_TRACE
    2328# include <cstdio>
    2429# endif
    2530
    26 /* Constructor. */
     31
     32/*!
     33Constructor for the \ref Nonlinear_Programming_Problem.
     34
     35\param n
     36dimension of the domain space for f(x) and g(x).
     37
     38\param m
     39dimension of the range space for g(x)
     40
     41\param x_i
     42initial value of x during the optimization procedure (size n).
     43
     44\param x_l
     45lower limit for x (size n).
     46
     47\param x_u
     48upper limit for x (size n).
     49
     50\param g_l
     51lower limit for g(x) (size m).
     52
     53\param g_u
     54upper limit for g(x) (size m).
     55
     56\param fg_info
     57pointer to base class version of derived class object used to get
     58information about the user's representation for f(x) and g(x).
     59(The object pointed to must not be deleted before this cppad_ipopt_nlp object).
     60
     61\param solution
     62pointer to object where final results are stored.
     63(The object pointed to must not be deleted before this cppad_ipopt_nlp object).
     64
     65\par Constants
     66The following values are set by the constructor and are \c const
     67or effectively \c const; i.e., they are set by the constructor and should
     68not be changed:
     69\verbatim
     70        n_, m_, x_i_, x_l_, x_u_, g_l_, g_u_, K_, L_, p_, q_, retape_,
     71        pattern_jac_r_, pattern_hes_r_, index_jac_g_, index_hes_fg_,
     72        nnz_jac_g_, iRow_jac_g_, jCol_jac_g_,
     73        nnz_h_lag_, iRow_h_lag_, jCol_h_lag_,
     74\endverbatim
     75In addition, the function calls <tt>fg_info->set_n(n)</tt>
     76and <tt>fg_info->set_m(m)</tt> are used to set the values of \c n
     77and \c m in \c fg_info.
     78
     79\par Variables
     80The following arrays have fixed size which is set during this constructor:
     81
     82\li \c tape_ok_ has size \c K_. It is initialized as true for indices
     83\c k such that <tt>retape[k]</tt> is false. 
     84
     85\li \c r_fun_ has size \c K_. It is initilaize with the default
     86\c ADFun constructor. Then, for indices \c k such that
     87<tt>retape[k]</tt> is false, the operation sequence corresponding
     88to \f$ r_k (u) \f$ is stored in <tt>r_fun_[k]</tt>.
     89
     90\li \c I_ has size equal to the maximum of <tt>p[k]</tt> w.r.t \c k.
     91
     92\li \c J_ has size equal to the maximum of <tt>q[k]</tt> w.r.t \c k.
     93
     94\par NDEBUG
     95If the preprocessor symbol \c NEBUG is not defined,
     96certain of the assumptions about the function calls of the form
     97\verbatim
     98        fg_info->index(k, ell, I, J)
     99\endverbatim
     100are checked to make sure they hold.
     101*/
    27102cppad_ipopt_nlp::cppad_ipopt_nlp(
    28         size_t                     n           ,
    29         size_t                     m           ,
    30         const NumberVector&        x_i         ,
    31         const NumberVector&        x_l         ,
    32         const NumberVector&        x_u         ,
    33         const NumberVector&        g_l         ,
    34         const NumberVector&        g_u         ,
    35         cppad_ipopt_fg_info*       fg_info     ,
    36         cppad_ipopt_solution*      solution    )
     103        size_t n                         ,
     104        size_t m                         ,
     105        const NumberVector    &x_i       ,
     106        const NumberVector    &x_l       ,
     107        const NumberVector    &x_u       ,
     108        const NumberVector    &g_l       ,
     109        const NumberVector    &g_u       ,
     110        cppad_ipopt_fg_info*   fg_info   ,
     111        cppad_ipopt_solution*  solution )
    37112        : n_ ( n ),
    38113          m_ ( m ),
     
    59134        tape_ok_.resize(K_);
    60135        pattern_jac_r_.resize(K_);
    61         pattern_r_lag_.resize(K_);
     136        pattern_hes_r_.resize(K_);
    62137        size_t max_p      = 0;
    63138        size_t max_q      = 0;
     
    70145                max_q       = std::max(max_q, q_[k]);
    71146                pattern_jac_r_[k].resize( p_[k] * q_[k] );
    72                 pattern_r_lag_[k].resize( q_[k] * q_[k] );
     147                pattern_hes_r_[k].resize( q_[k] * q_[k] );
    73148        }
    74149        I_.resize(max_p);
     
    124199        vec_fun_pattern(
    125200                K_, p_, q_, retape_, r_fun_,      // inputs
    126                 pattern_jac_r_, pattern_r_lag_    // outputs
     201                pattern_jac_r_, pattern_hes_r_    // outputs
    127202        );
    128203
     
    136211        // mapping from (i,j) to Ipopt sparsity index for Hessian of Lagragian
    137212        hes_fg_map(
    138                 fg_info_, m_, n_, K_, L_, p_, q_, pattern_r_lag_,   // inputs
     213                fg_info_, m_, n_, K_, L_, p_, q_, pattern_hes_r_,   // inputs
    139214                I_, J_,                                             // work
    140215                index_hes_fg_                                       // outputs
     
    152227                nnz_h_lag_, iRow_h_lag_, jCol_h_lag_  // outputs
    153228        );
    154 
    155229}
    156230
     231/// The destructor takes no special action.
    157232cppad_ipopt_nlp::~cppad_ipopt_nlp()
    158233{}
    159234
     235/*!
     236Return dimension information about optimization problem.
     237
     238\param[out] n
     239is set to the value \c n_.
     240
     241\param[out] m
     242is set to the value \c m_.
     243
     244\param[out] nnz_jac_g
     245is set to the value of \c nnz_jac_g_.
     246
     247\param[out] nnz_h_lag
     248is set to the vlaue of \c nnz_h_lag_.
     249
     250\param[out] index_style
     251is set to C_STYLE; i.e., zeoro based indexing is used in the
     252information passed to Ipopt.
     253*/
    160254bool cppad_ipopt_nlp::get_nlp_info(Index& n, Index& m, Index& nnz_jac_g,
    161255                         Index& nnz_h_lag, IndexStyleEnum& index_style)
     
    172266}
    173267
     268/*!
     269Return bound information about optimization problem.
     270
     271\param[in] n
     272is the dimension of the domain space for f(x) and g(x); i.e.,
     273it must be equal to \c n_.
     274
     275\param[out] x_l
     276is a vector of size \c n.
     277The input value of its elements does not matter.
     278On output, it is a copy of the lower bound for \f$ x \f$; i.e.,
     279\c x_l_.
     280
     281\param[out] x_u
     282is a vector of size \c n.
     283The input value of its elements does not matter.
     284On output, it is a copy of the upper bound for \f$ x \f$; i.e.,
     285\c x_u_.
     286
     287\param[in] m
     288is the dimension of the domain space for f(x) and g(x). i.e.,
     289it must be equal to \c m_.
     290
     291\param[out] g_l
     292is a vector of size \c m.
     293The input value of its elements does not matter.
     294On output, it is a copy of the lower bound for \f$ g(x) \f$; i.e., \c g_l_.
     295
     296\param[out] g_u
     297is a vector of size \c m.
     298The input value of its elements does not matter.
     299On output, it is a copy of the upper bound for \f$ g(x) \f$; i.e, \c g_u_.
     300*/
    174301bool cppad_ipopt_nlp::get_bounds_info(Index n, Number* x_l, Number* x_u,
    175302                            Index m, Number* g_l, Number* g_u)
     
    192319}
    193320
     321/*!
     322Return initial x value where optimiation is started.
     323
     324\param[in] n
     325must be equal to the domain dimension for f(x) and g(x); i.e.,
     326it must be equal to \c n_.
     327
     328\param[in] init_x
     329must be equal to true.
     330
     331\param[out] x
     332is a vector of size \c n.
     333The input value of its elements does not matter.
     334On output, it is a copy of the initial value for \f$ x \f$; i.e. \c x_i_.
     335
     336\param[in] init_z
     337must be equal to false.
     338
     339\param z_L
     340is not used.
     341
     342\param z_U
     343is not used.
     344
     345\param[in] m
     346must be equal to the domain dimension for f(x) and g(x); i.e.,
     347it must be equal to \c m_.
     348
     349\param init_lambda
     350must be equal to false.
     351
     352\param lambda
     353is not used.
     354*/
    194355bool cppad_ipopt_nlp::get_starting_point(Index n, bool init_x, Number* x,
    195356                               bool init_z, Number* z_L, Number* z_U,
     
    210371}
    211372
     373/*!
     374Evaluate the objective fucntion f(x).
     375
     376\param[in] n
     377is the dimension of the argument space for f(x); i.e., must be equal \c n_.
     378
     379\param[in] x
     380is a vector of size \c n containing the point at which to evaluate
     381the function f(x).
     382
     383\param[in] new_x
     384is true if the previous call to any one of the
     385\ref Evaluation_Methods used the same value for \c x.
     386
     387\param[out] obj_value
     388is the value of the objective f(x) at this value of \c x.
     389
     390\return
     391The return value is always true; see \ref Evaluation_Methods.
     392
     393\par Efficiency
     394This routine could be more efficient
     395(for certain when when L[k] > 1 and retape[k] is true)
     396if the users also provided a version
     397of the function <tt>fg_info->eval_r(k, u)</tt> where \c u was of type
     398\c NumberVector.
     399*/
    212400bool cppad_ipopt_nlp::eval_f(
    213401        Index n, const Number* x, bool new_x, Number& obj_value
    214402)
    215 {       // This routine is not efficient. It would be better if users version
    216         // of the function was templated so that we could use double to
    217         // calculate function values instead of retaping (when necessary).
     403{
    218404        CPPAD_ASSERT_UNKNOWN(size_t(n) == n_ );
    219405
     
    258444                }
    259445        }
    260 # if CPPAD_NLP_TRACE
     446# if CPPAD_IPOPT_NLP_TRACE
    261447        using std::printf;
    262448        for(j = 0; j < n_; j++)
     
    267453}
    268454
     455/*!
     456Evaluate the gradient of f(x).
     457
     458\param[in] n
     459is the dimension of the argument space for f(x); i.e., must be equal \c n_.
     460
     461\param[in] x
     462has a vector of size \c n containing the point at which to evaluate
     463the gradient of f(x).
     464
     465\param[in] new_x
     466is true if the previous call to any one of the
     467\ref Evaluation_Methods used the same value for \c x.
     468
     469\param[out] grad_f
     470is a vector of size \c n.
     471The input value of its elements does not matter.
     472The output value of its elements is the gradient of f(x)
     473at this value of.
     474
     475\return
     476The return value is always true; see \ref Evaluation_Methods.
     477*/
    269478bool cppad_ipopt_nlp::eval_grad_f(
    270479        Index n, const Number* x, bool new_x, Number* grad_f
     
    321530                }
    322531        }
    323 # if CPPAD_NLP_TRACE
     532# if CPPAD_IPOPT_NLP_TRACE
    324533        using std::printf;
    325534        for(j = 0; j < n_; j++) printf(
     
    333542}
    334543
     544/*!
     545Evaluate the function g(x).
     546
     547\param[in] n
     548is the dimension of the argument space for g(x); i.e., must be equal \c n_.
     549
     550\param[in] x
     551has a vector of size \c n containing the point at which to evaluate
     552the gradient of g(x).
     553
     554\param[in] new_x
     555is true if the previous call to any one of the
     556\ref Evaluation_Methods used the same value for \c x.
     557
     558\param[in] m
     559is the dimension of the range space for g(x); i.e., must be equal to \c m_.
     560
     561\param[out] g
     562is a vector of size \c m.
     563The input value of its elements does not matter.
     564The output value of its elements is
     565the value of the function g(x) at this value of \c x.
     566
     567\return
     568The return value is always true; see \ref Evaluation_Methods.
     569*/
    335570bool cppad_ipopt_nlp::eval_g(
    336571        Index n, const Number* x, bool new_x, Index m, Number* g
     
    381616                }
    382617        }
    383 # if CPPAD_NLP_TRACE
     618# if CPPAD_IPOPT_NLP_TRACE
    384619        using std::printf;
    385620        for(j = 0; j < n_; j++)
     
    391626}
    392627
     628/*!
     629Evaluate the Jacobian of g(x).
     630
     631\param[in] n
     632is the dimension of the argument space for g(x); i.e., must be equal \c n_.
     633
     634\param x
     635if \c values is not \c NULL,
     636\c x is a vector of size \c n containing the point at which to evaluate
     637the gradient of g(x).
     638
     639\param[in] new_x
     640is true if the previous call to any one of the
     641\ref Evaluation_Methods used the same value for \c x.
     642
     643\param[in] m
     644is the dimension of the range space for g(x); i.e., must be equal to \c m_.
     645
     646\param[in] nele_jac
     647is the number of possibly non-zero elements in the Jacobian of g(x);
     648i.e., must be equal to \c nnz_jac_g_.
     649
     650\param iRow
     651if \c values is not \c NULL, \c iRow is not defined.
     652if \c values is \c NULL, \c iRow
     653is a vector with size \c nele_jac.
     654The input value of its elements does not matter.
     655On output,
     656For <tt>k = 0 , ... , nele_jac-1, iRow[k]</tt> is the
     657base zero row index for the
     658k-th possibly non-zero entry in the Jacobian of g(x).
     659
     660\param jCol
     661if \c values is not \c NULL, \c jCol is not defined.
     662if \c values is \c NULL, \c jCol
     663is a vector with size \c nele_jac.
     664The input value of its elements does not matter.
     665On output,
     666For <tt>k = 0 , ... , nele_jac-1, jCol[k]</tt> is the
     667base zero column index for the
     668k-th possibly non-zero entry in the Jacobian of g(x).
     669
     670\param values
     671if \c values is not \c NULL, \c values
     672is a vector with size \c nele_jac.
     673The input value of its elements does not matter.
     674On output,
     675For <tt>k = 0 , ... , nele_jac-1, values[k]</tt> is the
     676value for the
     677k-th possibly non-zero entry in the Jacobian of g(x).
     678
     679\return
     680The return value is always true; see \ref Evaluation_Methods.
     681*/
    393682bool cppad_ipopt_nlp::eval_jac_g(Index n, const Number* x, bool new_x,
    394683                       Index m, Index nele_jac, Index* iRow, Index *jCol,
    395684                       Number* values)
    396 {       CPPAD_ASSERT_UNKNOWN(size_t(m) == m_ );
    397         CPPAD_ASSERT_UNKNOWN(size_t(n) == n_ );
     685{       CPPAD_ASSERT_UNKNOWN(size_t(m)          == m_ );
     686        CPPAD_ASSERT_UNKNOWN(size_t(n)          == n_ );
     687        CPPAD_ASSERT_UNKNOWN( size_t(nele_jac)  == nnz_jac_g_ );
    398688
    399689        size_t i, j, k, ell, l;
     
    464754}
    465755
     756/*!
     757Evaluate the Hessian of the Lagragian
     758
     759\section The_Hessian_of_the_Lagragian The Hessian of the Lagragian
     760The Hessian of the Lagragian is defined as
     761\f[
     762H(x, \sigma, \lambda )
     763=
     764\sigma \nabla^2 f(x) + \sum_{i=0}^{m-1} \lambda_i \nabla^2 g(x)_i
     765\f]
     766
     767\param[in] n
     768is the dimension of the argument space for g(x); i.e., must be equal \c n_.
     769
     770\param x
     771if \c values is not \c NULL, \c x
     772is a vector of size \c n containing the point at which to evaluate
     773the gradient of g(x).
     774
     775\param[in] new_x
     776is true if the previous call to any one of the
     777\ref Evaluation_Methods used the same value for \c x.
     778
     779\param[in] obj_factor
     780the value \f$ \sigma \f$ multiplying the Hessian of
     781f(x) in the expression for \ref The_Hessian_of_the_Lagragian.
     782
     783\param[in] m
     784is the dimension of the range space for g(x); i.e., must be equal to \c m_.
     785
     786\param[in] lambda
     787if \c values is not \c NULL, \c lambda
     788is a vector of size \c m specifing the value of \f$ \lambda \f$
     789in the expression for \ref The_Hessian_of_the_Lagragian.
     790
     791\param[in] new_lambda
     792is true if the previous call to \c eval_h had the same value for
     793\c lambda and false otherwise.
     794(Not currently used.)
     795
     796\param[in] nele_hess
     797is the number of possibly non-zero elements in the Hessian of the Lagragian;
     798i.e., must be equal to \c nnz_h_lag_.
     799
     800\param iRow
     801if \c values is not \c NULL, \c iRow is not defined.
     802if \c values is \c NULL, \c iRow
     803is a vector with size \c nele_jac.
     804The input value of its elements does not matter.
     805On output,
     806For <tt>k = 0 , ... , nele_jac-1, iRow[k]</tt> is the
     807base zero row index for the
     808k-th possibly non-zero entry in the Jacobian of g(x).
     809
     810\param jCol
     811if \c values is not \c NULL, \c jCol is not defined.
     812if \c values is \c NULL, \c jCol
     813is a vector with size \c nele_jac.
     814The input value of its elements does not matter.
     815On output,
     816For <tt>k = 0 , ... , nele_jac-1, jCol[k]</tt> is the
     817base zero column index for the
     818k-th possibly non-zero entry in the Jacobian of g(x).
     819
     820\param values
     821if \c values is not \c NULL, it
     822is a vector with size \c nele_jac.
     823The input value of its elements does not matter.
     824On output,
     825For <tt>k = 0 , ... , nele_jac-1, values[k]</tt> is the
     826value for the
     827k-th possibly non-zero entry in the Jacobian of g(x).
     828
     829\return
     830The return value is always true; see \ref Evaluation_Methods.
     831*/
    466832bool cppad_ipopt_nlp::eval_h(Index n, const Number* x, bool new_x,
    467833                   Number obj_factor, Index m, const Number* lambda,
     
    495861        for(k = 0; k < K_; k++) for(ell = 0; ell < L_[k]; ell++)
    496862        {       fg_info_->index(k, ell, I_, J_);
    497                 if( ! tape_ok_[k] )
    498                 {       // Record r_k for value of u corresponding to x
    499                         fun_record(
    500                                 fg_info_        ,   // inputs
    501                                 k               ,
    502                                 p_              ,
    503                                 q_              ,
    504                                 n_              ,
    505                                 x               ,
    506                                 J_              ,
    507                                 r_fun_              // output
     863                bool in_use = false;
     864                for(i = 0; i < p_[k]; i++)
     865                {       if( I_[i] == 0 )
     866                                in_use |= obj_factor > 0.;
     867                        else    in_use |= lambda[ I_[i] - 1 ] > 0;
     868                }
     869                if( in_use )
     870                {
     871                        if( ! tape_ok_[k]  )
     872                        {       // Record r_k for value of u corresponding to x
     873                                fun_record(
     874                                        fg_info_        ,   // inputs
     875                                        k               ,
     876                                        p_              ,
     877                                        q_              ,
     878                                        n_              ,
     879                                        x               ,
     880                                        J_              ,
     881                                        r_fun_              // output
     882                                );
     883                                if( retape_[k] )
     884                                        tape_ok_[k] = L_[k] <= 1;
     885                                else    tape_ok_[k] = true;
     886                        }
     887                        NumberVector w(p_[k]);
     888                        NumberVector r_hes(q_[k] * q_[k]);
     889                        NumberVector u(q_[k]);
     890                        for(j = 0; j < q_[k]; j++)
     891                        {       CPPAD_ASSERT_UNKNOWN( J_[j] < n_ );
     892                                u[j]   = x[ J_[j] ];
     893                        }
     894                        for(i = 0; i < p_[k]; i++)
     895                        {       CPPAD_ASSERT_UNKNOWN( I_[i] <= m_ );
     896                                if( I_[i] == 0 )
     897                                        w[i] = obj_factor;
     898                                else    w[i] = lambda[ I_[i] - 1 ];
     899                        }
     900                        if( retape_[k] )
     901                                r_hes = r_fun_[k].Hessian(u, w);
     902                        else    r_hes = r_fun_[k].SparseHessian(
     903                                        u, w, pattern_hes_r_[k]
    508904                        );
    509                 if( retape_[k] )
    510                         tape_ok_[k] = L_[k] <= 1;
    511                 else    tape_ok_[k] = true;
    512                 }
    513                 NumberVector w(p_[k]);
    514                 NumberVector r_hes(q_[k] * q_[k]);
    515                 NumberVector u(q_[k]);
    516                 for(j = 0; j < q_[k]; j++)
    517                 {       CPPAD_ASSERT_UNKNOWN( J_[j] < n_ );
    518                         u[j]   = x[ J_[j] ];
    519                 }
    520                 for(i = 0; i < p_[k]; i++)
    521                 {       CPPAD_ASSERT_UNKNOWN( I_[i] <= m_ );
    522                         if( I_[i] == 0 )
    523                                 w[i] = obj_factor;
    524                         else    w[i] = lambda[ I_[i] - 1 ];
    525                 }
    526                 if( retape_[k] )
    527                         r_hes = r_fun_[k].Hessian(u, w);
    528                 else    r_hes =
    529                         r_fun_[k].SparseHessian(u, w, pattern_r_lag_[k]);
    530                 for(i = 0; i < q_[k]; i++)
    531                 {       for(j = 0; j < q_[k]; j++) if( J_[j] <= J_[i] )
     905                        for(i = 0; i < q_[k]; i++) for(j = 0; j < q_[k]; j++)
     906                        if( J_[j] <= J_[i] )
    532907                        {       index_ij = index_hes_fg_[J_[i]].find(J_[j]);
    533908                                if( index_ij != index_hes_fg_[J_[i]].end() )
     
    544919}
    545920
     921/*!
     922Pass solution information from Ipopt to users solution structure.
     923
     924\param[in] status
     925is value that the Ipopt solution status
     926which gets mapped to a correponding value for
     927\n
     928<tt>solution_->status</tt>.
     929
     930\param[in] n
     931is the dimension of the domain space for f(x) and g(x); i.e.,
     932it must be equal to \c n_.
     933
     934\param[in] x
     935is a vector with size \c n specifing the final solution.
     936\n
     937<tt>solution_->x</tt> is set to be a vector with size \c n
     938and to have the same element values.
     939
     940\param[in] z_L
     941is a vector with size \c n specifing the Lagragian multipliers for the
     942constraint \f$ x^l \leq x \f$.
     943\n
     944<tt>solution_->z_l</tt> is set to be a vector with size \c n
     945and to have the same element values.
     946
     947\param[in] z_U
     948is a vector with size \c n specifing the Lagragian multipliers for the
     949constraint \f$ x \leq x^u \f$.
     950\n
     951<tt>solution_->z_u</tt> is set to be a vector with size \c n
     952and to have the same element values.
     953
     954\param[in] m
     955is the dimension of the domain space for f(x) and g(x). i.e.,
     956it must be equal to \c m_.
     957
     958\param[in] g
     959is a vector with size \c m containing the value of the constraint function
     960g(x) at the final solution for \c x.
     961\n
     962<tt>solution_->g</tt> is set to be a vector with size \c m
     963and to have the same element values.
     964
     965\param[in] lambda
     966is a vector with size \c m specifing the Lagragian multipliers for the
     967constraints \f$ g^l \leq g(x) \leq g^u \f$.
     968\n
     969<tt>solution_->lambda</tt> is set to be a vector with size \c m
     970and to have the same element values.
     971
     972\param[in] obj_value
     973is the value of the objective function f(x) at the final solution for \c x.
     974\n
     975<tt>solution_->obj_value</tt> is set to have the same value.
     976
     977\param[in] ip_data
     978is unspecified (by Ipopt) and hence not used.
     979
     980\param[in] ip_cq
     981is unspecified (by Ipopt) and hence not used.
     982
     983\par solution_[out]
     984the pointer \c solution_ , which is equal to the pointer \c solution
     985in the constructor for \c cppad_ipopt_nlp,
     986is used to set output values (see documentation above).
     987*/
    546988void cppad_ipopt_nlp::finalize_solution(
    547989        Ipopt::SolverReturn               status    ,
  • trunk/cppad_ipopt/src/cppad_ipopt_nlp.hpp

    r1636 r1637  
    567567uses a more complex representation.
    568568
     569$head Wish List$$
     570This is a list of possible future improvements to
     571$code cppad_ipopt_nlp$$ that would require changed to the user interface:
     572$list number$$
     573The routine $codei%fg_info.eval_r(%k%, %u%)%$$ should also support
     574$codei NumberVector$$ for the type of the argument $code u$$
     575(this would certainly be more efficient when
     576$codei%fg_info.retape(%k%)%$$ is true and $latex L(k) > 1$$).
     577It could be an option for the user to provide this as well as
     578the necessary $code ADVector$$ definition.
     579$lnext
     580There should a $cref/Discrete/$$ routine that the user can call
     581to determine the value of $latex \ell$$ during the evaluation of
     582$codei%fg_info.eval_r(%k%, %u%)%$$.
     583This way data, which does not affect the derivative values,
     584can be included in the function recording and evaluation.
     585$lend
     586
    569587$end
    570588-----------------------------------------------------------------------------
    571589*/
    572 
    573 
    574590# include <cppad/cppad.hpp>
    575591# include <coin/IpIpoptApplication.hpp>
    576592# include <coin/IpTNLP.hpp>
    577593
     594/*!
     595\file cppad_ipopt_nlp.hpp
     596\brief CppAD interface to Ipopt
     597*/
     598
     599
     600/// A scalar value used to record operation sequence.
    578601typedef CppAD::AD<Ipopt::Number>       ADNumber;
     602/// A simple vector of values used to record operation sequence
     603typedef CppAD::vector<ADNumber>        ADVector;
     604/// A simple vector of size_t values.
    579605typedef CppAD::vector<size_t>          SizeVector;
     606/// A simple vector of values used by Ipopt
    580607typedef CppAD::vector<Ipopt::Number>   NumberVector;
    581 typedef CppAD::vector<ADNumber>        ADVector;
    582 
    583 /*
    584 Class for return solution values.
     608
     609/*!
     610Abstract base class user derives from to define the funcitons in the problem.
    585611*/
    586612class cppad_ipopt_fg_info
    587613{
     614        /// allow cppad_ipopt_nlp class complete access to this class
    588615        friend class cppad_ipopt_nlp;
    589616private:
     617        /// domain space dimension for the functions f(x), g(x)
    590618        size_t n_;
     619        /// range space dimension for the function g(x)
    591620        size_t m_;
    592 
     621        /// the cppad_ipopt_nlp constructor uses this method to set n_
    593622        void set_n(size_t n)
    594623        {       n_ = n; }
     624        /// the cppad_ipopt_nlp constructor uses this method to set m_
    595625        void set_m(size_t m)
    596626        {       m_ = m; }
    597627
    598628public:
    599         // make destructor virtual so that derived class destructor gets called
     629        /// destructor virtual so user derived class destructor gets called
    600630        virtual ~cppad_ipopt_fg_info(void)
    601631        { }
    602         // number_functions: for simple representation
     632        /// number_functions; i.e. K (simple representation uses 1)
    603633        virtual size_t number_functions(void)
    604634        {       return 1; }
    605         // eval_r: pure virtual so that it must be defined by derived class
     635        /// function that evaluates the users representation for f(x) and
     636        /// and g(x) is pure virtual so user must define it in derived class
    606637        virtual ADVector eval_r(size_t k, const ADVector& u) = 0;
    607         // retape: default definition
     638        /// should the function r_k (u) be retaped when ever the arguemnt
     639        /// u changes (default is true which is safe but slow)
    608640        virtual bool retape(size_t k)
    609641        {       return true; }
    610         // domain_size: for simple representation
     642        /// domain_size q[k] for r_k (u) (simple representation uses n)
    611643        virtual size_t domain_size(size_t k)
    612644        {       return n_; }
    613         // range_size: for simple representation
     645        /// range_size p[k] for r_k (u) (simple representation uses m+1)
    614646        virtual size_t range_size(size_t k)
    615647        {       return m_ + 1; }
    616         // number_terms: for simple representation
     648        /// number_terms that use r_k (u) (simple represenation uses 1)
    617649        virtual size_t number_terms(size_t k)
    618650        {       return 1; }
    619         // index: for simple representation
     651        /// return the index vectors I_{k,ell} and J_{k,ell}
     652        /// (simple representation uses I[i] = i and J[j] = j)
    620653        virtual void index(size_t k, size_t ell, SizeVector& I, SizeVector& J)
    621654        {       assert( I.size() >= m_ + 1 );
     
    628661};
    629662
     663/*!
     664Class that contains information about the problem solution
     665
     666\section Nonlinear_Programming_Problem Nonlinear Programming Problem
     667We are give smooth functions
     668\f$ f : {\bf R}^n \rightarrow {\bf R} \f$
     669and
     670\f$ g : {\bf R}^n \rightarrow {\bf R}^m \f$
     671and wish to solve the problem
     672\f[
     673\begin{array}{rcl}
     674{\rm minimize} & f(x) & {\rm w.r.t.} \; x \in {\bf R}^n
     675\\
     676{\rm subject \; to} & g^l \leq g(x) \leq g^u
     677\\
     678& x^l \leq x \leq x^u
     679\end{array}
     680\f]
     681
     682
     683\section Users_Representation Users Representation
     684The functions
     685\f$ f : {\bf R}^n \rightarrow {\bf R} \f$ and
     686\f$ g : {\bf R}^n \rightarrow {\bf R}^m \f$ are defined by
     687\f[
     688\left( \begin{array}{c} f(x) \\ g(x) \end{array} \right)
     689=
     690\sum_{k=0}^{K-1} \; \sum_{\ell=0}^{L(k) - 1}
     691[ (m+1) \otimes I_{k,\ell} ] \; \circ
     692         \; r_k \; \circ \; [ J_{k,\ell} \otimes n ] \; (x)
     693\f]
     694where for \f$ k = 0 , \ldots , K-1\f$,
     695\f$ r_k : {\bf R}^{q(k)} \rightarrow {\bf R}^{p(k)} \f$.
     696
     697\section Evaluation_Methods Evaluation Methods
     698The set of evaluation methods for this class is
     699\verbatim
     700        { eval_f, eval_grad_f, eval_g, eval_jac_g, eval_h }
     701\endverbatim
     702Note that the \c bool return flag for the evaluations methods
     703does not appear in the Ipopt documentation.
     704Looking at the code, it seems to be a flag telling Ipopt to abort
     705when the flag is false.
     706
     707*/
    630708class cppad_ipopt_solution
    631709{
    632710public:
     711        /// possible values for he solution status
    633712        enum solution_status {
    634713                not_defined,
     
    648727                unknown
    649728        }  status;
     729        /// the approximation solution
    650730        NumberVector      x;
     731        /// Lagrange multipliers corresponding to lower bounds on x
    651732        NumberVector      z_l;
     733        /// Lagrange multipliers corresponding to upper bounds on x
    652734        NumberVector      z_u;
     735        /// value of g(x)
    653736        NumberVector      g;
     737        /// Lagrange multipliers correspondiing constraints on g(x)
    654738        NumberVector      lambda;
     739        /// value of f(x)
    655740        Ipopt::Number     obj_value;
    656 
     741        /// constructor initializes solution status as not yet defined
    657742        cppad_ipopt_solution(void)
    658743        {       status = not_defined; }
    659744};
    660745
    661 /*
    662 Class for interfacing a problem to IPOPT and using CppAD for derivative
    663 and sparsity pattern calculations.
     746/*!
     747Class connects Ipopt to CppAD for derivative and sparsity pattern calculations.
    664748*/
    665749class cppad_ipopt_nlp : public Ipopt::TNLP
    666750{
     751private:
     752        /// A Scalar value used by Ipopt
    667753        typedef Ipopt::Number                         Number;
     754        /// An index value used by Ipopt
    668755        typedef Ipopt::Index                          Index;
     756        /// Indexing style used in Ipopt sparsity structure
    669757        typedef Ipopt::TNLP::IndexStyleEnum           IndexStyleEnum;
     758        /// A simple vector of boolean values
    670759        typedef CppAD::vectorBool                     BoolVector;
     760        /// A simple vector of AD function objects
    671761        typedef CppAD::vector< CppAD::ADFun<Number> > ADFunVector;
     762        /// A simple vector of simple vectors of boolean values
    672763        typedef CppAD::vector<BoolVector>             BoolVectorVector;
    673 
     764        /// A mapping that is dense in i, sparse in j, and maps (i, j)
     765        /// to the corresponding sparsity index in Ipopt.
    674766        typedef CppAD::vector< std::map<size_t,size_t> > IndexMap;
     767
     768        // ------------------------------------------------------------------
     769        // Values directly passed in to constuctor
     770        // ------------------------------------------------------------------
     771        /// dimension of the domain space for f(x) and g(x)
     772        /// (passed to ctor)
     773        const size_t                    n_;
     774        /// dimension of the range space for g(x)
     775        /// (passed to ctor)
     776        const size_t                    m_;
     777        /// dimension of the range space for g(x)
     778        /// (passed to ctor)
     779        const NumberVector              x_i_;
     780        /// lower limit for x
     781        /// (size n_), (passed to ctor)
     782        const NumberVector              x_l_;
     783        /// upper limit for x
     784        /// (size n_) (passed to ctor)
     785        const NumberVector              x_u_;
     786        /// lower limit for g(x)
     787        /// (size m_) (passed to ctor)
     788        const NumberVector              g_l_;
     789        /// upper limit for g(x)
     790        /// (size m_) (passed to ctor)
     791        const NumberVector              g_u_;
     792        /// pointer to base class version of derived class object used to get
     793        /// information about the user's representation for f(x) and g(x)
     794        /// (passed to ctor)
     795        cppad_ipopt_fg_info* const      fg_info_;
     796        /// pointer to object where final results are stored
     797        /// (passed to ctor)
     798        cppad_ipopt_solution* const     solution_;
     799
     800        // ------------------------------------------------------------------
     801        // Effectively const values determined during constructor using calls
     802        // to fg_info:
     803        // ------------------------------------------------------------------
     804        /// The value of \f$ K \f$ in the representation.
     805        /// (effectively const)
     806        size_t                 K_;
     807        /// Does operation sequence for \f$ r_k (u) \f$ depend on \f$ u \f$.
     808        /// (size K_) (effectively const)
     809        BoolVector             retape_;
     810        /// <tt>q_[k]</tt> is the domain space dimension for \f$ r_k (u) \f$
     811        /// (size K_) (effectively const)
     812        SizeVector             q_;
     813        /// <tt>p_[k]</tt> is the range space dimension for \f$ r_k (u) \f$
     814        /// (size K_) (effectively const)
     815        SizeVector             p_;
     816        /// <tt>L_[k]</tt> is number of times \f$ r_k (u) \f$ appears in
     817        /// the representation summation
     818        /// (size K_) (effectively const)
     819        SizeVector             L_;
     820        // -------------------------------------------------------------------
     821        // Other effectively const values determined by the constructor:
     822        // -------------------------------------------------------------------
     823        /*!
     824        CppAD sparsity patterns for \f$ \{ r_k^{(1)} (u) \} \f$ (set by ctor).
     825
     826        For <tt>k = 0 , ... , K_-1, pattern_jac_r_[k]</tt>
     827        is a CppAD sparsity pattern for the Jacobian of \f$ r_k (u) \f$
     828        and as such it has size <tt>p_[k]*q_[k]</tt>.
     829        (effectively const)
     830        */
     831        BoolVectorVector                 pattern_jac_r_;
     832
     833        /*!
     834        CppAD sparsity patterns for \f$ \{ r_k^{(2)} (u) \} \f$ (set by ctor).
     835
     836        For <tt>k = 0 , ... , K_-1, pattern_jac_r_[k]</tt>
     837        is a CppAD sparsity pattern for the Hessian of
     838        \f[
     839                R(u) = \sum_{i=0}^{p[k]-1}  r_k (u)_i
     840        \f]
     841        and as such it has size <tt>q_[k]*q_[k]</tt>.
     842        (effectively const)
     843        */
     844        BoolVectorVector                 pattern_hes_r_;
     845
     846        /// number non-zero is Ipopt sparsity structor for Jacobian of g(x)
     847        /// (effectively const)
     848        size_t                           nnz_jac_g_;
     849        /// row indices in Ipopt sparsity structor for Jacobian of g(x)
     850        /// (effectively const)
     851        SizeVector                       iRow_jac_g_;
     852        /// column indices in Ipopt sparsity structor for Jacobian of g(x)
     853        /// (effectively const)
     854        SizeVector                       jCol_jac_g_;
     855
     856        /// number non-zero is Ipopt sparsity structor for Hessian of Lagragian
     857        /// (effectively const)
     858        size_t                           nnz_h_lag_;
     859        /// row indices in Ipopt sparsity structor for Hessian of Lagragian
     860        /// (effectively const)
     861        SizeVector                       iRow_h_lag_;
     862        /// column indices in Ipopt sparsity structor for Hessian of Lagragian
     863        /// (effectively const)
     864        SizeVector                       jCol_h_lag_;
     865
     866        /*!
     867        Mapping from (i, j) in Jacobian of g(x) to Ipopt sparsity structure
     868
     869        For <tt>i = 0 , ... , m_-1, index_jac_g_[i]</tt>
     870        is a standard map from column index values \c j to the corresponding
     871        index in the Ipopt sparsity structure for the Jacobian of g(x).
     872        */
     873        IndexMap                         index_jac_g_;
     874
     875        /*!
     876        Mapping from (i, j) in Hessian of fg(x) to Ipopt sparsity structure
     877
     878        For <tt>i = 0 , ... , n_-1, index_hes_fg_[i]</tt>
     879        is a standard map from column index values \c j to the corresponding
     880        index in the Ipopt sparsity structure for the Hessian of the Lagragian.
     881        */
     882        IndexMap                         index_hes_fg_;
     883        // -----------------------------------------------------------------
     884        // Values that are changed by routine other than the constructor:
     885        // -----------------------------------------------------------------
     886
     887        /// For <tt>k = 0 , ... , K_-1, r_fun_[k]</tt>
     888        /// is a the CppAD function object corresponding to \f$ r_k (u) \f$.
     889        ADFunVector                      r_fun_;
     890        /*!
     891        Is r_fun[k] OK for current x.
     892 
     893        For <tt>k = 0 , ... , K_-1, tape_ok_[k]</tt>
     894        is true if current operations sequence in <tt>r_fun_[k]</tt>
     895        OK for this value of \f$ x \f$.
     896        Note that \f$ u = [ J_{k,\ell} \otimes n ] (x) \f$ may depend on the
     897        value of \f$ \ell \f$.
     898        */
     899        BoolVector             tape_ok_;
     900
     901        /// work space of size equal maximum of <tt>q[k]</tt> w.r.t \c k.
     902        SizeVector             J_;
     903        /// work space of size equal maximum of <tt>p[k]</tt> w.r.t \c k.
     904        SizeVector             I_;
     905        // ------------------------------------------------------------
     906        // Private Methods
     907        // ------------------------------------------------------------
     908        /// block the default constructor from use
     909        cppad_ipopt_nlp(const cppad_ipopt_nlp&);
     910        /// blocks the assignment operator from use
     911        cppad_ipopt_nlp& operator=(const cppad_ipopt_nlp&);
    675912public:
    676         // constructor
     913        // ----------------------------------------------------------------
     914        // See cppad_ipopt_nlp.hpp for doxygen documentation of these methods
     915        // ----------------------------------------------------------------
     916
     917        /// only constructor for cppad_ipopot_nlp
    677918        cppad_ipopt_nlp(
    678919                size_t n                         ,
     
    687928        );
    688929
    689 
    690         // default destructor
     930        // use virtual so that derived class destructor gets called.
    691931        virtual ~cppad_ipopt_nlp();
    692932
     
    7941034                Ipopt::IpoptCalculatedQuantities* ip_cq
    7951035        );
    796 private:
    797         /*
    798         Values passed in by user
    799         */
    800         // dimension of the domain space
    801         const size_t                    n_;
    802         // number of components in g
    803         const size_t                    m_;
    804         // initial x
    805         const NumberVector              x_i_;
    806         // limits for x and g
    807         const NumberVector              x_l_;
    808         const NumberVector              x_u_;
    809         const NumberVector              g_l_;
    810         const NumberVector              g_u_;
    811         // Users function that evaluates f and g
    812         cppad_ipopt_fg_info* const      fg_info_;
    813         // object for storing final solution results
    814         cppad_ipopt_solution* const     solution_;
    815         // values determined by fg_info
    816         size_t                 K_;      // number terms in summation
    817         BoolVector             retape_; // for operations sequence of r_k (u)
    818         BoolVector             tape_ok_;// tape is ok for current value of x
    819         SizeVector             q_;      // dimension of domain for r_k (u)
    820         SizeVector             p_;      // dimension of range for r_k (u)
    821         SizeVector             L_;      // number of r_k (u) terms
    822         SizeVector             J_;      // index vector for domain
    823         SizeVector             I_;      // index vector for range
    824         /*
    825         Computed values
    826         */
    827         // CppAD sparsity patterns
    828         BoolVectorVector                 pattern_jac_r_;
    829         BoolVectorVector                 pattern_r_lag_;
    830         // Ipopt sparsity structure for Jacobian of g
    831         size_t                           nnz_jac_g_;
    832         SizeVector                       iRow_jac_g_;
    833         SizeVector                       jCol_jac_g_;
    834         // mapping from array indices to Ipopt sparsity structure
    835         IndexMap                         index_jac_g_;
    836         IndexMap                         index_hes_fg_;
    837         // Ipopt sparsity structure for Hessian of Lagragian
    838         size_t                           nnz_h_lag_;
    839         SizeVector                       iRow_h_lag_;
    840         SizeVector                       jCol_h_lag_;
    841         // CppAD function object for both f and g as one function
    842         ADFunVector                      r_fun_;
    843         /*
    844         Methods
    845         */
    846         // Methods to block default compiler methods.
    847         cppad_ipopt_nlp(const cppad_ipopt_nlp&);
    848         cppad_ipopt_nlp& operator=(const cppad_ipopt_nlp&);
    8491036
    8501037};
  • trunk/cppad_ipopt/src/hes_fg_map.cpp

    r1636 r1637  
    2323The functions
    2424\f$ f : {\bf R}^n \rightarrow {\bf R} \f$ and
    25 \f$ g : {\bf R}^n \rightarrow {\bf R}^m \f$ are defined by
    26 \f[
    27 \left( \begin{array}{c} f(x) \\ g(x) \end{array} \right)
    28 =
    29 \sum_{k=0}^{K-1} \; \sum_{\ell=0}^{L(k) - 1}
    30 [ (m+1) \otimes I_{k,\ell} ] \; \circ
    31          \; r_k \; \circ \; [ J_{k,\ell} \otimes n ] \; (x)
    32 \f]
    33 where for \f$ k = 0 , \ldots , K-1\f$,
    34 \f$ r_k : {\bf R}^{q(k)} \rightarrow {\bf R}^{p(k)} \f$.
     25\f$ g : {\bf R}^n \rightarrow {\bf R}^m \f$ are defined by the
     26\ref Users_Representation.
    3527We define the function
    3628\f$ F : {\bf R}^n \rightarrow {\bf R} \f$ by
  • trunk/cppad_ipopt/src/jac_g_map.cpp

    r1634 r1637  
    2424\f$ f : {\bf R}^n \rightarrow {\bf R} \f$ and
    2525\f$ g : {\bf R}^n \rightarrow {\bf R}^m \f$ are defined by
    26 \f[
    27 \left( \begin{array}{c} f(x) \\ g(x) \end{array} \right)
    28 =
    29 \sum_{k=0}^{K-1} \; \sum_{\ell=0}^{L(k) - 1}
    30 [ (m+1) \otimes I_{k,\ell} ] \; \circ
    31          \; r_k \; \circ \; [ J_{k,\ell} \otimes n ] \; (x)
    32 \f]
    33 where for \f$ k = 0 , \ldots , K-1\f$,
    34 \f$ r_k : {\bf R}^{q(k)} \rightarrow {\bf R}^{p(k)} \f$.
     26the \ref Users_Representation.
    3527
    3628\param fg_info
  • trunk/cppad_ipopt/test/makefile.in

    r1636 r1637  
    8686CYGPATH_W = @CYGPATH_W@
    8787
    88 # $Id: makefile.am 1634 2010-01-24 08:44:17Z bradbell $
     88# $Id: makefile.am 1636 2010-01-25 04:57:24Z bradbell $
    8989# -----------------------------------------------------------------------------
    9090# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-10 Bradley M. Bell
  • trunk/doxyfile.in

    r1632 r1637  
    184184# be part of the file/class/namespace that contains it.
    185185
    186 SEPARATE_MEMBER_PAGES  = NO
     186SEPARATE_MEMBER_PAGES  = YES
    187187
    188188# The TAB_SIZE tag can be used to set the number of spaces in a tab.
     
    280280# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
    281281
    282 EXTRACT_ALL            = NO
     282EXTRACT_ALL            = YES
    283283
    284284# If the EXTRACT_PRIVATE tag is set to YES all private members of a class
     
    514514# to stderr.
    515515
    516 WARN_LOGFILE           =
     516WARN_LOGFILE           =  doxygen.err
    517517
    518518#---------------------------------------------------------------------------
     
    661661# called/used by that function will be listed.
    662662
    663 REFERENCES_RELATION    = YES
     663REFERENCES_RELATION    = NO
    664664
    665665# If the REFERENCES_LINK_SOURCE tag is set to YES (the default)
  • trunk/omh/whats_new_10.omh

    r1636 r1637  
    1313$begin whats_new_10$$
    1414$spell
     15        Lagragian
    1516        iostream
    1617        obj_value
     
    3435assist you in learning about changes between various versions of CppAD.
    3536
     37$head 01-26$$
     38Another speed improvement was made to $cref/cppad_ipopt_nlp/$$.
     39To be specific, the Lagragian multipliers where checked and components
     40that were zero were excluded form the Hessian evaluation.
     41
    3642$head 01-24$$
    3743It appears that in $cref/cppad_ipopt_nlp/$$, when $code retape[k]$$ was true,
     
    4955There was a bug in the $cref/ipopt_ode_check.cpp/$$ program,
    5056for a long time,  that did not show up until now. Basically,
    51 the check had code of the form:
    52 $codep
    53         # include <iostream>
    54         int main()
    55         {       double obj_value = obj_value;
    56                 std::cout << "obj_value = " << obj_value << std::endl;
    57         }
    58 $$
    59 The value of $code obj_value$$ is unspecified,
    60 but gcc 4.4.2 (and previous versions) did not give any indication of this.
     57the check had code of the was using an undefined value.
     58This has been fixed.
    6159
    6260$head 01-23$$
Note: See TracChangeset for help on using the changeset viewer.