problem printing out the best genome that the GA found!

Matthew Wall mbwall at MIT.EDU
Wed May 31 10:30:04 EDT 2000


the issue when using streams with vcpp is that there are two streams 
libraries in the micros~1 environment, and the only way to 
distinguish between them is at compile time:

   if you want to use the old streams, then:  #include <iostream.h>
   if you want to use the new streams, then:  #include <iostream>

it ends up being very confusing and difficult to control, 
particularly when you mix different libraries and even more so when 
those libraries do not all use the same version of the streams 
library.

with galib, you can do the following in gaconfig.h:

   if you want to use the old streams, then:  #define USE_OLD_STREAMS
   if you want to use the new streams, then:  #define USE_ANSI_STREAMS

the installation guide suggests turning off streams (#define 
NO_STREAMS) when using mfc just to avoid the whole issue.  mfc uses 
the new streams, so you can #define USE_ANSI_STREAMS when you compile 
galib with the intent to link to mfc (or with any other libraries 
that use the new streams library) and you should be ok.

note that there are other header issues when using micros~1 
environment - the order in which you include header files can make a 
huge difference since micros~1 defines a zillion macros and they do 
not use namespaces and and and...

note bene that none if this is an issue on unixes, nor on macos.

matthew




>I am having the same problem - the error occurs when you have '#define
>NO_STREAMS' set - all the overloaded << and write() functions are then
>not declared and defined in the classes. The GA lib will compile and you
>can use it no problems, until you want to output any data ...
>
>I can get the library to compile with or without streams no problem
>(difference of about 1.2Mb in the final ga.lib file). But if I then use
>the library with stream functions included, I get loads of 'ambiguous
>istream and ostream' errors on compilation.
>
>I'm using MSVC++ 6.0 without MFC, anyone know what we need to do to get
>the << and write functions to work?
>
>On a wider note, the FAQ mentions only about having to turn off
>NO_STREAMS in order to use MFC; has no-one else had the problems above
>(I can't see anything in the mailing archives)? How about a few more
>questions and answers for the FAQ - I'll happily write an idiots guide
>to setting up GA lib under MSVC++, if I can get it to work ...
>
>Cheers, Tom.
>
>
>
>On Tue, 30 May 2000, Joe Dumoulin wrote:
>
>  > You must create an operator<< that prints your genome and make it a friend
>  > of the genome class you are using (i'm not sure the second part is
>  > necessary;  it just makes it easier.  If you are using a binary string
>  > genome, try
>  >
>  > cout << hex << (long) ga.statistics().bestIndividual() << "\n";
>  >
>  > I'm not sure it will work but it's ceratinly worth a try....
>  >
>  >
>  > Joe D
>  >
>  > -------------------------------------------------------------------------
>  > A student asked the master: "Master, how may I find enlightenment?"  The
>  > master replied with a question: "Have you finished your rice?"  The
>  > student answered: "Yes, Master."  The master responded: "Then wash
>  > your bowl!"
>  >
>  > On Tue, 30 May 2000, Luis Ariel Diago wrote:
>  >
>  > > I am using galib with Visual C++ 5.0 and when I try to
>  > >
>  > > print out the best genome that the GA found it give me
>  > > the following error in the line:
>  > >
>  > > cout << "The GA found:\n" <<
>  > > ga.statistics().bestIndividual() << "\n";
>  > >
>  > > Compiling...
>  > > ex1.C
>  > > D:\galib245\examples\ex1.C(70) : error C2679: binary
>  > > '<<' : no operator defined which takes a right-hand
>  > > operand of type 'const class GAGenome' (or there is no
>  > > acceptable conversion)
>  > >
>  > > Error executing cl.exe.
>  > >
>  > > What should I do?
>  > >
>  > >
>  > > =====
>  > > ºººººººººººº   Hola!
>  > >    |   º   º  |   Quieres contactarme?
>  > >   (    (..)    )  escribeme a: luis_a_diago at yahoo.com
>  > >     \   __   /
>  > >      |______|     Quieres conocer mas acerca de mi?
>  > >                   visitame en:
>  > > http://www.geocities.com/luis_a_diago/
>  > >
>  > > __________________________________________________
>  > > Do You Yahoo!?
>  > > Send instant messages & get email alerts with Yahoo! Messenger.
>  > > http://im.yahoo.com/
>  > >
>  >
>  >
>
>____________________________________________________________
>
>   Tom Smith         toms at cogs.susx.ac.uk
>                     http://www.cogs.susx.ac.uk/users/toms/
>
>   Centre for Computational Neuroscience and Robotics,
>   School of Biological Sciences, University of Sussex,
>   Falmer, Brighton BN1 9QG, Great Britain.
>   tel 01273 877 386, fax 01273 678 535, mobile 0966 543 467
>____________________________________________________________





More information about the galib mailing list