Correct templatized types across ObjectiveVector-dependant code

This commit is contained in:
Johann Dreo 2013-06-07 11:52:50 +02:00 committed by LPTK
commit 206f12e558
4 changed files with 13 additions and 11 deletions

View file

@ -59,7 +59,7 @@ public:
typedef typename ObjectiveVector::Type AtomType; typedef typename ObjectiveVector::Type AtomType;
/// Ctor /// Ctor
moeoHypContinue( const std::vector<AtomType> & _OptimVec, moeoArchive < MOEOT > & _archive, bool _normalize=true, AtomType _rho=1.1) moeoHypContinue( const std::vector<AtomType> & _OptimVec, moeoArchive < MOEOT > & _archive, bool _normalize=true, double _rho=1.1)
: eoContinue<MOEOT>(), arch(_archive), metric(_normalize,_rho) : eoContinue<MOEOT>(), arch(_archive), metric(_normalize,_rho)
{ {
vectorToParetoSet(_OptimVec); vectorToParetoSet(_OptimVec);

View file

@ -33,17 +33,19 @@ Authors:
#include <comparator/moeoObjectiveObjectiveVectorComparator.h> #include <comparator/moeoObjectiveObjectiveVectorComparator.h>
#include <comparator/moeoParetoObjectiveVectorComparator.h> #include <comparator/moeoParetoObjectiveVectorComparator.h>
#include <core/moeoRealObjectiveVector.h> #include <core/moeoScalarObjectiveVector.h>
template < class ObjectiveVectorTraits > template < class ObjectiveVectorTraits, class T = eoMinimizingDualFitness /* can be an eoMaximizingDualFitness */>
class moeoDualRealObjectiveVector : public moeoScalarObjectiveVector<ObjectiveVectorTraits, eoMinimizingDualFitness > class moeoDualRealObjectiveVector : public moeoScalarObjectiveVector<ObjectiveVectorTraits, T >
{ {
protected: protected:
bool _is_feasible; bool _is_feasible;
public: public:
moeoDualRealObjectiveVector(double value=0.0) : moeoScalarObjectiveVector<ObjectiveVectorTraits, eoMinimizingDualFitness >(value, false) {} moeoDualRealObjectiveVector(double value=0.0)
: moeoScalarObjectiveVector<ObjectiveVectorTraits, eoMinimizingDualFitness >
( T(value, false) ) {}
bool is_feasible() const bool is_feasible() const
{ {

View file

@ -151,8 +151,8 @@ class moeoScalarObjectiveVector : public moeoObjectiveVector < ObjectiveVectorTr
* @param _os output stream * @param _os output stream
* @param _objectiveVector the objective vector to write * @param _objectiveVector the objective vector to write
*/ */
template < class ObjectiveVectorTraits > template < class ObjectiveVectorTraits, class T >
std::ostream & operator<<(std::ostream & _os, const moeoScalarObjectiveVector < ObjectiveVectorTraits > & _objectiveVector) std::ostream & operator<<(std::ostream & _os, const moeoScalarObjectiveVector < ObjectiveVectorTraits, T > & _objectiveVector)
{ {
for (unsigned int i=0; i<_objectiveVector.size()-1; i++) for (unsigned int i=0; i<_objectiveVector.size()-1; i++)
_os << _objectiveVector[i] << " "; _os << _objectiveVector[i] << " ";
@ -165,10 +165,10 @@ std::ostream & operator<<(std::ostream & _os, const moeoScalarObjectiveVector <
* @param _is input stream * @param _is input stream
* @param _objectiveVector the objective vector to read * @param _objectiveVector the objective vector to read
*/ */
template < class ObjectiveVectorTraits > template < class ObjectiveVectorTraits, class T >
std::istream & operator>>(std::istream & _is, moeoScalarObjectiveVector < ObjectiveVectorTraits > & _objectiveVector) std::istream & operator>>(std::istream & _is, moeoScalarObjectiveVector < ObjectiveVectorTraits, T > & _objectiveVector)
{ {
_objectiveVector = moeoScalarObjectiveVector < ObjectiveVectorTraits > (); _objectiveVector = moeoScalarObjectiveVector < ObjectiveVectorTraits, T > ();
for (unsigned int i=0; i<_objectiveVector.size(); i++) for (unsigned int i=0; i<_objectiveVector.size(); i++)
{ {
_is >> _objectiveVector[i]; _is >> _objectiveVector[i];

View file

@ -154,7 +154,7 @@ class moeoExpBinaryIndicatorBasedFitnessAssignment : public moeoBinaryIndicatorB
*/ */
void setup(const eoPop < MOEOT > & _pop) void setup(const eoPop < MOEOT > & _pop)
{ {
double min, max; typename MOEOT::ObjectiveVector::Type min, max;
for (unsigned int i=0; i<ObjectiveVector::Traits::nObjectives(); i++) for (unsigned int i=0; i<ObjectiveVector::Traits::nObjectives(); i++)
{ {
min = _pop[0].objectiveVector()[i]; min = _pop[0].objectiveVector()[i];