COPASI API  4.16.103
COptMethodHGASA.h
Go to the documentation of this file.
1 /* Begin CVS Header
2  $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/optimization/COptMethodHGASA.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  * COptMethodHGASA class
15  */
16 
17 #ifndef COPASI_COptMethodHGASA
18 #define COPASI_COptMethodHGASA
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 
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
60  double *CandidateValue; // array of values of objective function f/ individuals
61 
62  int *CrossPoint; // indexes of the crossover points
63  int *WinScore; // number of WinScore of each individual in the tournament
64 
65  /**
66  * Default Constructor
67  */
69 
70  public:
71  /**
72  * Copy Constructor
73  * @param const COptMethodHGASA & src
74  */
75  COptMethodHGASA(const COptMethodHGASA & src);
76 
77  /**
78  * Destructor
79  */
80  virtual ~COptMethodHGASA();
81 
82  /**
83  * Execute the optimization algorithm calling simulation routine
84  * when needed. It is noted that this procedure can give feedback
85  * of its progress by the callback function set with SetCallback.
86  */
87 
88  /********Declare the prototype of member functions here**************/
89 
90  // define mutation functions
91  void Set_NumParameter (int num);
92  void Set_PopulationSize(int num);
93  void Set_NumGeneration(int num);
94  void Set_murvar(double num);
95  void Set_individual(int i, int j, double num);
96  void Set_CandidateValue(int i, double num);
97  void Set_BestFoundSoFar(int num);
98  // void Set_mutvar(double num);
99  void Set_Minimum(double num);
100  void Set_Maximum(double num);
101 
102  // define access functions
103 
104  int Get_NumParameter();
106  int Get_NumGeneration();
107  int Get_PopulationSize();
108 
109  /***********define functional functions here*************************/
110 
111  // evaluate the fitness of one individual
112  //virtual double evaluate(int i);
113 
114  // copy individual o to position d
115  virtual void copy(int o, int d);
116 
117  // swap individuals o and d
118  virtual void swap(int o, int d);
119 
120  // exchange individuals o and d
121  virtual void exchange(int o, int d);
122 
123  //mutate one individual
124  //virtual void mutate(int i);
125 
126  virtual void crossover(int p1, int p2, int c1, int c2);
127 
128  //virtual void shuffle(void);
129 
130  // replicate the individuals w/ crossover
131  virtual void replicate(void);
132 
133  // select PopulationSize individuals
134  virtual void select(int method);
135 
136  // check the BestFoundSoFar individual at this NumGenerationation
137  virtual int fittest(void);
138 
139  // initialise the population
140  //virtual void creation(int l, int u);
141 
142  virtual void TrackDataFile(int i);
143 
144  virtual bool optimise();
145  virtual bool optimise(int index);
146  };
147 
148 //implementation of mutation functions
149 
151 {
152  NumParameter = num;
153 }
154 
156 {
157  PopulationSize = num;
158 }
159 
161 {
162  NumGeneration = num;
163 }
164 
165 /*
166 inline void COptMethodHGASA::Set_mutvar(double num)
167 {
168 mutvar=num;
169 }
170  */
171 
172 inline void COptMethodHGASA::Set_Minimum(double num)
173 {
174  Minimum = num;
175 }
176 inline void COptMethodHGASA::Set_Maximum(double num)
177 {
178  Maximum = num;
179 }
180 
181 inline void COptMethodHGASA::Set_individual(int i, int j, double num)
182 {
183  individual[i][j] = num;
184 }
185 
186 inline void COptMethodHGASA::Set_CandidateValue(int i, double num)
187 {
188  CandidateValue[i] = num;
189 }
190 
192 {
193  BestFoundSoFar = num;
194 }
195 
196 //implementation of access functions
197 
199 {
200  return NumParameter;
201 }
202 
204 {
206 }
207 
209 {
210  return NumGeneration;
211 }
212 
214 {
215  return PopulationSize;
216 }
217 
218 #endif // COPASI_COptMethodHGASA
virtual void exchange(int o, int d)
void Set_CandidateValue(int i, double num)
double * CandidateValue
virtual void select(int method)
static COptMethod * createMethod(CCopasiMethod::SubType subType=CCopasiMethod::RandomSearch)
Definition: COptMethod.cpp:50
virtual void swap(int o, int d)
virtual int fittest(void)
double ** individual
virtual ~COptMethodHGASA()
void Set_murvar(double num)
void Set_Minimum(double num)
virtual bool optimise()
virtual void replicate(void)
double Get_BestFoundSoFar_candidate()
void Set_NumParameter(int num)
virtual void copy(int o, int d)
void Set_BestFoundSoFar(int num)
void Set_individual(int i, int j, double num)
void Set_Maximum(double num)
void Set_NumGeneration(int num)
virtual void crossover(int p1, int p2, int c1, int c2)
void Set_PopulationSize(int num)
virtual void TrackDataFile(int i)