problems with `nBestGenomes'

Thomas Binder binder at iue.tuwien.ac.at
Wed Mar 29 08:47:39 EST 2000


Thomas Binder wrote:
> 
> Hi everybody!
> 
> It seems I found the solution to my bounds problem.
> 

Well, it seems I was too fast here.

I obviously only fixed the problem for a value of `1' for nBestGenomes.
For any value bigger than `1' I still get evaluations of non-initialized 
genomes. 

As I went deeper and deeper into the subject I found the actual problem. 
In method `updateBestIndividual' of the GAStatistics class the first ever reset 
of the `best of all' population results in illegal requests. This happens only
if we keep more than one best-of's.

As a solution I'll attach a patch against the GAStatistics.C file (2.4.5). Maybe
there will be a new release which fixes this problem anyway ...


If you want to apply the patch you need to store the attachment in a file (e.g. 
fix.patch).

now apply the patch using:
	patch -p0 < fix.patch


regards,
Tom

P.S.: This patch also solved my problems (SIGSEGV) conerning the 
`multi-threading issues' I posted last week.


========================= cut here =========================
--- GAStatistics.C	Wed Mar 29 15:40:07 2000
+++ GAStatistics.C.fixed	Wed Mar 29 15:39:57 2000
@@ -168,11 +168,21 @@
   if(pop.order() != boa->order()) boa->order(pop.order());
 
   if(flag == gaTrue){		// reset the BOA array
-    int j=0;
+    if (boa->nevals() == 0)	// non-initialized boa
+    {
+      int j(0);
+      for(int i=0; i<boa->size(); i++){
+        boa->individual(i).copy(pop.best(j));
+        if(j < pop.size()-1) j++;
+      }
+    }
+
+    int j(0);
     for(int i=0; i<boa->size(); i++){
       boa->best(i).copy(pop.best(j));
       if(j < pop.size()-1) j++;
     }
+    
     return;
   }
======================== cut here ========================
-- 
"Computers are like air conditioners - they stop working properly when you open
 Windows"
                            \\\|///
                          \\  ~ ~  //
                           (  @ @  )
/------------------------oOOo-(_)-oOOo-----------------------------------------\
| Thomas Binder                        |                                       |
| Institute for  Microelectronics      | phone: ++43/1/58801-36036             |
| Technical University Vienna          |                                       |
| Gusshausstrasse  27-29 / E360        | fax  : ++43/1/58801-36099             |
| A-1040  Vienna                       |                                       |
| A U S T R I A                        | email: binder at iue.tuwien.ac.at        |
\---------------------------------Oooo.----------------------------------------/
                        .oooO     (   )
                        (   )      ) /
                         \ (      (_/
                          \_)





More information about the galib mailing list