problem printing out the best genome that the GA found!

Tom Smith toms at cogs.susx.ac.uk
Wed May 31 10:02:20 EDT 2000


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