Add hyper volume continuators & metrics handling feasibility constraint on objectives
This commit is contained in:
parent
82ce471aef
commit
75340a5c91
4 changed files with 262 additions and 47 deletions
|
|
@ -86,41 +86,42 @@ class moeoHyperVolumeDifferenceMetric : public moeoVectorVsVectorBinaryMetric <
|
|||
*/
|
||||
double operator()(const std::vector < ObjectiveVector > & _set1, const std::vector < ObjectiveVector > & _set2)
|
||||
{
|
||||
double hypervolume_set1;
|
||||
double hypervolume_set2;
|
||||
|
||||
if(rho >= 1.0){
|
||||
//determine bounds
|
||||
setup(_set1, _set2);
|
||||
//determine reference point
|
||||
for (unsigned int i=0; i<ObjectiveVector::Traits::nObjectives(); i++){
|
||||
if(normalize){
|
||||
if (ObjectiveVector::Traits::minimizing(i))
|
||||
ref_point[i]= rho;
|
||||
else
|
||||
ref_point[i]= 1-rho;
|
||||
}
|
||||
else{
|
||||
if (ObjectiveVector::Traits::minimizing(i))
|
||||
ref_point[i]= bounds[i].maximum() * rho;
|
||||
else
|
||||
ref_point[i]= bounds[i].maximum() * (1-rho);
|
||||
}
|
||||
}
|
||||
//if no normalization, reinit bounds to O..1 for
|
||||
if(!normalize)
|
||||
for (unsigned int i=0; i<ObjectiveVector::Traits::nObjectives(); i++)
|
||||
bounds[i] = eoRealInterval(0,1);
|
||||
double hypervolume_set1;
|
||||
double hypervolume_set2;
|
||||
|
||||
}
|
||||
else if(normalize)
|
||||
setup(_set1, _set2);
|
||||
if(rho >= 1.0){
|
||||
//determine bounds
|
||||
setup(_set1, _set2);
|
||||
//determine reference point
|
||||
for (unsigned int i=0; i<ObjectiveVector::Traits::nObjectives(); i++){
|
||||
if(normalize){
|
||||
if (ObjectiveVector::Traits::minimizing(i))
|
||||
ref_point[i]= rho;
|
||||
else
|
||||
ref_point[i]= 1-rho;
|
||||
}
|
||||
else{
|
||||
if (ObjectiveVector::Traits::minimizing(i))
|
||||
ref_point[i]= bounds[i].maximum() * rho;
|
||||
else
|
||||
ref_point[i]= bounds[i].maximum() * (1-rho);
|
||||
}
|
||||
}
|
||||
//if no normalization, reinit bounds to O..1 for
|
||||
if(!normalize)
|
||||
for (unsigned int i=0; i<ObjectiveVector::Traits::nObjectives(); i++)
|
||||
bounds[i] = eoRealInterval(0,1);
|
||||
|
||||
moeoHyperVolumeMetric <ObjectiveVector> unaryMetric(ref_point, bounds);
|
||||
hypervolume_set1 = unaryMetric(_set1);
|
||||
hypervolume_set2 = unaryMetric(_set2);
|
||||
}
|
||||
else if(normalize)
|
||||
setup(_set1, _set2);
|
||||
|
||||
return hypervolume_set1 - hypervolume_set2;
|
||||
moeoHyperVolumeMetric <ObjectiveVector> unaryMetric(ref_point, bounds);
|
||||
hypervolume_set1 = unaryMetric(_set1);
|
||||
hypervolume_set2 = unaryMetric(_set2);
|
||||
|
||||
return hypervolume_set1 - hypervolume_set2;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -132,7 +133,7 @@ class moeoHyperVolumeDifferenceMetric : public moeoVectorVsVectorBinaryMetric <
|
|||
}
|
||||
|
||||
/**
|
||||
* method caclulate bounds for the normalization
|
||||
* method calculate bounds for the normalization
|
||||
* @param _set1 the vector contains all objective Vector of the first pareto front
|
||||
* @param _set2 the vector contains all objective Vector of the second pareto front
|
||||
*/
|
||||
|
|
@ -182,7 +183,7 @@ class moeoHyperVolumeDifferenceMetric : public moeoVectorVsVectorBinaryMetric <
|
|||
return 1e-6;
|
||||
}
|
||||
|
||||
private:
|
||||
protected:
|
||||
|
||||
/*boolean indicates if data must be normalized or not*/
|
||||
bool normalize;
|
||||
|
|
@ -196,4 +197,90 @@ class moeoHyperVolumeDifferenceMetric : public moeoVectorVsVectorBinaryMetric <
|
|||
|
||||
};
|
||||
|
||||
|
||||
template<class ObjectiveVector>
|
||||
class moeoDualHyperVolumeDifferenceMetric : public moeoHyperVolumeDifferenceMetric<ObjectiveVector>
|
||||
{
|
||||
protected:
|
||||
using moeoHyperVolumeDifferenceMetric<ObjectiveVector>::rho;
|
||||
using moeoHyperVolumeDifferenceMetric<ObjectiveVector>::normalize;
|
||||
using moeoHyperVolumeDifferenceMetric<ObjectiveVector>::ref_point;
|
||||
using moeoHyperVolumeDifferenceMetric<ObjectiveVector>::bounds;
|
||||
|
||||
public:
|
||||
|
||||
typedef typename ObjectiveVector::Type Type;
|
||||
|
||||
moeoDualHyperVolumeDifferenceMetric( bool _normalize=true, double _rho=1.1)
|
||||
: moeoHyperVolumeDifferenceMetric<ObjectiveVector>(_normalize, _rho)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
moeoDualHyperVolumeDifferenceMetric( bool _normalize/*=true*/, ObjectiveVector& _ref_point/*=NULL*/ )
|
||||
: moeoHyperVolumeDifferenceMetric<ObjectiveVector>( _normalize, _ref_point )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* calculates and returns the HyperVolume value of a pareto front
|
||||
* @param _set1 the vector contains all objective Vector of the first pareto front
|
||||
* @param _set2 the vector contains all objective Vector of the second pareto front
|
||||
*/
|
||||
double operator()(const std::vector < ObjectiveVector > & _set1, const std::vector < ObjectiveVector > & _set2)
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
// the two sets must be homogeneous in feasibility
|
||||
assert( _set1.size() > 0 );
|
||||
for( unsigned int i=1; i<_set1.size(); ++i ) {
|
||||
assert( _set1[i].is_feasible() == _set1[0].is_feasible() );
|
||||
}
|
||||
assert( _set2.size() > 0 );
|
||||
for( unsigned int i=1; i<_set2.size(); ++i ) {
|
||||
assert( _set2[i].is_feasible() == _set2[0].is_feasible() );
|
||||
}
|
||||
// and they must have the same feasibility
|
||||
assert( _set1[0].is_feasible() == _set2[0].is_feasible() );
|
||||
#endif
|
||||
bool feasible = _set1[0].is_feasible();
|
||||
|
||||
double hypervolume_set1;
|
||||
double hypervolume_set2;
|
||||
|
||||
if(rho >= 1.0){
|
||||
//determine bounds
|
||||
setup(_set1, _set2);
|
||||
//determine reference point
|
||||
for (unsigned int i=0; i<ObjectiveVector::Traits::nObjectives(); i++){
|
||||
if(normalize){
|
||||
if (ObjectiveVector::Traits::minimizing(i))
|
||||
ref_point[i]= Type(rho, feasible);
|
||||
else
|
||||
ref_point[i]= Type(1-rho, feasible);
|
||||
}
|
||||
else{
|
||||
if (ObjectiveVector::Traits::minimizing(i))
|
||||
ref_point[i]= Type(bounds[i].maximum() * rho, feasible);
|
||||
else
|
||||
ref_point[i]= Type(bounds[i].maximum() * (1-rho), feasible);
|
||||
}
|
||||
}
|
||||
//if no normalization, reinit bounds to O..1 for
|
||||
if(!normalize)
|
||||
for (unsigned int i=0; i<ObjectiveVector::Traits::nObjectives(); i++)
|
||||
bounds[i] = eoRealInterval(0,1);
|
||||
|
||||
}
|
||||
else if(normalize)
|
||||
setup(_set1, _set2);
|
||||
|
||||
moeoHyperVolumeMetric <ObjectiveVector> unaryMetric(ref_point, bounds);
|
||||
hypervolume_set1 = unaryMetric(_set1);
|
||||
hypervolume_set2 = unaryMetric(_set2);
|
||||
|
||||
return hypervolume_set1 - hypervolume_set2;
|
||||
}
|
||||
};
|
||||
|
||||
#endif /*MOEOHYPERVOLUMEMETRIC_H_*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue