added a public bool feasible, used to identify feasible individuals in initialization processes
This commit is contained in:
parent
ed7902ed90
commit
2184dc845f
1 changed files with 24 additions and 4 deletions
|
|
@ -93,26 +93,37 @@ public:
|
||||||
|
|
||||||
// Basic constructors and assignments
|
// Basic constructors and assignments
|
||||||
eoScalarFitnessAssembled()
|
eoScalarFitnessAssembled()
|
||||||
: baseVector( FitnessTraits::size() ) {}
|
: baseVector( FitnessTraits::size() ),
|
||||||
|
feasible(true)
|
||||||
|
{}
|
||||||
|
|
||||||
eoScalarFitnessAssembled( size_type _n,
|
eoScalarFitnessAssembled( size_type _n,
|
||||||
const ScalarType& _val,
|
const ScalarType& _val,
|
||||||
const std::string& _descr="Unnamed variable" )
|
const std::string& _descr="Unnamed variable" )
|
||||||
: baseVector(_n, _val)
|
: baseVector(_n, _val),
|
||||||
|
feasible(true)
|
||||||
{
|
{
|
||||||
if ( _n > FitnessTraits::size() )
|
if ( _n > FitnessTraits::size() )
|
||||||
FitnessTraits::resize(_n, _descr);
|
FitnessTraits::resize(_n, _descr);
|
||||||
}
|
}
|
||||||
|
|
||||||
eoScalarFitnessAssembled( const eoScalarFitnessAssembled& other) : baseVector( other ) {}
|
eoScalarFitnessAssembled( const eoScalarFitnessAssembled& other)
|
||||||
|
: baseVector( other ),
|
||||||
|
feasible(other.feasible)
|
||||||
|
{}
|
||||||
|
|
||||||
eoScalarFitnessAssembled& operator=( const eoScalarFitnessAssembled& other) {
|
eoScalarFitnessAssembled& operator=( const eoScalarFitnessAssembled& other) {
|
||||||
baseVector::operator=( other );
|
baseVector::operator=( other );
|
||||||
|
feasible = other.feasible;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Constructors and assignments to work with scalar type
|
// Constructors and assignments to work with scalar type
|
||||||
eoScalarFitnessAssembled( const ScalarType& v ) : baseVector( 1, v ) {}
|
eoScalarFitnessAssembled( const ScalarType& v )
|
||||||
|
: baseVector( 1, v ),
|
||||||
|
feasible(true)
|
||||||
|
{}
|
||||||
|
|
||||||
eoScalarFitnessAssembled& operator=( const ScalarType& v ) {
|
eoScalarFitnessAssembled& operator=( const ScalarType& v ) {
|
||||||
|
|
||||||
if ( empty() )
|
if ( empty() )
|
||||||
|
|
@ -120,6 +131,8 @@ public:
|
||||||
else
|
else
|
||||||
front() = v;
|
front() = v;
|
||||||
|
|
||||||
|
feasible=true;
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -152,6 +165,13 @@ public:
|
||||||
|
|
||||||
//! Get vector with descriptions
|
//! Get vector with descriptions
|
||||||
std::vector<std::string> getDescriptionVector() { return FitnessTraits::getDescriptionVector(); }
|
std::vector<std::string> getDescriptionVector() { return FitnessTraits::getDescriptionVector(); }
|
||||||
|
|
||||||
|
//! Feasibility boolean
|
||||||
|
/**
|
||||||
|
* Can be specified anywhere in fitness evaluation
|
||||||
|
* as an indicator if the individual is in some feasible range.
|
||||||
|
*/
|
||||||
|
bool feasible;
|
||||||
|
|
||||||
// Scalar type access
|
// Scalar type access
|
||||||
operator ScalarType(void) const {
|
operator ScalarType(void) const {
|
||||||
|
|
|
||||||
Reference in a new issue