Skip to content

Commit

Permalink
Fixing failing test for plot_envelope due to solver tolerances
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffrey-hokanson committed Aug 30, 2019
1 parent 701adab commit 10ec29d
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions psdr/subspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import cvxopt

from .pgf import PGF
from .domains.domain import DEFAULT_CVXPY_KWARGS
from .misc import merge

__all__ = ['SubspaceBasedDimensionReduction',
'ActiveSubspace',
Expand Down Expand Up @@ -142,7 +144,9 @@ def shadow_envelope(self, X, fX, ax = None, ngrid = None, pgfname = None, verbos
else:
if len(U.shape) > 1:
U = U[:,0]


# Since this is for plotting purposes, we reduce accuracy to 3 digits
solver_kwargs = {'verbose': verbose, 'solver': 'OSQP', 'eps_abs': 1e-3, 'eps_rel': 1e-3}

X = np.array(X)
fX = np.array(fX)
Expand Down Expand Up @@ -196,14 +200,14 @@ def shadow_envelope(self, X, fX, ax = None, ngrid = None, pgfname = None, verbos
#ub0 = [ max(max(fX[j == i]), max(fX[j== i+1])) for i in np.arange(0,ngrid-1)] +[max(fX[j == ngrid - 1])]
#ub.value = np.array(ub0).flatten()
prob = cp.Problem(cp.Minimize(cp.sum(ub)), [A*ub >= fX.flatten()])
prob.solve(verbose = verbose, warm_start = True)
prob.solve(**solver_kwargs)
ub = ub.value

lb = cp.Variable(len(yy))
#lb0 = [ min(min(fX[j == i]), min(fX[j== i+1])) for i in np.arange(0,ngrid-1)] +[min(fX[j == ngrid - 1])]
#lb.value = np.array(lb0).flatten()
prob = cp.Problem(cp.Maximize(cp.sum(lb)), [A*lb <= fX.flatten()])
prob.solve(verbose = verbose, warm_start = True)
prob.solve(**solver_kwargs)
lb = lb.value

if ax is not None:
Expand Down

0 comments on commit 10ec29d

Please sign in to comment.