COPASI API
4.16.103
Main Page
Namespaces
Classes
Files
File List
File Members
copasi
optimization
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
32
CRealProblem::CRealProblem
() :
COptProblem
()
33
{}
34
35
// Destructor
36
CRealProblem::~CRealProblem
()
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
47
bool
CRealProblem::calculate
()
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
{
76
fitness =
std::numeric_limits< C_FLOAT64 >::max
();
77
}
78
79
// :TODO: we need to set the result vector return fitness;
80
return
true
;
81
}
CRealProblem::~CRealProblem
~CRealProblem()
Definition:
CRealProblem.cpp:36
CRealProblem::calculate
virtual bool calculate()
Definition:
CRealProblem.cpp:47
copasi.h
CRealProblem::CRealProblem
CRealProblem()
Definition:
CRealProblem.cpp:32
CRealProblem.h
COptProblem
Definition:
COptProblem.h:49
max
#define max(a, b)
Definition:
f2c.h:176
Generated on Thu Jul 2 2015 14:50:36 for COPASI API by
1.8.6