From 8aa23c31de6fdadde3b3f3059d411251851ebcd4 Mon Sep 17 00:00:00 2001 From: Rowan Cockett Date: Tue, 16 Feb 2016 21:53:31 -0800 Subject: [PATCH 1/2] Allow moving off bounds in projected gradient. The current implementation does not allow you to move off the bounds (lower/upper) once you have gotten on them, this allows you to move off of the bound. Please note that more testing should be done to ensure that this does not introduce oscillations into the optimization routine. --- SimPEG/Optimization.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/SimPEG/Optimization.py b/SimPEG/Optimization.py index 4f2cb062..54f6c4ff 100644 --- a/SimPEG/Optimization.py +++ b/SimPEG/Optimization.py @@ -990,4 +990,18 @@ class ProjectedGNCG(BFGS, Minimize, Remember): cgFlag = 1 # End CG Iterations + # Take a gradient step on the active cells if exist + if temp != self.xc.size: + + rhs_a = (Active) * -self.g + + dm_i = max( abs( delx ) ) + dm_a = max( abs(rhs_a) ) + + delx = delx + rhs_a * dm_i / dm_a /10. + + # Only keep gradients going in the right direction on the active set + indx = ((self.xc<=self.lower) & (delx < 0)) | ((self.xc>=self.upper) & (delx > 0)) + delx[indx] = 0. + return delx From 5d9d74693234102d6ce593577a2e2532ddea1c16 Mon Sep 17 00:00:00 2001 From: Lindsey Heagy Date: Sun, 3 Apr 2016 10:42:28 -0700 Subject: [PATCH 2/2] kwarg for stepping off bounds in projected gradient --- SimPEG/Optimization.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/SimPEG/Optimization.py b/SimPEG/Optimization.py index 54f6c4ff..0a241710 100644 --- a/SimPEG/Optimization.py +++ b/SimPEG/Optimization.py @@ -888,6 +888,8 @@ class ProjectedGNCG(BFGS, Minimize, Remember): maxIterCG = 5 tolCG = 1e-1 + stepOffBoundsFact = 0.1 # perturbation of the inactive set off the bounds + lower = -np.inf upper = np.inf @@ -998,7 +1000,8 @@ class ProjectedGNCG(BFGS, Minimize, Remember): dm_i = max( abs( delx ) ) dm_a = max( abs(rhs_a) ) - delx = delx + rhs_a * dm_i / dm_a /10. + # perturb inactive set off of bounds so that they are included in the step + delx = delx + self.stepOffBoundsFact * (rhs_a * dm_i / dm_a) # Only keep gradients going in the right direction on the active set indx = ((self.xc<=self.lower) & (delx < 0)) | ((self.xc>=self.upper) & (delx > 0))