COPASI API  4.16.103
pvmtest.cpp
Go to the documentation of this file.
1 /* Begin CVS Header
2  $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/pvmtest/pvmtest.cpp,v $
3  $Revision: 1.6 $
4  $Name: $
5  $Author: gauges $
6  $Date: 2009/02/18 20:54:47 $
7  End CVS Header */
8 
9 // Copyright (C) 2008 by Pedro Mendes, Virginia Tech Intellectual
10 // Properties, Inc., EML Research, gGmbH, University of Heidelberg,
11 // and The University of Manchester.
12 // All rights reserved.
13 
14 // Copyright (C) 2001 - 2007 by Pedro Mendes, Virginia Tech Intellectual
15 // Properties, Inc. and EML Research, gGmbH.
16 // All rights reserved.
17 
18 #define COPASI_MAIN
19 
20 #include "copasi.h"
21 #include "utilities/CGlobals.h"
26 
27 C_INT32 TestOptimization(void); //yohe: new
28 
29 C_INT main(C_INT argc, char *argv[])
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
54 
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 C_INT
Definition: copasi.h:115
C_INT32 TestOptimization(void)
Definition: pvmtest.cpp:55
#define pdelete(p)
Definition: copasi.h:215
void setProblem(COptProblem *problem)
Definition: COptMethod.cpp:170
const std::string & getText() const
static COptMethod * createMethod(CCopasiMethod::SubType subType=CCopasiMethod::RandomSearch)
Definition: COptMethod.cpp:50
const CCopasiMessage & getMessage() const
#define C_INT32
Definition: copasi.h:90
C_INT main(C_INT argc, char *argv[])
Definition: pvmtest.cpp:29
bool setValue(const std::string &name, const CType &value)
virtual bool optimise()
Definition: COptMethod.cpp:184