From a91501af565e52920c00f37729cf393f2b57affb Mon Sep 17 00:00:00 2001 From: James Hensman Date: Fri, 10 May 2013 16:39:20 +0100 Subject: [PATCH] minor modifications to the constraint behaviour --- GPy/core/transformations.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/GPy/core/transformations.py b/GPy/core/transformations.py index be8c3030..e446566e 100644 --- a/GPy/core/transformations.py +++ b/GPy/core/transformations.py @@ -34,6 +34,8 @@ class logexp(transformation): ef = np.exp(f) return (ef - 1.)/ef def initialize(self,f): + if np.any(f<0.): + print "Warning: changing parameters to satisfy constraints" return np.abs(f) def __str__(self): return '(+ve)' @@ -48,6 +50,8 @@ class exponent(transformation): def gradfactor(self,f): return f def initialize(self,f): + if np.any(f<0.): + print "Warning: changing parameters to satisfy constraints" return np.abs(f) def __str__(self): return '(+ve)' @@ -62,6 +66,8 @@ class negative_exponent(transformation): def gradfactor(self,f): return f def initialize(self,f): + if np.any(f>0.): + print "Warning: changing parameters to satisfy constraints" return -np.abs(f) def __str__(self): return '(-ve)' @@ -79,7 +85,9 @@ class logistic(transformation): def gradfactor(self,f): return (f-self.lower)*(self.upper-f)/self.difference def initialize(self,f): - return self.f(f*0.) + if np.any(np.logical_or(fself.upper)): + print "Warning: changing parameters to satisfy constraints" + return np.where(np.logical_or(fself.upper),self.f(f*0.),f) def __str__(self): return '({},{})'.format(self.lower,self.upper)