Generic ObjectiveVector types

This commit is contained in:
Johann Dreo 2013-06-07 12:43:09 +02:00
commit 9787d4d89c
5 changed files with 40 additions and 8 deletions

View file

@ -43,9 +43,9 @@ class moeoDualRealObjectiveVector : public moeoScalarObjectiveVector<ObjectiveVe
public:
moeoDualRealObjectiveVector(double value=0.0)
moeoDualRealObjectiveVector(double value=0.0, bool feasible = false)
: moeoScalarObjectiveVector<ObjectiveVectorTraits, eoMinimizingDualFitness >
( T(value, false) ) {}
( T(value, feasible) ) {}
bool is_feasible() const
{
@ -113,4 +113,36 @@ class moeoDualRealObjectiveVector : public moeoScalarObjectiveVector<ObjectiveVe
};
/**
* Output for a moeoDualRealObjectiveVector object
* @param _os output stream
* @param _objectiveVector the objective vector to write
*/
template < class ObjectiveVectorTraits >
std::ostream & operator<<(std::ostream & _os, const moeoDualRealObjectiveVector < ObjectiveVectorTraits > & _objectiveVector)
{
for (unsigned int i=0; i<_objectiveVector.size()-1; i++)
_os << _objectiveVector[i] << " ";
_os << _objectiveVector[_objectiveVector.size()-1];
return _os;
}
/**
* Input for a moeoDualRealObjectiveVector object
* @param _is input stream
* @param _objectiveVector the objective vector to read
*/
template < class ObjectiveVectorTraits >
std::istream & operator>>(std::istream & _is, moeoDualRealObjectiveVector < ObjectiveVectorTraits > & _objectiveVector)
{
_objectiveVector = moeoDualRealObjectiveVector < ObjectiveVectorTraits > ();
for (unsigned int i=0; i<_objectiveVector.size(); i++)
{
_is >> _objectiveVector[i];
}
return _is;
}
#endif /*_DUALREALOBJECTIVEVECTOR_H_*/