added shit init (size init) for main7 + corrected velocity constructor errors
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@865 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
dd7ba90e1a
commit
c438dc7863
3 changed files with 30 additions and 5 deletions
|
|
@ -24,6 +24,7 @@ int main( int __argc, char** __argv )
|
|||
const double INIT_POSITION_MAX = 2.0;
|
||||
const double INIT_VELOCITY_MIN = -1.;
|
||||
const double INIT_VELOCITY_MAX = 1.;
|
||||
const double weight = 1;
|
||||
const double C1 = 0.5;
|
||||
const double C2 = 2.;
|
||||
rng.reseed (time(0));
|
||||
|
|
@ -45,7 +46,7 @@ int main( int __argc, char** __argv )
|
|||
pop.append (POP_SIZE, random);
|
||||
eoLinearTopology<Indi> topology(NEIGHBORHOOD_SIZE);
|
||||
eoRealVectorBounds bnds(VEC_SIZE,INIT_VELOCITY_MIN,INIT_VELOCITY_MAX);
|
||||
eoStandardVelocity < Indi > velocity (topology,C1,C2,bnds);
|
||||
eoStandardVelocity < Indi > velocity (topology,weight,C1,C2,bnds);
|
||||
eoInitializer <Indi> init(eval,veloRandom,localInit,topology,pop);
|
||||
|
||||
// Parallel algorithm
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ int main( int __argc, char** __argv )
|
|||
const double INIT_VELOCITY_MIN = -1.;
|
||||
const double INIT_VELOCITY_MAX = 1.;
|
||||
const unsigned int MIG_FREQ = 10;
|
||||
const double omega = 1;
|
||||
const double C1 = 0.5;
|
||||
const double C2 = 2.;
|
||||
rng.reseed (time(0));
|
||||
|
|
@ -50,7 +51,7 @@ int main( int __argc, char** __argv )
|
|||
pop.append (POP_SIZE, random);
|
||||
eoLinearTopology<Indi> topology(NEIGHBORHOOD_SIZE);
|
||||
eoRealVectorBounds bnds(VEC_SIZE,INIT_VELOCITY_MIN,INIT_VELOCITY_MAX);
|
||||
eoStandardVelocity < Indi > velocity (topology,C1,C2,bnds);
|
||||
eoStandardVelocity < Indi > velocity (topology,omega,C1,C2,bnds);
|
||||
eoInitializer <Indi> init(eval,veloRandom,localInit,topology,pop);
|
||||
|
||||
// Island model
|
||||
|
|
@ -79,7 +80,7 @@ int main( int __argc, char** __argv )
|
|||
pop2.append (POP_SIZE, random2);
|
||||
eoLinearTopology<Indi> topology2(NEIGHBORHOOD_SIZE);
|
||||
eoRealVectorBounds bnds2(VEC_SIZE,INIT_VELOCITY_MIN,INIT_VELOCITY_MAX);
|
||||
eoStandardVelocity < Indi > velocity2 (topology2,C1,C2,bnds2);
|
||||
eoStandardVelocity < Indi > velocity2 (topology2,omega,C1,C2,bnds2);
|
||||
eoInitializer <Indi> init2(eval2,veloRandom2,localInit2,topology2,pop2);
|
||||
|
||||
// Island model
|
||||
|
|
|
|||
|
|
@ -12,6 +12,26 @@ double f (const Indi & _indi)
|
|||
return (-sum);
|
||||
}
|
||||
|
||||
template <class EOT>
|
||||
class eoResizerInit: public eoInit<EOT>
|
||||
{
|
||||
public:
|
||||
|
||||
typedef typename EOT::AtomType AtomType;
|
||||
|
||||
eoResizerInit(unsigned _size)
|
||||
: size(_size){}
|
||||
|
||||
virtual void operator()(EOT& chrom)
|
||||
{
|
||||
chrom.resize(size);
|
||||
chrom.invalidate();
|
||||
}
|
||||
private :
|
||||
unsigned size;
|
||||
};
|
||||
|
||||
|
||||
int main( int __argc, char** __argv )
|
||||
{
|
||||
|
||||
|
|
@ -24,6 +44,7 @@ int main( int __argc, char** __argv )
|
|||
const double INIT_POSITION_MAX = 2.0;
|
||||
const double INIT_VELOCITY_MIN = -1.;
|
||||
const double INIT_VELOCITY_MAX = 1.;
|
||||
const double omega = 1;
|
||||
const double C1 = 0.5;
|
||||
const double C2 = 2.;
|
||||
rng.reseed (time(0));
|
||||
|
|
@ -38,9 +59,11 @@ int main( int __argc, char** __argv )
|
|||
eoStandardFlight < Indi > flight(bndsFlight);
|
||||
eoLinearTopology<Indi> topology(NEIGHBORHOOD_SIZE);
|
||||
eoRealVectorBounds bnds(VEC_SIZE,INIT_VELOCITY_MIN,INIT_VELOCITY_MAX);
|
||||
eoStandardVelocity < Indi > velocity (topology,C1,C2,bnds);
|
||||
eoStandardVelocity < Indi > velocity (topology,omega,C1,C2,bnds);
|
||||
|
||||
eoPop < Indi > pop(POP_SIZE);
|
||||
eoResizerInit<Indi> sizeInit(VEC_SIZE);
|
||||
// need at least a size initialization
|
||||
eoPop < Indi > pop(POP_SIZE,sizeInit);
|
||||
eoInitFixedLength < Indi > randomSeq (VEC_SIZE, uGen);
|
||||
peoMultiStart <Indi> initRandom (randomSeq);
|
||||
peoWrapper random (initRandom,pop);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue