Skip to content

Commit

Permalink
Cosmit.
Browse files Browse the repository at this point in the history
  • Loading branch information
mblondel committed Nov 1, 2019
1 parent bec7be2 commit 75edc54
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions polytopes.py
Expand Up @@ -431,13 +431,17 @@ def _Euclidean_project(self, theta):
w = np.array(w)
if not self.w_sorted:
w = w[np.argsort(w)[::-1]]

perm = np.argsort(theta)[::-1]
theta = theta[perm]
dual_sol = isotonic_regression(w - theta, increasing=True)
primal_sol = dual_sol + theta

dual_sol = isotonic_regression(theta - w, increasing=False)

# Or equivalently
#dual_sol = isotonic_regression(theta - w, increasing=False)
#primal_sol = theta - dual_sol
#dual_sol = -isotonic_regression(w - theta, increasing=True)

primal_sol = theta - dual_sol

return primal_sol[inv_permutation(perm)]

def _KL_project(self, theta):
Expand Down

0 comments on commit 75edc54

Please sign in to comment.