ADMB Documentation  11.1.1927
 All Classes Files Functions Variables Typedefs Friends Defines
trunc.hpp
Go to the documentation of this file.
00001 /*
00002  * $Id: trunc.hpp 1729 2014-03-04 01:26:24Z johnoel $
00003  *
00004  * Author: David Fournier
00005  * Copyright (c) 2008-2012 Regents of the University of California
00006  *
00007  * ADModelbuilder and associated libraries and documentations are
00008  * provided under the general terms of the "New BSD" license
00009  *
00010  * License:
00011  *
00012  * Redistribution and use in source and binary forms, with or without
00013  * modification, are permitted provided that the following conditions are
00014  * met:
00015  *
00016  * 1. Redistributions of source code must retain the above copyright
00017  * notice, this list of conditions and the following disclaimer.
00018  *
00019  * 2.  Redistributions in binary form must reproduce the above copyright
00020  * notice, this list of conditions and the following disclaimer in the
00021  * documentation and/or other materials provided with the distribution.
00022  *
00023  * 3.  Neither the name of the  University of California, Otter Research,
00024  * nor the ADMB Foundation nor the names of its contributors may be used
00025  * to endorse or promote products derived from this software without
00026  * specific prior written permission.
00027  *
00028  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00029  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00030  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00031  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
00032  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00033  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00034  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00035  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00036  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00037  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00038  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00039  *
00040  */
00045 #ifndef FMMT_HPP
00046 #define FMMT_HPP
00047 
00048 #if defined(__GNUC__) && (__GNUC__ < 3)
00049   #pragma interface
00050 #endif
00051 
00052 /*
00053 class fmm_control
00054 {
00055 public:
00056   long   maxfn;
00057   long   iprint;
00058   double crit;
00059   long   imax;
00060   double dfn;
00061   long   ifn;
00062   long   iexit;
00063   long   ialph;
00064   long   ihflag;
00065   long   ihang;
00066   long   scroll_flag;
00067   int maxfn_flag;
00068   int quit_flag;
00069   double min_improve;
00070   int    ireturn;
00071 
00072   void set_defaults();
00073   fmm_control();
00074   fmm_control(const fmm_control&);
00075 #ifdef HOME_VERSION
00076 #include "insx014.h"
00077 #endif
00078   void writeon(const ostream& s) const;
00079 };
00080 */
00081 
00086 class fmmt : public fmm_control
00087 {
00088 private:
00089   dvector w;
00090   dvector funval;
00091   int m;
00092   int diagco;
00093 public:
00094   double dmin,fbest,df;
00095   double gmax;
00096   dvector gbest;
00097   dvector xbest;
00098   dvector diag;
00099   double eps;
00100   double xtol;
00101   double gtol;
00102   int nvar;
00103   long int iter;
00104   int ireturn1;
00105   int curriter;
00106   ivector iprint1;
00107 
00108 public:
00109   fmmt(int _nvar,int _m=7);
00110 
00111   double minimize(const independent_variables &x,
00112     double (*pf)(const dvar_vector&));
00113 
00114   double minimize(const independent_variables &x, const dvector& c,
00115                   double (*pf)(const dvar_vector&, const dvector&));
00116 
00117   void fmin(const double& f, const independent_variables &x, const dvector& g);
00118 
00119   dmatrix& hessian();
00120 };
00121 #endif