The Fib multimedia system
Fib is a system for storing multimedia data (like images or films).
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
cFibObjectFitnessBasicAlgorithm.h
Go to the documentation of this file.
1 /**
2  * @file cFibObjectFitnessBasicAlgorithm
3  * file name: cFibObjectFitnessBasicAlgorithm.h
4  * @author Betti Oesterholz
5  * @date 02.03.2010
6  * @mail webmaster@BioKom.info
7  *
8  * System: C++
9  *
10  * This header specifies the simple class of fib -enviroment algorithm
11  * creating fib -fitness objects.
12  * Copyright (C) @c GPL3 2010 Betti Oesterholz
13  *
14  * This program is free software: you can redistribute it and/or modify
15  * it under the terms of the GNU General Public License (GPL) as
16  * published by the Free Software Foundation, either version 3 of the
17  * License, or any later version.
18  *
19  * This program is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22  * GNU Lesser General Public License for more details.
23  *
24  * You should have received a copy of the GNU General Public License
25  * along with this program. If not, see <http://www.gnu.org/licenses/>.
26  *
27  * @see cObjectFitness
28  * @see cFibObjectFitness
29  * @see cFibObjectFitnessBasic
30  * @see cObjectFitnessAlgorithm
31  * This header specifies the simple class of fib -enviroment algorithm
32  * for creating fib -fitness objects.
33  * The better (higher) the fitness the better the Fib object, the more likly
34  * it should live and children should be created from it.
35  *
36  */
37 /*
38 History:
39 02.03.2010 Oesterholz created
40 18.04.2010 Oesterholz evalueObject() methods changed: not a function but
41  an object is given to evalue the data
42 30.04.2010 Oesterholz using cEvaluePositionListMemLimit to evalue the
43  given (non original) Fib objects
44 05.07.2010 Oesterholz some functions moved to classes in namespace fib
45 12.09.2010 Oesterholz changes for the getOriginalPositionList() method
46 31.10.2012 Oesterholz cFibObjectFitnessAlgorithm() constructor with
47  input reference Fib object created
48 */
49 
50 #ifndef ___C_FIB_OBJECT_FITNESS_BASIC_ALGORITHMUS_H__
51 #define ___C_FIB_OBJECT_FITNESS_BASIC_ALGORITHMUS_H__
52 
53 #include "version.h"
54 
56 #include "cFibObjectFitnessBasic.h"
57 
58 #include "cRoot.h"
59 
60 #include <string>
61 
62 
63 using std::string;
64 
65 namespace enviroment{
66 namespace fib{
67 
68 
69 class cFibIndividual;//cyclic dependencie
70 
71 
73 
74 protected:
75 
76  /**
77  * The weight for the dDistanceToOriginal value.
78  */
80 
81  /**
82  * The weight for the lSize value.
83  */
84  double dWeightSize;
85 
86  /**
87  * The weight for the lEvaluationTime value.
88  */
90 
91 //help variable members
92 
93  /**
94  * A pointer to the best possible fitness the algorithm can create.
95  * No individual with a better/ higher fitness can be created with this
96  * algorithm.
97  * The best case fitness is an cFibObjectFitness object with all
98  * fitnessvalues set to 0.
99  */
101 
102  /**
103  * A pointer to the worst case fitness for the algorithm and
104  * originalindividual.
105  * An individual with the worst case fitness can easily be created.
106  * This is the fitness of the originalindividual.
107  * If no originalindividual is set NULL is returned.
108  */
110 
111 public:
112 
113  /**
114  * constructor
115  */
117 
118  /**
119  * constructor
120  *
121  * @see cFibObjectFitnessBasic
122  * @param pInOriginalIndividual the individual with which the fitness
123  * should be evalued;
124  * Beware: this object won't be copied, so don't delete it as long
125  * as this object exists
126  * @param dInWeightDistanceToOriginal the weight for the distance to original value
127  * @param dInWeightSize the weight for the Fib object size value
128  * @param dInWeightEvaluationTime the weight for the evaluation time of
129  * the Fib object
130  */
131  cFibObjectFitnessBasicAlgorithm( cFibIndividual * pInOriginalIndividual,
132  double dInWeightDistanceToOriginal=1.0, double dInWeightSize=1.0,
133  double dInWeightEvaluationTime=1.0 );
134 
135  /**
136  * constructor
137  *
138  * @see cFibObjectFitnessBasic
139  * @param pOriginalFibElement the Fib object with which the fitness
140  * should be evalued;
141  * Beware: this object won't be copied, so don't delete it as long
142  * as this object exists
143  * @param dInWeightDistanceToOriginal the weight for the distance to original value
144  * @param dInWeightSize the weight for the Fib object size value
145  * @param dInWeightEvaluationTime the weight for the evaluation time of
146  * the Fib object
147  */
148  cFibObjectFitnessBasicAlgorithm( cFibElement * pOriginalFibElement,
149  double dInWeightDistanceToOriginal=1.0, double dInWeightSize=1.0,
150  double dInWeightEvaluationTime=1.0 );
151 
152  /**
153  * constructor
154  *
155  * @see cFibObjectFitnessBasic
156  * @param inOriginalFibElement the Fib object with which the fitness
157  * should be evalued
158  * @param dInWeightDistanceToOriginal the weight for the distance to original value
159  * @param dInWeightSize the weight for the Fib object size value
160  * @param dInWeightEvaluationTime the weight for the evaluation time of
161  * the Fib object
162  */
163  cFibObjectFitnessBasicAlgorithm( const cFibElement & inOriginalFibElement,
164  double dInWeightDistanceToOriginal=1.0, double dInWeightSize=1.0,
165  double dInWeightEvaluationTime=1.0 );
166 
167  /**
168  * copyconstructor
169  *
170  * @param objectFitnessAlgorithm the cFibObjectFitnessBasicAlgorithm object to copy
171  */
173  objectFitnessAlgorithm );
174 
175  /**
176  * destructor
177  */
179 
180  /**
181  * This function evalues the fitness for the given fib -individual.
182  * Beware: You have to delete the returned fitness after usage.
183  *
184  * @see pOriginalIndividual
185  * @param individual the cFibIndividual for which a fitnessobject should
186  * be created
187  * @return the fitnessobject for the fitness of the given individual or
188  * NULL, if no fitness could be created
189  */
190  virtual cFibObjectFitnessBasic * evalueFitness( const cIndividual & individual ) const;
191 
192  /**
193  * This function evalues the fitness for the given fib -individual.
194  * Beware: You have to delete the returned fitness after usage.
195  *
196  * @see pOriginalIndividual
197  * @param individual the cFibIndividual for which a fitnessobject should
198  * be created
199  * @return the fitnessobject for the fitness of the given individual or
200  * NULL, if no fitness could be created
201  */
202  virtual cFibObjectFitnessBasic * evalueFitness( const cFibIndividual & individual ) const;
203 
204  /**
205  * This function evalues the fitness for the given fib -individual.
206  * Beware: You have to delete the returned fitness after usage.
207  *
208  * @see pOriginalIndividual
209  * @param fibObject the Fib object for which a fitnessobject should
210  * be created
211  * @return the fitnessobject for the fitness of the given fibObject or
212  * NULL, if no fitness could be created
213  */
214  virtual cFibObjectFitnessBasic * evalueFitness( const cFibElement * fibObject ) const;
215 
216  /**
217  * This method evalues the difference betwean the orginal Fib object
218  * and the given Fib object fibObject on an area.
219  * It is the sum of the distances of all values of propertyvectorelements
220  * betwean the represented and original Fib object of all positions
221  * which are inside the dimension bounderies and are in fibObjectArea,
222  * if given (not NULL).
223  *
224  * @param fibObject the Fib object to which the difference is to evalue
225  * @param fibObjectArea if given (not NULL) the points/positions of
226  * this (evalued) Fib object are the positions for which the
227  * distance is evalued (other points will be ignored)
228  * @return a value for the difference betwean the orginal Fib object
229  * and the given Fib object fibObject, or -1.0 if an error occured
230  */
231  virtual double evalueDistance( const cFibElement *fibElement,
232  const cFibElement *fibElementArea=NULL ) const;
233 
234  /**
235  * This method evalues the difference betwean the orginal Fib object
236  * and the given points with ther properties.
237  * It is the sum of the distances of all values of propertyvectorelements
238  * betwean the represented and original Fib object of all positions
239  * which are inside the dimension bounderies.
240  *
241  * @param liPointWithProperties the list with the points and ther
242  * properties for which to evalue the distance
243  * @return a value for the difference betwean the orginal Fib object
244  * and the given liPointWithProperties, or -1.0 if an error occured
245  */
246  virtual double evalueDistance( list< pair< cVectorPosition,
247  list< cVectorProperty > > > & liPointWithProperties ) const;
248 
249  /**
250  * This method evalues the difference betwean the orginal Fib object
251  * and the given Fib object fibObject on an area.
252  * It is the sum of the distances of all values of propertyvectorelements
253  * betwean the represented and original Fib object of all positions
254  * which are inside the dimension bounderies and are in fibObjectArea.
255  *
256  * @param liPointWithProperties the list with the points and ther
257  * properties for which to evalue the distance
258  * @param liPointWithPropertiesOfArea the points/positions of
259  * the positions for which the distance is evalued (other points
260  * will be ignored)
261  * (the list< cVectorProperty > is included for consistencie, but
262  * it is ignored in this method)
263  * @return a value for the difference betwean the orginal Fib object
264  * and the given liPointWithProperties, or -1.0 if an error occured
265  */
266  virtual double evalueDistanceInArea( list< pair< cVectorPosition,
267  list< cVectorProperty > > > & liPointWithProperties,
268  list< pair< cVectorPosition, list< cVectorProperty > > > &
269  liPointWithPropertiesOfArea ) const;
270 
271  /**
272  * @return the name of this class
273  */
274  virtual string getClassName() const;
275 
276  /**
277  * This method sets the originalindividual.
278  * The originalindividual is the individual with which the fitness
279  * should be evalued.
280  *
281  * @see getOriginalIndividual()
282  * @see pOriginalIndividual
283  * @param pInOriginalIndividual a point to the originalindividual to set
284  * Beware: this object won't be copied, so don't delete it as long
285  * as this object exists
286  * @return true if the originalindividual is set to originalIndividum,
287  * else false
288  */
289  virtual bool setOriginalIndividual( cIndividual * pInOriginalIndividual );
290 
291  /**
292  * This method sets the originalindividual.
293  * The originalindividual is the individual with which the fitness
294  * should be evalued.
295  *
296  * @see getOriginalIndividual()
297  * @see pOriginalIndividual
298  * @param pInOriginalIndividual a point to the fib -originalindividual to set
299  * Beware: this object won't be copied, so don't delete it as long
300  * as this object exists
301  * @return true if the originalindividual is set to pInOriginalIndividual,
302  * else false
303  */
304  virtual bool setOriginalIndividual( cFibIndividual * pInOriginalIndividual );
305 
306  /**
307  * This method sets the originalindividual.
308  * The originalindividual is the individual with which the fitness
309  * should be evalued.
310  *
311  * @see getOriginalIndividual()
312  * @see pOriginalIndividual
313  * @param pInOriginalFibObject the Fib object with which the fitness
314  * should be evalued;
315  * Beware: this object won't be copied, so don't delete it as long
316  * as this object exists
317  * @return true if the originalindividual is set to pInOriginalFibObject,
318  * else false
319  */
320  virtual bool setOriginalFibObject( cFibElement * pInOriginalFibObject );
321 
322  /**
323  * This Method clones this object.
324  *
325  * @return a clone of this object
326  */
327  virtual cFibObjectFitnessBasicAlgorithm * clone() const;
328 
329  /**
330  * This Method returns the best possible fitness the algorithm can create.
331  * No individual with a better/ higher fitness can be created with this
332  * algorithm.
333  * The best case fitness is an cFibObjectFitness object with all
334  * fitnessvalues set to 0.
335  *
336  * @return a cFibObjectFitness object with all fitnessvalues set to 0
337  */
338  virtual const cFibObjectFitnessBasic * getBestFitness() const;
339 
340  /**
341  * This Method returns the worst case fitness for the algorithm and
342  * originalindividual.
343  * An individual with the worst case fitness can easyly be created.
344  * This is the fitness of the originalindividual.
345  * If no originalindividual is set NULL is returned.
346  *
347  * @return a refernce to the fitness of the originalindividual or NULL,
348  * ff no originalindividual is set
349  */
350  virtual const cFibObjectFitnessBasic * getWorstCaseFitness() const;
351 
352 
353  /**
354  * @see dWeightDistanceToOriginal
355  * @return the weight for the dDistanceToOriginal value
356  */
357  double getWeightDistanceToOriginal() const;
358 
359  /**
360  * @see dWeightSize
361  * @return the weight for the lSize value
362  */
363  double getWeightSize() const;
364 
365  /**
366  * @see dWeightEvaluationTime
367  * @return the weight for the lEvaluationTime value
368  */
369  double getWeightEvaluationTime() const;
370 
371 
372 
373 };//end class cFibObjectFitnessBasicAlgorithm
374 
375 };//end namespace fib
376 };//end namespace enviroment
377 
378 #endif //___C_FIB_OBJECT_FITNESS_BASIC_ALGORITHMUS_H__
379 
380 
381 
382 
383 
384 
385