GA1DArrayAlleleGenome & GASharing

joe joe at dns1.digithink.com
Fri Feb 15 10:50:40 EST 2002


What was the error you received at runtime?

On Fri, 15 Feb 2002, Markku Laukkanen wrote:

>
>
> On Thu, 14 Feb 2002, G.Spagnuolo wrote:
>
> > Hi all!
> > I am working with galib under VC++6.0 and I need to use the genome class
> > GA1DArrayAlleleGenome (or GARealGenome with alleles) together with the
> > GASharing scaling function.
> > In the following I report a test example to clarify my problem.
> > I have the first gene whose value is in the set [1..10] and the second one
> > whose value is in the range [2..8], both integers.
> > The compiler gives no errors during compiling, linking and so on, but I
> > have a runtime error when the line
> >
> > ga.scaling(scale);
> >
> > is executed.
> > In particular, the error occurs when
> >
> >    sclscm = s.clone();
> >
> > is executed.
> > Of course, I have the same error if I use the GARealGenome with alleles.
> >
> > Any hint?
>
> Hmm, with gcc 3.03 & linux & ga 2.45 doesn't coredump. Have you compiled
> or is the library compiled with the same version of VC ?
>
> 	PKY
>
> >
> > Thanks in advance.
> >
> > G.Spagnuolo
> >
> >
> > #include <ga.h>
> >
> > #include <GAAllele.C>
> > #include <GA1DArrayGenome.C>
> > GAAlleleSet<float>;
> > GAAlleleSetCore<float>;
> > GAArray<float>;
> > GA1DArrayGenome<float>;
> > GA1DArrayAlleleGenome<float>;
> >
> > float objective (GAGenome & genome)
> > {
> >          GA1DArrayAlleleGenome<float> & g = (GA1DArrayAlleleGenome<float>
> > &)genome;
> >
> >          return 0;
> > }
> >
> > float Comparator(const GAGenome& g1, const GAGenome& g2)
> > {
> >    return 0;
> > }
> >
> > int main ()
> > {
> >
> >          GAAlleleSet<float> set1;
> >          for (int i1=1;i1<=10;i1++)
> >                  set1.add((float)i1);
> >
> >          GAAlleleSet<float> set2;
> >          for (int i2=2;i2<=8;i2++)
> >                  set2.add((float)i2);
> >
> >          GAAlleleSetArray<float> alleles;
> >          alleles.add(set1);
> >          alleles.add(set2);
> >
> >          GA1DArrayAlleleGenome<float> genome(alleles,objective);
> >
> >          GASteadyStateGA ga(genome);
> >
> >          ga.set(gaNpopulationSize, 5);
> >          ga.set(gaNpCrossover, 0.5);
> >          ga.set(gaNpMutation, 0.05);
> >          ga.set(gaNnGenerations, 100);
> >          ga.set(gaNpReplacement, 0.50);
> >
> >          ga.minimize();
> >          ga.initialize();
> >
> >          GASharing scale(Comparator);
> >          ga.scaling(scale);
> >
> >          ga.evolve();
> >
> >          return 0;
> > }
> >
> > --
> > Dr. Giovanni Spagnuolo, Ph.D.
> > Assistant Professor
> > University of Salerno
> > Dipartimento di Ingegneria dell'Informazione ed Ingegneria Elettrica
> > D.I.I.I.E.
> > Via Ponte Don Melillo
> > 84084 Fisciano - Salerno - Italy
> > phone: +39 089 964258
> > fax: +39 089 964218
> > e-mail: spanish at ieee.org
> >
> > "You can tell whether a man is clever by his answers.
> > You can tell whether a man is wise by his questions."
> > Naguib Mahfouz
> >
>
>





More information about the galib mailing list