[shark] 21/58: Fast hypervolume algorithm for three objectives added.

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Wed Mar 16 10:05:29 UTC 2016


This is an automated email from the git hooks/post-receive script.

ghisvail-guest pushed a commit to branch master
in repository shark.

commit 1e32bddc2998ead1c252428056b6c2f14ff8582f
Author: Tobias Glasmachers <tobias.glasmachers at ini.rub.de>
Date:   Mon Feb 8 09:41:12 2016 +0100

    Fast hypervolume algorithm for three objectives added.
---
 Test/Algorithms/Hypervolume.cpp                    |  13 +--
 .../DirectSearch/HypervolumeCalculator.h           | 121 +++++++++++++++++++--
 2 files changed, 113 insertions(+), 21 deletions(-)

diff --git a/Test/Algorithms/Hypervolume.cpp b/Test/Algorithms/Hypervolume.cpp
index 1b7687f..81852d0 100644
--- a/Test/Algorithms/Hypervolume.cpp
+++ b/Test/Algorithms/Hypervolume.cpp
@@ -22,9 +22,6 @@ struct Fixture {
 	Fixture() {
 		BOOST_TEST_MESSAGE( "Setting up test sets and reference points " );
 		m_refPoint3D = boost::assign::list_of( 1.1 )( 1.1 )( 1.1 );
-		//~ m_refPoint3D.push_back(1.1);
-		//~ m_refPoint3D.push_back(1.1);
-		//~ m_refPoint3D.push_back(1.1);
 		m_testSet3D.push_back( boost::assign::list_of( 6.56039859404455e-2 ) (0.4474014917277) (0.891923776019316) );
 		m_testSet3D.push_back( boost::assign::list_of( 3.74945443950542e-2)(3.1364039802686e-2)(0.998804513479922 ) );
 		m_testSet3D.push_back( boost::assign::list_of( 0.271275894554688)(0.962356894778677)(1.66911984440026e-2 ) );
@@ -106,9 +103,8 @@ BOOST_AUTO_TEST_CASE( Algorithms_ExactHypervolume ) {
 
 	BOOST_CHECK_CLOSE( hc( ife, m_testSet2D, m_refPoint2D ), Fixture::HV_TEST_SET_2D, 1E-5 );
 	BOOST_CHECK_CLOSE( hc( ife, m_testSet3D, m_refPoint3D ), Fixture::HV_TEST_SET_3D, 1E-5 );
-
 	std::vector<double> results;
-	
+
 	for( unsigned int trial = 0; trial < 10; trial++ )
 		results.push_back(ha( m_testSet3D.begin(), m_testSet3D.end(), ife, m_refPoint3D, 1E-2, 1E-2 ) );
 	
@@ -130,10 +126,9 @@ BOOST_AUTO_TEST_CASE( Algorithms_LeastContributorApproximator ) {
 	}
 
 	std::vector< RealVector >::const_iterator it = m_testSet3D.begin();
-	BOOST_CHECK_EQUAL( 
-		lca.leastContributor( ife, m_testSet3D, m_refPoint3D ),
-		(std::size_t)std::distance( contributions.begin(), std::min_element( contributions.begin(), contributions.end() ) ) 
-	);
+	std::size_t approx = lca.leastContributor( ife, m_testSet3D, m_refPoint3D );
+	std::size_t exact = (std::size_t)std::distance( contributions.begin(), std::min_element( contributions.begin(), contributions.end() ) );
+	BOOST_CHECK_EQUAL( approx, exact );
 }
 
 BOOST_AUTO_TEST_SUITE_END()
diff --git a/include/shark/Algorithms/DirectSearch/HypervolumeCalculator.h b/include/shark/Algorithms/DirectSearch/HypervolumeCalculator.h
index 0992a3a..aa42954 100644
--- a/include/shark/Algorithms/DirectSearch/HypervolumeCalculator.h
+++ b/include/shark/Algorithms/DirectSearch/HypervolumeCalculator.h
@@ -5,18 +5,24 @@
  * 
  * The algorithm is described in
  * 
- * Nicola Beume und G�nter Rudolph. 
+ * Nicola Beume und Günter Rudolph. 
  * Faster S-Metric Calculation by Considering Dominated Hypervolume as Klee's Measure Problem.
  * In: B. Kovalerchuk (ed.): Proceedings of the Second IASTED Conference on Computational Intelligence (CI 2006), 
  * pp. 231-236. ACTA Press: Anaheim, 2006. 
  * 
- * 
+ * A specialized algorithm is used for the three-objective case:
+ *
+ * M. T. M. Emmerich and C. M. Fonseca.
+ * Computing hypervolume contributions in low dimensions: Asymptotically optimal algorithm and complexity results.
+ * In: Evolutionary Multi-Criterion Optimization (EMO) 2011.
+ * Vol. 6576 of Lecture Notes in Computer Science, pp. 121--135, Berlin: Springer, 2011.
  *
- * \author      T.Voss, O.Krause
- * \date        2014
  *
+ * \author      T.Voss, O.Krause, T. Glasmachers
+ * \date        2014-2016
  *
- * \par Copyright 1995-2015 Shark Development Team
+ *
+ * \par Copyright 1995-2016 Shark Development Team
  * 
  * <BR><HR>
  * This file is part of Shark.
@@ -44,7 +50,7 @@
 #include <algorithm>
 #include <iostream>
 #include <vector>
-
+#include <map>
 #include <cmath>
 
 namespace shark {
@@ -53,7 +59,7 @@ namespace shark {
 	*
 	*  The algorithm is described in
 	*
-	*  Nicola Beume und G�nter Rudolph. 
+	*  Nicola Beume und Günter Rudolph. 
 	*  Faster S-Metric Calculation by Considering Dominated Hypervolume as Klee's Measure Problem.
 	*  In: B. Kovalerchuk (ed.): Proceedings of the Second IASTED Conference on Computational Intelligence (CI 2006), 
 	*  pp. 231-236. ACTA Press: Anaheim, 2006.
@@ -63,7 +69,7 @@ namespace shark {
 		/**
 		* \brief Returns an estimate on the runtime of the algorithm.
 		* \param [in] noPoints The number of points n considered in the runtime estimation.
-		* \param [in] noObjectives The number of points m considered in the runtime estimation.
+		* \param [in] noObjectives The number of objectives m considered in the runtime estimation.
 		*/
 		static double runtime( std::size_t noPoints, std::size_t noObjectives ) {
 			if( noPoints < 10 )
@@ -190,12 +196,103 @@ namespace shark {
 			}
 			return h;
 		}
+		else if (m_noObjectives == 3)
+		{
+			if (m_useLogHyp)
+			{
+				double volume = 0.0;
+				double area = 0.0;
+				std::map<double, double> front2D;
+				double prev_x2 = 0.0;
+				for (size_t i=0; i<set.size(); i++)
+				{
+					VectorType x = extractor(set[i]);
+					if (i > 0) volume += area * (std::log(x[2]) - prev_x2);
+
+					// check whether x is dominated
+					std::map<double, double>::iterator worse = front2D.upper_bound(std::log(x[0]));
+					double b = std::log(refPoint[1]);
+					if (worse != front2D.begin())
+					{
+						std::map<double, double>::iterator better = worse;
+						if (better == front2D.end() || better->first > std::log(x[0])) --better;
+						if (better->second <= std::log(x[1])) continue;
+						b = better->second;
+					}
+
+					// remove dominated points
+					while (worse != front2D.end())
+					{
+						if (worse->second < std::log(x[1])) break;
+						std::map<double, double>::iterator it = worse;
+						++worse;
+						double r = (worse == front2D.end()) ? std::log(refPoint[0]): worse->first;
+						area -= (r - it->first) * (b - it->second);
+						front2D.erase(it);
+					}
+
+					// insert x
+					front2D[std::log(x[0])] = std::log(x[1]);
+					double r = (worse == front2D.end()) ? std::log(refPoint[0]) : worse->first;
+					area += (r - std::log(x[0])) * (b - std::log(x[1]));
+
+					prev_x2 = std::log(x[2]);
+				}
+				volume += area * (std::log(refPoint[2]) - prev_x2);
+				return volume;
+			}
+			else
+			{
+				double volume = 0.0;
+				double area = 0.0;
+				std::map<double, double> front2D;
+				double prev_x2 = 0.0;
+				for (size_t i=0; i<set.size(); i++)
+				{
+					VectorType x = extractor(set[i]);
+					if (i > 0) volume += area * (x[2] - prev_x2);
+
+					// check whether x is dominated
+					std::map<double, double>::iterator worse = front2D.upper_bound(x[0]);
+					double b = refPoint[1];
+					if (worse != front2D.begin())
+					{
+						std::map<double, double>::iterator better = worse;
+						if (better == front2D.end() || better->first > x[0]) --better;
+						if (better->second <= x[1]) continue;
+						b = better->second;
+					}
+
+					// remove dominated points
+					while (worse != front2D.end())
+					{
+						if (worse->second < x[1]) break;
+						std::map<double, double>::iterator it = worse;
+						++worse;
+						double r = (worse == front2D.end()) ? refPoint[0]: worse->first;
+						area -= (r - it->first) * (b - it->second);
+						front2D.erase(it);
+					}
 
-		VectorType regLow( m_noObjectives, 1E15 );
-		for( std::size_t i = 0; i < set.size(); i++ ){
-			noalias(regLow) = min(regLow,extractor(set[i]));
+					// insert x
+					front2D[x[0]] = x[1];
+					double r = (worse == front2D.end()) ? refPoint[0] : worse->first;
+					area += (r - x[0]) * (b - x[1]);
+
+					prev_x2 = x[2];
+				}
+				volume += area * (refPoint[2] - prev_x2);
+				return volume;
+			}
+		}
+		else
+		{
+			VectorType regLow( m_noObjectives, 1E15 );
+			for( std::size_t i = 0; i < set.size(); i++ ){
+				noalias(regLow) = min(regLow,extractor(set[i]));
+			}
+			return( stream( regLow, refPoint, set, extractor, 0, refPoint.back() ) );	
 		}
-		return( stream( regLow, refPoint, set, extractor, 0, refPoint.back() ) );	
 	}
 
 	template<typename VectorType>

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/shark.git



More information about the debian-science-commits mailing list