COPASI API  4.16.103
CCopasiMethod.cpp
Go to the documentation of this file.
1 // Copyright (C) 2010 - 2013 by Pedro Mendes, Virginia Tech Intellectual
2 // Properties, Inc., University of Heidelberg, and The University
3 // of Manchester.
4 // All rights reserved.
5 
6 // Copyright (C) 2008 - 2009 by Pedro Mendes, Virginia Tech Intellectual
7 // Properties, Inc., EML Research, gGmbH, University of Heidelberg,
8 // and The University of Manchester.
9 // All rights reserved.
10 
11 // Copyright (C) 2003 - 2007 by Pedro Mendes, Virginia Tech Intellectual
12 // Properties, Inc. and EML Research, gGmbH.
13 // All rights reserved.
14 
15 /**
16  * CCopasiMethod class.
17  * This class is used to describe a task in COPASI. This class is
18  * intended to be used as the parent class for all methods whithin COPASI.
19  *
20  * Created for Copasi by Stefan Hoops 2003
21  */
22 
23 #include "copasi/copasi.h"
24 
28 #include "copasi/model/CModel.h"
29 
30 const std::string CCopasiMethod::SubTypeName[] =
31 {
32  "Not set",
33  "Random Search",
34  "Random Search (PVM)",
35  "Simulated Annealing",
36  "Corana Random Walk",
37  "Differential Evolution",
38  "Scatter Search",
39  "Genetic Algorithm",
40  "Evolutionary Programming",
41  "Steepest Descent",
42  "Hybrid GA/SA",
43  "Genetic Algorithm SR",
44  "Hooke & Jeeves",
45  "Levenberg - Marquardt",
46  "Nelder - Mead",
47  "Evolution Strategy (SRES)",
48  "Current Solution Statistics",
49  "Particle Swarm",
50  "Praxis",
51  "Truncated Newton",
52  "Enhanced Newton",
53  "Deterministic (LSODA)",
54  "Deterministic (LSODAR)",
55  "Stochastic (Direct method)",
56  "Stochastic (Gibson + Bruck)",
57  "Stochastic (\xcf\x84-Leap)",
58  "Stochastic (Adaptive SSA/\xcf\x84-Leap)",
59  "Hybrid (Runge-Kutta)",
60  "Hybrid (LSODA)",
61  "Hybrid (ODE45)",
62  "Hybrid (DSA-LSODAR)",
63  "ILDM (LSODA,Deuflhard)",
64  "ILDM (LSODA,Modified)",
65  "CSP (LSODA)",
66  "MCA Method (Reder)",
67  "Scan Framework",
68  "Wolf Method",
69  "Sensitivities Method",
70 #ifdef COPASI_SSA
71  "Stoichiometric Stability Analysis",
72 #endif // COPASI_SSA
73  "EFM Algorithm",
74  "Bit Pattern Tree Algorithm",
75  "Bit Pattern Algorithm",
76  "Householder Reduction",
77  "Cross Section Finder",
78  "Linear Noise Approximation",
79  ""
80 };
81 
82 const char * CCopasiMethod::XMLSubType[] =
83 {
84  "NotSet",
85  "RandomSearch",
86  "RandomSearch(PVM)",
87  "SimulatedAnnealing",
88  "CoranaRandomWalk",
89  "DifferentialEvolution",
90  "ScatterSearch",
91  "GeneticAlgorithm",
92  "EvolutionaryProgram",
93  "SteepestDescent",
94  "HybridGASA",
95  "GeneticAlgorithmSR",
96  "HookeJeeves",
97  "LevenbergMarquardt",
98  "NelderMead",
99  "EvolutionaryStrategySR",
100  "CurrentSolutionStatistics",
101  "ParticleSwarm",
102  "Praxis",
103  "TruncatedNewton",
104  "EnhancedNewton",
105  "Deterministic(LSODA)",
106  "Deterministic(LSODAR)",
107  "Stochastic",
108  "DirectMethod",
109  "TauLeap",
110  "AdaptiveSA",
111  "Hybrid",
112  "Hybrid (LSODA)",
113  "Hybrid (DSA-ODE45)",
114  "Hybrid (DSA-LSODAR)",
115  "TimeScaleSeparation(ILDM,Deuflhard)",
116  "TimeScaleSeparation(ILDM,Modified)",
117  "TimeScaleSeparation(CSP)",
118  "MCAMethod(Reder)",
119  "ScanFramework",
120  "WolfMethod",
121  "SensitivitiesMethod",
122 #ifdef COPASI_SSA
123  "StoichiometricStabilityAnalysis",
124 #endif // COPASI_SSA
125  "EFMAlgorithm",
126  "EFMBitPatternTreeMethod",
127  "EFMBitPatternMethod",
128  "Householder",
129  "crossSectionMethod",
130  "LinearNoiseApproximation",
131  NULL
132 };
133 
135  CCopasiParameterGroup("NoName", NULL, "Method"),
136  mType(CCopasiTask::unset),
137  mSubType(unset),
138  mpCallBack(NULL)
139  //mpReport(NULL)
141 
143  const CCopasiMethod::SubType & subType,
144  const CCopasiContainer * pParent):
145  CCopasiParameterGroup(CCopasiTask::TypeName[type], pParent, "Method"),
146  mType(type),
147  mSubType(subType),
148  mpCallBack(NULL)
149  //mpReport(NULL)
151 
153  const CCopasiContainer * pParent):
154  CCopasiParameterGroup(src, pParent),
155  mType(src.mType),
156  mSubType(src.mSubType),
157  mpCallBack(src.mpCallBack)
158  //mpReport(src.mpReport)
159 {}
160 
162 
164 {
165  mpCallBack = pCallBack;
166  return true;
167 }
168 
170 
171 // void CCopasiMethod::setType(const CCopasiTask::Type & type) {mType = type;}
172 
174 {return mSubType;}
175 
176 // void CCopasiMethod::setSubType(const CCopasiMethod::SubType & subType)
177 // {mSubType = subType;}
178 
179 //virtual
181 {
182  if (!pProblem)
183  {
184  //no problem
186  return false;
187  }
188 
189  if (! pProblem->getModel())
190  {
191  //no model
193  return false;
194  }
195 
196  if (pProblem->getModel()->getEvents().size())
197  {
198  if (mType == CCopasiTask::lyap)
199  {
200  CCopasiMessage(CCopasiMessage::ERROR, MCCopasiMethod + 4, "Lyapunov Exponents");
201  return false;
202  }
203 
205  {
206  CCopasiMessage(CCopasiMessage::ERROR, MCCopasiMethod + 4, "Time Scale Separation Analysis");
207  return false;
208  }
209 
210  if (mType == CCopasiTask::lna)
211  {
212  CCopasiMessage(CCopasiMessage::ERROR, MCCopasiMethod + 4, "Linear Noise Approximation");
213  return false;
214  }
215  }
216 
217  return true;
218 }
219 
220 void CCopasiMethod::load(CReadConfig & /* configBuffer */,
221  CReadConfig::Mode /* mode */)
222 {fatalError();}
223 
224 void CCopasiMethod::print(std::ostream * ostream) const
225 {*ostream << *this;}
226 
227 std::ostream &operator<<(std::ostream &os, const CCopasiMethod & o)
228 {
229  os << "Method: " << o.getObjectName() << std::endl;
230 
231  CCopasiParameterGroup::parameterGroup::const_iterator it =
232  o.CCopasiParameter::getValue().pGROUP->begin();
233  CCopasiParameterGroup::parameterGroup::const_iterator end =
234  o.CCopasiParameter::getValue().pGROUP->end();
235 
236  for (; it != end; ++it)
237  {
238  (*it)->print(&os);
239  os << std::endl;
240  }
241 
242  return os;
243 }
244 
245 void CCopasiMethod::printResult(std::ostream * ostream) const
246 {*ostream << " Not implemented.";}
virtual void printResult(std::ostream *ostream) const
CCopasiVectorN< CEvent > & getEvents()
Definition: CModel.cpp:1110
std::ostream & operator<<(std::ostream &os, const CCopasiMethod &o)
const std::string & getObjectName() const
virtual size_t size() const
#define fatalError()
virtual bool setCallBack(CProcessReport *pCallBack)
const CCopasiMethod::SubType & getSubType() const
virtual bool isValidProblem(const CCopasiProblem *pProblem)
virtual void load(CReadConfig &configBuffer, CReadConfig::Mode mode=CReadConfig::SEARCH)
#define MCCopasiMethod
virtual void print(std::ostream *ostream) const
virtual ~CCopasiMethod()
const CCopasiTask::Type & getType() const
static const std::string SubTypeName[]
Definition: CCopasiMethod.h:95
CCopasiTask::Type mType
CCopasiMethod::SubType mSubType
static const char * XMLSubType[]
bool setObjectName(const std::string &name)
CProcessReport * mpCallBack
CModel * getModel() const