trick to allow maximization
This commit is contained in:
parent
b6b5cd6e2f
commit
5a74f9a3c6
1 changed files with 93 additions and 90 deletions
|
|
@ -66,14 +66,6 @@ class moeoHypervolumeBinaryMetric : public moeoNormalizedSolutionVsSolutionBinar
|
||||||
*/
|
*/
|
||||||
moeoHypervolumeBinaryMetric(double _rho = 1.1) : moeoNormalizedSolutionVsSolutionBinaryMetric<ObjectiveVector, double>(), rho(_rho)
|
moeoHypervolumeBinaryMetric(double _rho = 1.1) : moeoNormalizedSolutionVsSolutionBinaryMetric<ObjectiveVector, double>(), rho(_rho)
|
||||||
{
|
{
|
||||||
// not-a-maximization problem check
|
|
||||||
for (unsigned int i=0; i<ObjectiveVector::Traits::nObjectives(); i++)
|
|
||||||
{
|
|
||||||
if (ObjectiveVector::Traits::maximizing(i))
|
|
||||||
{
|
|
||||||
throw std::runtime_error("Hypervolume binary metric not yet implemented for a maximization problem in moeoHypervolumeBinaryMetric");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// consistency check
|
// consistency check
|
||||||
if (rho < 1)
|
if (rho < 1)
|
||||||
{
|
{
|
||||||
|
|
@ -92,6 +84,17 @@ class moeoHypervolumeBinaryMetric : public moeoNormalizedSolutionVsSolutionBinar
|
||||||
double operator()(const ObjectiveVector & _o1, const ObjectiveVector & _o2)
|
double operator()(const ObjectiveVector & _o1, const ObjectiveVector & _o2)
|
||||||
{
|
{
|
||||||
double result;
|
double result;
|
||||||
|
// transform maximizing objectives into minimizing objectives
|
||||||
|
ObjectiveVector o1 = _o1;
|
||||||
|
ObjectiveVector o2 = _o2;
|
||||||
|
for (unsigned int i=0; i<ObjectiveVector::Traits::nObjectives(); i++)
|
||||||
|
{
|
||||||
|
if (ObjectiveVector::Traits::maximizing(i))
|
||||||
|
{
|
||||||
|
o1[i] = bounds[i].maximum() - o1[i] + bounds[i].minimum();
|
||||||
|
o2[i] = bounds[i].maximum() - o2[i] + bounds[i].minimum();
|
||||||
|
}
|
||||||
|
}
|
||||||
// if _o2 is dominated by _o1
|
// if _o2 is dominated by _o1
|
||||||
if ( paretoComparator(_o2,_o1) )
|
if ( paretoComparator(_o2,_o1) )
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue