[go: up one dir, main page]

Menu

[r999]: / libmona / libmona / goal.hh  Maximize  Restore  History

Download this file

167 lines (124 with data), 4.2 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
/* -*- mona-c++ -*-
* Copyright (c) Leipzig, Madrid 2004 - 2008
* Max-Planck-Institute for Human Cognitive and Brain Science
* Max-Planck-Institute for Evolutionary Anthropology
* BIT, ETSI Telecomunicacion, UPM
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
// $Id: goal.hh,v 1.10 2005/06/08 16:10:55 gerddie Exp $
/**
\author: Gert Wollny < wollny at cbs mpg de >
*/
#ifndef __goal_hh
#define __goal_hh
#include <libmona/defines.hh>
#include <libmona/monaPlugIns.hh>
#include <libmona/plugin_handler.hh>
#include <libmona/factory.hh>
#include <vector>
#include <valarray>
MONA_NAMESPACE_BEGIN
/**
The gradient free goal function for optimisation.
*/
class CGoal {
public:
typedef std::valarray<double> vector;
/**
Initialise the goal with a starting position and a search range
\param pos
\param range
*/
CGoal(CGoal::vector& pos, const CGoal::vector& min, const CGoal::vector& max);
virtual ~CGoal();
/**
\param x possible solution
\returns value of target function at (transformed) x
*/
double operator()(const CGoal::vector& x) const;
/** \returns number of unknowns */
size_t size()const;
/** Set the current solution of the optimisation problem
\param pos in search space
*/
void set_position(const CGoal::vector& pos);
const CGoal::vector& get_position() const;
size_t get_evaluations()const;
const CGoal::vector& get_range() const;
const CGoal::vector& get_min() const;
const CGoal::vector& get_max() const;
private:
/**
This function has to be implemented in order to make actual use of the
goal.
*/
virtual double do_evaluate(const CGoal::vector& x) const = 0;
virtual void do_set_position(const CGoal::vector& x);
// this mutable is dirty ...
mutable size_t _M_evaluations;
/* this is convinience, that adds dirt to the interface */
CGoal::vector& _M_pos;
CGoal::vector _M_min;
CGoal::vector _M_max;
CGoal::vector _M_range;
};
class FGradientFreeOptimiserBase {
public:
virtual ~FGradientFreeOptimiserBase();
virtual void prepare(CGoal& goal) = 0;
virtual bool operator () (CGoal& goal, double epsilon, size_t max_eval) = 0;
private:
};
class CGFOptimiserFactory : public TFactory< FGradientFreeOptimiserBase>
{
public:
CGFOptimiserFactory(char const * const name);
static std::string const get_plugin_searchpattern();
};
class CGoalFactory : public TFactory<CGoal>
{
public:
CGoalFactory(char const * const name);
static std::string const get_plugin_searchpattern();
};
typedef TPluginHandler<CGFOptimiserFactory> CGFOptimiserPluginHandler;
typedef TPluginHandler<CGoalFactory> CGoalPluginHandler;
MONA_NAMESPACE_END
#endif
/*
$Log: goal.hh,v $
Revision 1.10 2005/06/08 16:10:55 gerddie
playing around
Revision 1.9 2005/05/24 14:13:35 gerddie
save the work on symmetric registration
Revision 1.8 2005/05/23 17:10:15 gerddie
ssdsym test cought some errors
Revision 1.7 2005/05/23 14:33:14 gerddie
slight changes in the factory infrastructure
Revision 1.6 2005/05/20 10:44:33 gerddie
rigidreggoal compiles
Revision 1.5 2005/05/19 13:08:48 gerddie
some tweaking in genetic optimisation
Revision 1.4 2005/05/19 07:55:37 gerddie
change goal vector handling to valarray
Revision 1.3 2005/05/12 13:23:19 gerddie
supprt function to get range
Revision 1.2 2005/05/12 09:25:15 gerddie
make the gradfree optimiser a plugin based entity
Revision 1.1 2005/05/11 22:58:32 gerddie
add seperate goal file
*/