evaluation.cpp
1 /********************************************************************************
2  * FARSA Genetic Algorithm Library *
3  * Copyright (C) 2007-2009 Gianluca Massera <emmegian@yahoo.it> *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the Free Software *
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
18  ********************************************************************************/
19 
20 #include "core/evaluation.h"
21 #include "core/genome.h"
22 
23 namespace farsa {
24 
26  isDone = false;
27  isInitialized = false;
28  isFinalized = true;
29  genotypev = 0;
30  genotypeid = -1;
31  genomev = 0;
32  ga = 0;
33 }
34 
36  //--- nothing to do
37 }
38 
40  //--- check if it is initialized already and not finalized yet
41  if ( isInitialized && !isFinalized ) {
42  //--- nothing do to
43  return;
44  }
45  genotypev = gen;
46  if ( genome() ) {
47  genotypeid = genome()->find( gen );
48  }
49  isDone = false;
50  init();
51  isInitialized = true;
52  isFinalized = false;
53 }
54 
56  if ( !isInitialized ) {
57  qFatal( "You Must Initialized Evaluation Process before calling evaluateStep()" );
58  return;
59  }
60  step();
61 }
62 
64  while( ! isEvaluationDone() ) {
65  evaluateStep();
66  }
67 }
68 
70  if ( !isInitialized && isFinalized ) {
71  //--- nothing to do
72  return;
73  }
74  fini();
75  isInitialized = false;
76  isFinalized = true;
77 }
78 
80  return isDone;
81 }
82 
84  isDone = true;
85 }
86 
87 } // end namespace farsa