[opengm] 165/386: added EpsStrategy parameter to bundle method

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Wed Aug 31 08:37:11 UTC 2016


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

ghisvail-guest pushed a commit to branch debian/master
in repository opengm.

commit a54a1071c1fdbee72be7e7760a9e3452e593ee36
Author: Jan Funke <funke at ini.ch>
Date:   Fri Dec 19 14:58:17 2014 +0100

    added EpsStrategy parameter to bundle method
---
 include/opengm/learning/bundle-optimizer.hxx | 50 +++++++++++++++++++++++-----
 1 file changed, 41 insertions(+), 9 deletions(-)

diff --git a/include/opengm/learning/bundle-optimizer.hxx b/include/opengm/learning/bundle-optimizer.hxx
index 03d1778..7b020c6 100644
--- a/include/opengm/learning/bundle-optimizer.hxx
+++ b/include/opengm/learning/bundle-optimizer.hxx
@@ -39,21 +39,42 @@ class BundleOptimizer {
 
 public:
 
+	enum EpsStrategy {
+
+		/**
+		 * Compute the eps from the gap estimate between the lower bound and the 
+		 * target objective. The gap estimate will only be correct for oracle 
+		 * calls that perform exact inference.
+		 */
+		EpsFromGap,
+
+		/**
+		 * Compute the eps from the change of the minimum of the lower bound.  
+		 * This version does also work for approximate (but deterministic) 
+		 * inference methods.
+		 */
+		EpsFromChange
+	};
+
 	struct Parameter {
 
 		Parameter() :
 			lambda(1.0),
-			min_gap(1e-5),
-			steps(0) {}
+			min_eps(1e-5),
+			steps(0),
+			epsStrategy(EpsFromChange) {}
 
 		// regularizer weight
 		double lambda;
 
-		// stopping criteria of the bundle method optimization
-		ValueType min_gap;
-
 		// the maximal number of steps to perform, 0 = no limit
 		unsigned int steps;
+
+		// bundle method stops if eps is smaller than this value
+		ValueType min_eps;
+
+		// how to compute the eps for the stopping criterion
+		EpsStrategy epsStrategy;
 	};
 
 	BundleOptimizer(const Parameter& parameter = Parameter());
@@ -127,7 +148,8 @@ BundleOptimizer<T>::optimize(Oracle& oracle, Weights& w) {
 	  9. return w_t
 	*/
 
-	T minValue = std::numeric_limits<T>::infinity();
+	T minValue     =  std::numeric_limits<T>::infinity();
+	T lastMinLower = -std::numeric_limits<T>::infinity();
 
 	unsigned int t = 0;
 
@@ -176,12 +198,18 @@ BundleOptimizer<T>::optimize(Oracle& oracle, Weights& w) {
 		//std::cout << " w* of ℒ(w)   + ½λ|w|²   is: "  << w << std::endl;
 
 		// compute gap
-		T eps_t = minValue - minLower;
+		T eps_t;
+		if (_parameter.epsStrategy == EpsFromGap)
+			eps_t = minValue - minLower;
+		else
+			eps_t = minLower - lastMinLower;
+
+		lastMinLower = minLower;
 
 		std::cout  << "          ε   is: " << eps_t << std::endl;
 
 		// converged?
-		if (eps_t <= _parameter.min_gap)
+		if (eps_t <= _parameter.min_eps)
 			break;
 	}
 
@@ -230,11 +258,15 @@ BundleOptimizer<T>::findMinLowerBound(ModelWeights& w, T& value) {
 	std::string msg;
 	bool optimal = _solver->solve(x, value, msg);
 
-	if (!optimal)
+	if (!optimal) {
+
 		std::cerr
 				<< "[BundleOptimizer] QP could not be solved to optimality: "
 				<< msg << std::endl;
 
+		return;
+	}
+
 	for (size_t i = 0; i < w.numberOfWeights(); i++)
 		w[i] = x[i];
 }

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



More information about the debian-science-commits mailing list