[galib] Antwort: GAlib: how to initialize my first generation's individuals in real numbers (not zeros) ?
Kupfer, Michael (ARC-AFA)[UC SANTA CRUZ]
Michael.Kupfer at nasa.gov
Wed Oct 1 12:38:03 EDT 2008
Hello Torsten, Hello Yi!
I am myself a GAlib beginner but what I'd suggest is to write your own initializer.
I believe there even should be some examples.
But here is a code snippet from my application.
What you have to do is basically replace what I did in the MyArrayInitializer with your desired real numbers.
Maybe this helps.
Best,
Michael.
--------------------------------------------------
Michael Kupfer
University Affiliated Research Center
UC Santa Cruz
NASA Ames Research Center
Building 210, Room 255, Mail Stop 210-6
Moffett Field, CA 94035
U.S.A.
Email: Michael.Kupfer -AT- nasa.gov <mailto:Michael.Kupfer at nasa.gov>
Phone: (650)604-6424
-----------------------------------------------------
#include
#include
#include
...
#define
...
//------------------- own initializer ----------------------
void MyArrayInitializer(GAGenome & g)
{
int sep_value;
GARealGenome &genome = (GARealGenome &)g;
// set first gene to the ETA_f
genome.gene(0, unit[0].arr_f);
//[SNIP ... ]
//check for some constraint violation
// set the other genes ...
if(unit[i].arr_f > genome.gene(i-1) + SV)
{
genome.gene(i, unit[i].arr_f);
}
else
{
genome.gene(i, genome.gene(i-1) + SV);
}
}
//---------------------end of own initializer--------------------------
//--------------begin of main------------------------------------------
int main(int argc, char* argv [])
{
// declaration of the GAlib included random number generator
void GARandomSeed(unsigned s = 0);
//[SNIP ... ]
GARealGenome genome(alleles, Objective);
genome.initializer(MyArrayInitializer);
genome.crossover(GARealGenome::OnePointCrossover);
//[SNIP ... ]
}
________________________________
From: galib-bounces at mit.edu [mailto:galib-bounces at mit.edu] On Behalf Of Torsten.Gutjahr at ise.fraunhofer.de
Sent: Tuesday, September 30, 2008 10:32 AM
To: yi.zong at risoe.dk
Cc: galib-bounces at mit.edu; galib at mit.edu
Subject: [galib] Antwort: GAlib: how to initialize my first generation's individuals in real numbers (not zeros) ?
Dear all,
I have the same problem like Yi Zong. Please, could somebody help us?
Best Regards
----------------------------------------------------------------------------------------
Torsten Gutjahr
Dept. Materials Research and Applied Optics
Fraunhofer-Institut für Solare Energiesysteme ISE
Heidenhofstraße 2, 79110 Freiburg, Germany
Phone: +49 (0) 7 61/ 4588-59 80 Fax: +49 (0) 7 61/ 4588-99 81
torsten.gutjahr at ise.fraunhofer.de
www.ise.fraunhofer.de
yi.zong at risoe.dk
Gesendet von: galib-bounces at mit.edu
30.09.2008 16:30
An
galib at mit.edu
Kopie
Thema
[galib] GAlib: how to initialize my first generation's individuals in real numbers (not zeros) ?
Dear all,
When I use Galib to optimize, I want to initialize my first generation's individuals in some real numbers (not zeros), which I think they are in the best results range. That is to say, the first generation is specified as some numbers by myself and not gets diverse by random seed.
How can I realize it?
Thank you in advance,
Yi Zong
Post doc
Phone direct +45 4677 5045
Mobile
yi.zong at risoe.dk
Wind Energy Department
Risø National Laboratory for Sustainable Energy
Technical University of Denmark - DTU
Building 118, P.O. Box 49
DK-4000 Roskilde, Denmark
Tel +45 4677 4677
Fax +45 4677 5083
www.risoe.dtu.dk
_______________________________________________
galib mailing list
galib at mit.edu
http://mailman.mit.edu/mailman/listinfo/galib
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.mit.edu/pipermail/galib/attachments/20081001/5b14216f/attachment.htm
More information about the galib
mailing list