blob: efc1c0fef513ecb60fcfdca4c12a2e922a2b2c17 (
plain)
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
|
$NetBSD: patch-an,v 1.2 2011/11/27 19:42:25 joerg Exp $
--- src/Genetic.hpp.orig 2002-01-09 18:34:33.000000000 +0000
+++ src/Genetic.hpp
@@ -1,6 +1,7 @@
#ifndef GENETIC_HPP
#define GENETIC_HPP
+#include <cstdlib>
#include <list>
using namespace std;
@@ -216,9 +217,9 @@ public:
virtual Genetic_Operator<T> *Choose_Operator(void)
{
int max=(int)total_op_weight;
- list<Genetic_Operator<T> *>::iterator start=operators.begin();
- list<Genetic_Operator<T> *>::iterator end=operators.end();
- list<Genetic_Operator<T> *>::iterator iter;
+ typename list<Genetic_Operator<T> *>::iterator start=operators.begin();
+ typename list<Genetic_Operator<T> *>::iterator end=operators.end();
+ typename list<Genetic_Operator<T> *>::iterator iter;
int r=rand()%max;
int count=0;
for (iter=start;iter!=end;iter++) {
@@ -249,7 +250,7 @@ public:
Genetic_Population<T> *newpop=new Genetic_Population<T>(p->size);
int cur_size=0;
while (cur_size<newpop->size) {
- Genetic_Operator<T> *op=Choose_Operator();
+ Genetic_Operator<T> *op=this->Choose_Operator();
if ( (cur_size+op->NumOfResults())>newpop->size)
continue;
for (i=0;i<op->NumOfOperands();i++) {
@@ -264,7 +265,7 @@ public:
cur_size++;
}
}
- newpop->Eval_Fitness(fit_func);
+ newpop->Eval_Fitness(this->fit_func);
return newpop;
}
|