ADMB Documentation  11.1.1932
 All Classes Files Functions Variables Typedefs Friends Defines
model12.cpp
Go to the documentation of this file.
00001 /*
00002  * $Id: model12.cpp 1919 2014-04-22 22:02:01Z johnoel $
00003  *
00004  * Author: David Fournier
00005  * Copyright (c) 2008-2014 Regents of the University of California
00006  */
00007 #include <admodel.h>
00008 
00009 void initial_params::save(const ofstream& _ofs, int prec)
00010 {
00011   ofstream& ofs=(ofstream&)_ofs;
00012   ofs << setw(prec+6) << setshowpoint();
00013   for (int i=0;i<num_initial_params;i++)
00014   {
00015     (varsptr[i])->save_value(ofs,prec);
00016   }
00017 }
00018 
00019 void param_init_number::save_value(const ofstream& _ofs, int prec)
00020 {
00021   ofstream& ofs=(ofstream&)_ofs;
00022 #ifndef __ZTC__
00023   ofs << setprecision(prec) << dvariable(*this) << endl;
00024 #else
00025   ofs << setw(prec+6) << setprecision(prec) << *this << endl;
00026 #endif
00027 }
00028 
00029 void param_init_vector::save_value(const ofstream& _ofs, int prec)
00030 {
00031   ofstream& ofs=(ofstream&)_ofs;
00032   ofs << setw(prec+6) << setprecision(prec) << dvar_vector(*this) << endl;
00033 }
00034 
00035 void param_init_bounded_vector::save_value(const ofstream& _ofs, int prec)
00036 {
00037   ofstream& ofs=(ofstream&)_ofs;
00038   ofs << setw(prec+6) << setprecision(prec) << dvar_vector(*this) << endl;
00039 }
00040 
00041 void param_init_matrix::save_value(const ofstream& _ofs, int prec)
00042 {
00043   ofstream& ofs=(ofstream&)_ofs;
00044   ofs << setw(prec+6) << setprecision(prec) << dvar_matrix(*this) << endl;
00045 }
00046 
00047 void param_init_number::save_value(const ofstream& _ofs, int prec,
00048   const dvector& g, int& offset)
00049 {
00050   ADUNCONST(ofstream,ofs)
00051   ofs << label() << " "
00052       << setw(prec+6) << setprecision(prec) << *this << " "
00053       << setw(prec+6) << setprecision(prec) << g(offset++) << endl;
00054 }
00055 
00056 void param_init_vector::save_value(const ofstream& _ofs, int prec,
00057   const dvector& g, int& offset)
00058 {
00059   ADUNCONST(ofstream,ofs)
00060   int mmin=indexmin();
00061   int mmax=indexmax();
00062   for (int i=mmin;i<=mmax;i++)
00063   {
00064     ofs << label()
00065         << "(" << i << ") "
00066         << setw(prec+6) << setprecision(prec) << (*this)(i) << " "
00067         << setw(prec+6) << setprecision(prec) << g(offset++) << endl;
00068   }
00069 }
00070 
00071 void param_init_bounded_vector::save_value(const ofstream& _ofs, int prec,
00072   const dvector& g, int& offset)
00073 {
00074   ADUNCONST(ofstream,ofs)
00075   int mmin=indexmin();
00076   int mmax=indexmax();
00077   for (int i=mmin;i<=mmax;i++)
00078   {
00079     ofs << label()
00080         << "(" << i << ") "
00081         << setw(prec+6) << setprecision(prec) << (*this)(i) << " "
00082         << setw(prec+6) << setprecision(prec) << g(offset++) << endl;
00083   }
00084 }
00085 
00086 void initial_params::save_all(const ofstream& _ofs, int prec, const dvector& g)
00087 {
00088   ADUNCONST(ofstream,ofs)
00089   int offset = 1;
00090   ofs <<"ParName"<< "   "<< "Value"<< "   " <<"Gradient"<< endl;
00091   for (int i = 0; i < initial_params::num_initial_params; i++)
00092   {
00093     if (withinbound(0,(varsptr[i])->phase_start,current_phase))
00094     {
00095       // ofs << i+1 <<"       ";
00096       (initial_params::varsptr[i])->save_value(ofs, 6, g, offset);
00097     }
00098   }
00099 }
00100 
00101 void param_init_matrix::save_value(const ofstream& _ofs, int prec,
00102   const dvector&g, int& offset)
00103 {
00104   //ADUNCONST(ofstream,ofs)
00105   //cerr << "not done yet" << endl;
00106   //ad_exit(1);
00107   ofstream& ofs = (ofstream&)_ofs;
00108   ofs << setw(prec+6) << setprecision(prec) << dvar_matrix(*this) << endl;
00109 }