Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

ForestNitrogenCyclingMinimizableDirector.cpp

Go to the documentation of this file.
00001 // ForestNitrogenCyclingMinimizableDirector.cpp: implementation of the CForestNitrogenCyclingMinimizableDirector class.
00002 //
00004 
00005 #include "ForestNitrogenCyclingMinimizableDirector.h"
00006 
00008 // Construction/Destruction
00010 
00011 CForestNitrogenCyclingMinimizableDirector::CForestNitrogenCyclingMinimizableDirector()
00012 {
00013         // create networks,experiments,observers,movers,minimizables
00014         double maxSimTime = 385.0;
00015         double stepSize = 0.0001;
00016         double frequency = 1.0;
00017         int nCells = 1;
00018         double moveTol = 1.0e-06;
00019 
00020         m_dGammaSquared = 0.0;
00021         
00022         // flags for all minimizables
00023         bool rateFlag = true;
00024         bool chemFlag = false;
00025         bool logsFlag = false;
00026         double timeWeight = 1.0;
00027         double rateWeight = 1.0;
00028         double chemWeight = 0.0;
00029 
00030         // expt. 0 - Monthly precipitation data
00031         // networks and data
00032         _networkList.push_back(new CForestNitrogenCycleNetwork());
00033         _experimentList.push_back(new Experiment(_networkList[0],"Hubbard Brook 1"));
00034         // put data files here
00035         _experimentList[0]->AddDataFileToList("MonthlyMDO.dat");
00036         // forcing files
00037         _experimentList[0]->AddForcingFileToList("MonthlyIP.dat");
00038         // mover and plotter
00039         _moverList.push_back(new CQualityControlCashKarpMover(frequency,stepSize,moveTol));
00040         _plotterList.push_back(new GnuPlotterTimeSeriesObserver());
00041         // title
00042         _plotterList[0]->SetTitle("Forest N Cycling Network : Hubbard Brook Experimental Forest : ODE");
00043         // minimizable
00044         _minimizableList.push_back(new SingleNetworkMinimizable());
00045         // parameters
00046         _minimizableList[0]->Initialize(_experimentList[0],_moverList[0],nCells,rateFlag,chemFlag,logsFlag,timeWeight,rateWeight,chemWeight);
00047         _minimizableList[0]->GetConversionFactor(0)->SetFactorFixed(true);
00048         _minimizableList[0]->GetConversionFactor(0)->SetFactorValue(1.0);
00049         _minimizableList[0]->GetConversionFactor(1)->SetFactorFixed(true);
00050         _minimizableList[0]->GetConversionFactor(1)->SetFactorValue(1.0);
00051         _minimizableList[0]->GetConversionFactor(2)->SetFactorFixed(true);
00052         _minimizableList[0]->GetConversionFactor(2)->SetFactorValue(1.0);
00053         _minimizableList[0]->GetConversionFactor(3)->SetFactorFixed(true);
00054         _minimizableList[0]->GetConversionFactor(3)->SetFactorValue(1.0);
00055         _minimizableList[0]->GetConversionFactor(4)->SetFactorFixed(true);
00056         _minimizableList[0]->GetConversionFactor(4)->SetFactorValue(1.0);
00057         // attach observer
00058         _minimizableList[0]->Attach(_plotterList[0]);
00059 
00060                 
00061         // allocate the master residuals list
00062         int masterResidualsSize = 0;
00063         for(int i = 0; i < _minimizableList.size(); i++)
00064         {
00065                 int subRes = _minimizableList[i]->GetNResiduals();
00066                 masterResidualsSize += subRes;
00067                 cout << subRes << " residuals in minimizable " << i << endl;
00068         }
00069         if(m_dGammaSquared > 0.0)
00070         {
00071                 masterResidualsSize += 1;
00072         }
00073         Allocate(masterResidualsSize);
00074 
00075         cout << "Master Residuals size : " << masterResidualsSize << endl;
00076 
00077         // define the experiments
00078         DefineExperiments();
00079 
00080 }
00081 
00082 CForestNitrogenCyclingMinimizableDirector::~CForestNitrogenCyclingMinimizableDirector()
00083 {
00084         for(int i = 0; i < _minimizableList.size(); i++)
00085         {
00086                 _minimizableList[i]->Detach(_plotterList[i]);
00087         }
00088         for(i = 0; i < _plotterList.size(); i++)
00089         {
00090                 delete _plotterList[i];
00091         }
00092 
00093 }
00094 
00095 void CForestNitrogenCyclingMinimizableDirector::DefineExperiments()
00096 {
00097 
00098 }
00099 
00100 double CForestNitrogenCyclingMinimizableDirector::GetParameter(int parIndex)
00101 {
00102         // for this director, everyone has the same parameters so any set 
00103         // can be returned
00104         return _minimizableList[0]->GetParameter(parIndex);
00105 }
00106 
00107 int CForestNitrogenCyclingMinimizableDirector::GetNParameters()
00108 {
00109         // ditto as for GetParameters()
00110         return _minimizableList[0]->GetNParameters();
00111 }

Generated on Mon Nov 3 09:37:51 2003 by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002