COPASI API  4.16.103
Macros | Functions
pvmtest.cpp File Reference
#include "copasi.h"
#include "utilities/CGlobals.h"
#include "optimization/COptMethod.h"
#include "optimization/CRealProblem.h"
#include "utilities/CCopasiException.h"
#include "report/CCopasiRootContainer.h"
Include dependency graph for pvmtest.cpp:

Go to the source code of this file.

Macros

#define COPASI_MAIN
 

Functions

C_INT main (C_INT argc, char *argv[])
 
C_INT32 TestOptimization (void)
 

Macro Definition Documentation

#define COPASI_MAIN

Definition at line 18 of file pvmtest.cpp.

Function Documentation

C_INT main ( C_INT  argc,
char *  argv[] 
)

Definition at line 29 of file pvmtest.cpp.

References CCopasiException::getMessage(), CCopasiMessage::getText(), pdelete, CCopasiObject::Root, and TestOptimization().

30 {
31  cout << "Starting main program." << endl;
32 
33  CCopasiContainer::init();
34  Copasi = new CGlobals;
35 
36  Copasi->setArguments(argc, argv);
37 
38  try
39  {
41  }
42 
43  catch (CCopasiException Exception)
44  {
45  cout << Exception.getMessage().getText() << endl;
46  }
47 
48  pdelete(Copasi);
50 
51  cout << "Leaving main program." << endl;
52  return 0;
53 } // end of main
C_INT32 TestOptimization(void)
Definition: pvmtest.cpp:55
#define pdelete(p)
Definition: copasi.h:215
const std::string & getText() const
const CCopasiMessage & getMessage() const
C_INT32 TestOptimization ( void  )

Definition at line 55 of file pvmtest.cpp.

References COptMethod::createMethod(), COptMethod::optimise(), pdelete, COptMethod::setProblem(), and CCopasiParameterGroup::setValue().

Referenced by main().

56 {
57  int i, num_params;
58  cout << "TestOptimization() begins --- " << endl;
60 
61  CRealProblem *CReal = new CRealProblem();
62  CRand->setProblem(CReal);
63 
64  // set parameter numbers....
65  /**** hard coded num of params ***/
66  num_params = 10;
67  CReal->setParameterNum(num_params);
68 
69  // set the individual parameters
70 
71  CRand->setValue(0, 100000);
72 
73  for (i = 0; i < num_params; i++)
74  {
75  CReal->setParameterMin(i, -5);
76  CReal->setParameterMax(i, 2);
77  }
78 
79  CRand->optimise();
80  cout << "result---best values";
81  for (i = 0; i < num_params; i++)
82  {
83  cout << CReal->getBestValue(i);
84  cout << "\n";
85  }
86 
87  pdelete(CRand);
88  return 0;
89 }
#define pdelete(p)
Definition: copasi.h:215
void setProblem(COptProblem *problem)
Definition: COptMethod.cpp:170
static COptMethod * createMethod(CCopasiMethod::SubType subType=CCopasiMethod::RandomSearch)
Definition: COptMethod.cpp:50
bool setValue(const std::string &name, const CType &value)
virtual bool optimise()
Definition: COptMethod.cpp:184