COPASI API  4.16.103
COptMethodEP2.h
Go to the documentation of this file.
1 /* Begin CVS Header
2  $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/optimization/COptMethodEP2.h,v $
3  $Revision: 1.4 $
4  $Name: $
5  $Author: shoops $
6  $Date: 2006/04/27 01:29:53 $
7  End CVS Header */
8 
9 // Copyright 2005 by Pedro Mendes, Virginia Tech Intellectual
10 // Properties, Inc. and EML Research, gGmbH.
11 // All rights reserved.
12 
13 /**
14  * COptMethodEP2 class
15  */
16 
17 #ifndef COPASI_COptMethodEP2
18 #define COPASI_COptMethodEP2
19 
20 #define TRUE 1
21 #define FALSE 0
22 
23 #include <iostream>
24 #include <iomanip>
25 #include <fstream>
26 // #include <sys/times.h>
27 // #include <sys/types.h>
28 #include "stdio.h"
29 #include "stdlib.h"
30 #include "stddef.h"
31 #include "time.h"
32 #include "ctype.h"
33 #include "string.h"
34 #include "math.h"
35 #include "float.h"
36 //#include "r250.h"
37 
38 class CRandom;
39 
40 // this is an abstract class that contains many virtual functions
41 // without definitions
42 
43 class COptMethodEP2 : public COptMethod
44  {
46 
47  // Operations
48  private:
49 
50  int NumGeneration; // number of generations
51  int PopulationSize; // size of the population
52  int NumCrossPoint; // number of crossover points
53 
54  double Minimum, Maximum; //parameter boundary
55 
56  int BestFoundSoFar; // index of the BestFoundSoFar individual
57  int NumParameter; // number of parameters
58 
59  // double **individual; // for array of individuals w/ candidate values for the parameters
61  double *CandidateValue; // array of values of objective function f/ individuals
62  double *CandidateValueRate; // array of map values of objective function f/ individuals
63 
64  int *CrossPoint; // indexes of the crossover points
65  int *WinScore; // number of WinScore of each individual in the tournament
66 
67  /**
68  * Default Constructor
69  */
70  COptMethodEP2();
71 
72  public:
73  /**
74  * Copy Constructor
75  * @param const COptMethodEP2 & src
76  */
77  COptMethodEP2(const COptMethodEP2 & src);
78 
79  /**
80  * Destructor
81  */
82  virtual ~COptMethodEP2();
83 
84  /**
85  * Execute the optimization algorithm calling simulation routine
86  * when needed. It is noted that this procedure can give feedback
87  * of its progress by the callback function set with SetCallback.
88  */
89 
90  /********Declare the prototype of member functions here**************/
91 
92  // define mutation functions
93  void Set_NumParameter (int num);
94  void Set_PopulationSize(int num);
95  void Set_NumGeneration(int num);
96  void Set_murvar(double num);
97  void Set_individual(int i, int j, double num);
98  void Set_CandidateValue(int i, double num);
99  void Set_BestFoundSoFar(int num);
100  // void Set_mutvar(double num);
101  void Set_Minimum(double num);
102  void Set_Maximum(double num);
103 
104  // define access functions
105 
106  int Get_NumParameter();
108  int Get_NumGeneration();
109  int Get_PopulationSize();
110 
111  /***********define functional functions here*************************/
112 
113  // evaluate the fitness of one individual
114  //virtual double evaluate(int i);
115 
116  // copy individual o to position d
117  virtual void copy(int o, int d);
118 
119  // swap individuals o and d
120  virtual void swap(int o, int d);
121 
122  // exchange individuals o and d
123  virtual void exchange(int o, int d);
124 
125  //mutate one individual
126  //virtual void mutate(int i);
127 
128  //virtual void shuffle(void);
129 
130  // select PopulationSize individuals
131  virtual void select(int method);
132 
133  // check the BestFoundSoFar individual at this NumGenerationation
134  virtual int fittest(void);
135 
136  // initialise the population
137  //virtual void creation(int l, int u);
138 
139  virtual void TrackDataFile(int i);
140 
141  virtual bool optimise();
142  };
143 
144 //implementation of mutation functions
145 
146 inline void COptMethodEP2::Set_NumParameter (int num)
147 {
148  NumParameter = num;
149 }
150 
152 {
153  PopulationSize = num;
154 }
155 
157 {
158  NumGeneration = num;
159 }
160 
161 /*
162 inline void COptMethodEP2::Set_mutvar(double num)
163 {
164 mutvar=num;
165 }
166  */
167 
168 inline void COptMethodEP2::Set_Minimum(double num)
169 {
170  Minimum = num;
171 }
172 inline void COptMethodEP2::Set_Maximum(double num)
173 {
174  Maximum = num;
175 }
176 
177 inline void COptMethodEP2::Set_individual(int i, int j, double num)
178 {
179  individual[i][j] = num;
180 }
181 
182 inline void COptMethodEP2::Set_CandidateValue(int i, double num)
183 {
184  CandidateValue[i] = num;
185 }
186 
188 {
189  BestFoundSoFar = num;
190 }
191 
192 //implementation of access functions
193 
195 {
196  return NumParameter;
197 }
198 
200 {
202 }
203 
205 {
206  return NumGeneration;
207 }
208 
210 {
211  return PopulationSize;
212 }
213 
214 #endif // COPASI_COptMethodEP2
virtual void exchange(int o, int d)
virtual int fittest(void)
void Set_BestFoundSoFar(int num)
static COptMethod * createMethod(CCopasiMethod::SubType subType=CCopasiMethod::RandomSearch)
Definition: COptMethod.cpp:50
void Set_CandidateValue(int i, double num)
int Get_NumParameter()
double * CandidateValue
Definition: COptMethodEP2.h:61
virtual void swap(int o, int d)
int Get_NumGeneration()
void Set_PopulationSize(int num)
virtual ~COptMethodEP2()
CVector< CVector< C_FLOAT64 > > individual
Definition: COptMethodEP2.h:60
void Set_NumParameter(int num)
void Set_NumGeneration(int num)
virtual void select(int method)
virtual bool optimise()
virtual void TrackDataFile(int i)
virtual void copy(int o, int d)
void Set_Minimum(double num)
double Get_BestFoundSoFar_candidate()
double * CandidateValueRate
Definition: COptMethodEP2.h:62
int Get_PopulationSize()
void Set_individual(int i, int j, double num)
void Set_Maximum(double num)
void Set_murvar(double num)