COPASI API  4.16.103
CRealProblem.cpp
Go to the documentation of this file.
1 /* Begin CVS Header
2  $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/optimization/CRealProblem.cpp,v $
3  $Revision: 1.12 $
4  $Name: $
5  $Author: shoops $
6  $Date: 2012/04/23 21:11:21 $
7  End CVS Header */
8 
9 // Copyright (C) 2012 by Pedro Mendes, Virginia Tech Intellectual
10 // Properties, Inc., University of Heidelberg, and The University
11 // 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 /**
19  * File name: CRealProblem.cpp
20  *
21  * Programmer: Yongqun He
22  * Contact email: yohe@vt.edu
23  * functions. It's used by COptAlgorithm class and COptimization class
24  */
25 
26 #include "copasi.h"
27 #include "CRealProblem.h"
28 
29 //? Do I need to call super() ? find out
30 
31 // Default constructor
33 {}
34 
35 // Destructor
37 {}
38 
39 // calculate function for optimization
40 // YOHE: Here is the N-Dimensional Test Function I use:
41 // f(x) = (1/2)Sum(j=1, n)(Xj^4 - 16Xj^2 + 5Xj)
42 // where, x = [X1, X2, ... , Xj, ..., Xn]
43 // Number of global minima = 1;
44 // Global minimum found by TRUST:
45 // [-2.90354, -2.90354, ..., -2.90354].
46 // calculate function for optimization
48 {
49  int j;
50 
51  double fitness;
52  double fitness0;
53 
54  // :TODO: broken
55  int parameterNum; // = getCalculateVariables().size();
56  double * parameterValues; // = getCalculateVariables().array();
57 
58  //YOHE: this is the mathematics function used only for testing purpose
59  // evaluate the fitness
60 
61  try
62  {
63  fitness0 = 0;
64 
65  for (j = 0; j < parameterNum; j++)
66  {
67  fitness = fitness0 + pow(parameterValues[j], 4.0) - 16.0 * pow(parameterValues[j], 2.0)
68  + 5.0 * parameterValues[j];
69  fitness0 = fitness;
70  }
71 
72  fitness = fitness0 / 2.0;
73  }
74  catch (int)
75  {
77  }
78 
79  // :TODO: we need to set the result vector return fitness;
80  return true;
81 }
virtual bool calculate()
#define max(a, b)
Definition: f2c.h:176