Skip to content

Commit fa4c104

Browse files
authored
Merge pull request #34 from bgoujaud/fix/indents
Fix/indents
2 parents fefba38 + 4f60554 commit fa4c104

File tree

6 files changed

+29
-85
lines changed

6 files changed

+29
-85
lines changed

PEPit/examples/composite_convex_minimization/accelerated_douglas_rachford_splitting.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,9 @@ def wc_accelerated_douglas_rachford_splitting(mu, L, alpha, n, verbose=True):
8282
(PEPit) Calling SDP solver
8383
(PEPit) Solver status: optimal (solver: SCS); optimal value: 0.19291623130351168
8484
*** Example file: worst-case performance of the Accelerated Douglas Rachford Splitting in function values ***
85-
PEPit guarantee: F(y_n)-F_* <= 0.192915 ||x0 - ws||^2
86-
Theoretical guarantee for quadratics : F(y_n)-F_* <= 1.68889 ||x0 - ws||^2
85+
PEPit guarantee: F(y_n)-F_* <= 0.192916 ||x0 - ws||^2
86+
Theoretical guarantee for quadratics: F(y_n)-F_* <= 1.68889 ||x0 - ws||^2
87+
8788
"""
8889

8990
# Instantiate PEP
@@ -139,9 +140,9 @@ def wc_accelerated_douglas_rachford_splitting(mu, L, alpha, n, verbose=True):
139140
if verbose:
140141
print('*** Example file:'
141142
' worst-case performance of the Accelerated Douglas Rachford Splitting in function values ***')
142-
print('\tPEPit guarantee:\t \t \t \t \t \t F(y_n)-F_* <= {:.6} ||x0 - ws||^2'.format(pepit_tau))
143+
print('\tPEPit guarantee:\t\t\t F(y_n)-F_* <= {:.6} ||x0 - ws||^2'.format(pepit_tau))
143144
if alpha < 1/L:
144-
print('\tTheoretical guarantee for quadratics :\t F(y_n)-F_* <= {:.6} ||x0 - ws||^2 '.format(theoretical_tau))
145+
print('\tTheoretical guarantee for quadratics:\t F(y_n)-F_* <= {:.6} ||x0 - ws||^2'.format(theoretical_tau))
145146

146147
# Return the worst-case guarantee of the evaluated method (and the upper theoretical value)
147148
return pepit_tau, theoretical_tau

PEPit/examples/composite_convex_minimization/improved_interior_algorithm.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ def wc_improved_interior_algorithm(L, mu, c, lam, n, verbose=True):
7878
function 3 : 42 constraint(s) added
7979
(PEPit) Compiling SDP
8080
(PEPit) Calling SDP solver
81-
(PEPit) Solver status: optimal (solver: MOSEK); optimal value: 0.0680763240358105
81+
(PEPit) Solver status: optimal_inaccurate (solver: SCS); optimal value: 0.06675394483126838
8282
*** Example file: worst-case performance of the Improved interior gradient algorithm in function values ***
83-
PEPit guarantee: F(x_n)-F_* <= 0.0680763 (c * Dh(xs; x0) + f1(x0) - F_ *)
84-
Theoretical guarantee: F(x_n)-F_* <= 0.111111 (c * Dh(xs; x0) + f1(x0) - F_ *)
83+
PEPit guarantee: F(x_n)-F_* <= 0.0667539 (c * Dh(xs;x0) + f1(x0) - F_*)
84+
Theoretical guarantee: F(x_n)-F_* <= 0.111111 (c * Dh(xs;x0) + f1(x0) - F_*)
8585
8686
"""
8787

@@ -132,16 +132,16 @@ def wc_improved_interior_algorithm(L, mu, c, lam, n, verbose=True):
132132
cvxpy_prob = problem.solve(verbose=verbose, return_full_cvxpy_problem=True)
133133
pepit_tau = cvxpy_prob.value
134134
if cvxpy_prob.solver_stats.solver_name == "SCS":
135-
print("\033[93m(PEPit) We recommend to use another solver than SCS, such as MOSEK. \033[0m")
135+
print("\033[96m(PEPit) We recommend to use another solver than SCS, such as MOSEK. \033[0m")
136136

137137
# Compute theoretical guarantee (for comparison)
138138
theoretical_tau = (4 * L) / (c * (n + 1) ** 2)
139139

140140
# Print conclusion if required
141141
if verbose:
142142
print('*** Example file: worst-case performance of the Improved interior gradient algorithm in function values ***')
143-
print('\tPEPit guarantee:\t \t F(x_n)-F_* <= {:.6} (c * Dh(xs;x0) + f1(x0) - F_*)'.format(pepit_tau))
144-
print('\tTheoretical guarantee :\t F(x_n)-F_* <= {:.6} (c * Dh(xs;x0) + f1(x0) - F_*)'.format(theoretical_tau))
143+
print('\tPEPit guarantee:\t F(x_n)-F_* <= {:.6} (c * Dh(xs;x0) + f1(x0) - F_*)'.format(pepit_tau))
144+
print('\tTheoretical guarantee:\t F(x_n)-F_* <= {:.6} (c * Dh(xs;x0) + f1(x0) - F_*)'.format(theoretical_tau))
145145

146146
# Return the worst-case guarantee of the evaluated method (and the upper theoretical value)
147147
return pepit_tau, theoretical_tau

PEPit/examples/inexact_proximal_methods/accelerated_inexact_forward_backward.py

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def wc_accelerated_inexact_forward_backward(L, zeta, n, verbose=True):
2121
inexact accelerated proximal gradient method). That is, it computes the smallest possible
2222
:math:`\\tau(n, L, \\zeta)` such that the guarantee
2323
24-
.. math :: F(x_n) - F(x_\\star) \\leqslant \\tau(n, L, \\zeta ) \\|x_0 - x_\\star\\|^2,
24+
.. math :: F(x_n) - F(x_\\star) \\leqslant \\tau(n, L, \\zeta) \\|x_0 - x_\\star\\|^2,
2525
2626
is valid, where :math:`x_n` is the output of the IAFB, and where :math:`x_\\star` is a minimizer of :math:`F`.
2727
@@ -90,10 +90,10 @@ def wc_accelerated_inexact_forward_backward(L, zeta, n, verbose=True):
9090
function 2 : 528 constraint(s) added
9191
(PEPit) Compiling SDP
9292
(PEPit) Calling SDP solver
93-
(PEPit) Solver status: optimal (solver: MOSEK); optimal value: 0.018734084607959313
93+
(PEPit) Solver status: optimal (solver: SCS); optimal value: 0.018869997698251897
9494
*** Example file: worst-case performance of an inexact accelerated forward backward method ***
95-
PEPit guarantee: F(x_n)-F_* <= 0.0187341
96-
Theoretical guarantee: F(x_n)-F_* <= 0.0269437
95+
PEPit guarantee: F(x_n)-F_* <= 0.01887 ||x_0 - x_*||^2
96+
Theoretical guarantee: F(x_n)-F_* <= 0.0269437 ||x_0 - x_*||^2
9797
9898
"""
9999

@@ -116,20 +116,20 @@ def wc_accelerated_inexact_forward_backward(L, zeta, n, verbose=True):
116116
problem.set_initial_condition((x0 - xs) ** 2 <= 1)
117117

118118
# Some algorithmic parameters (for convenience)
119-
gamma = 1/L
120-
eta = (1-zeta**2) * gamma
119+
gamma = 1 / L
120+
eta = (1 - zeta ** 2) * gamma
121121
A = [0]
122122

123123
# Compute n steps of the IAFB method starting from x0
124124
x = x0
125125
z = x0
126126
for i in range(n):
127-
A.append( A[i] + (eta + sqrt( eta ** 2 + 4 * eta * A[i] ) )/2)
128-
y = x + ( 1 - A[i] / A[i+1] ) * ( z - x )
127+
A.append(A[i] + (eta + sqrt(eta ** 2 + 4 * eta * A[i])) / 2)
128+
y = x + (1 - A[i] / A[i + 1]) * (z - x)
129129
gy = f.gradient(y)
130130
x, sx, hx, _, vx, _, epsVar = inexact_proximal_step(y - gamma * gy, h, gamma, opt='PD_gapI')
131-
h.add_constraint(epsVar <= ( zeta * gamma ) ** 2 / 2 * ( vx + gy ) ** 2) # this is the accuracy requirement
132-
z = z - (A[i+1]-A[i]) * (vx + gy)
131+
h.add_constraint(epsVar <= (zeta * gamma) ** 2 / 2 * (vx + gy) ** 2) # this is the accuracy requirement
132+
z = z - (A[i + 1] - A[i]) * (vx + gy)
133133

134134
# Set the performance metric to the function value accuracy
135135
problem.set_performance_metric((f.value(x) + hx) - Fs)
@@ -138,18 +138,17 @@ def wc_accelerated_inexact_forward_backward(L, zeta, n, verbose=True):
138138
pepit_tau = problem.solve(verbose=verbose)
139139

140140
# Compute theoretical guarantee (for comparison)
141-
theoretical_tau = 2*L/(1-zeta**2)/n**2
141+
theoretical_tau = 2 * L / (1 - zeta ** 2) / n ** 2
142142

143143
# Print conclusion if required
144144
if verbose:
145145
print('*** Example file: worst-case performance of an inexact accelerated forward backward method ***')
146-
print('\tPEPit guarantee:\t F(x_n)-F_* <= {:.6}'.format(pepit_tau))
147-
print('\tTheoretical guarantee:\t F(x_n)-F_* <= {:.6}'.format(theoretical_tau))
146+
print('\tPEPit guarantee:\t F(x_n)-F_* <= {:.6} ||x_0 - x_*||^2'.format(pepit_tau))
147+
print('\tTheoretical guarantee:\t F(x_n)-F_* <= {:.6} ||x_0 - x_*||^2'.format(theoretical_tau))
148148

149149
# Return the worst-case guarantee of the evaluated method (and the upper theoretical value)
150150
return pepit_tau, theoretical_tau
151151

152152

153153
if __name__ == "__main__":
154-
155154
pepit_tau, theoretical_tau = wc_accelerated_inexact_forward_backward(L=1.3, zeta=.45, n=11, verbose=True)

PEPit/examples/unconstrained_convex_minimization/inexact_accelerated_gradient.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def wc_inexact_accelerated_gradient(L, epsilon, n, verbose=True):
7171
(PEPit) Calling SDP solver
7272
(PEPit) Solver status: optimal (solver: SCS); optimal value: 0.03944038534724904
7373
*** Example file: worst-case performance of inexact accelerated gradient method ***
74-
PEPit guarantee: f(x_n)-f_* <= 0.0394404 (f(x_0)-f_*)
74+
PEPit guarantee: f(x_n)-f_* <= 0.0394404 (f(x_0)-f_*)
7575
Theoretical guarantee for epsilon = 0 : f(x_n)-f_* <= 0.0357143 (f(x_0)-f_*)
7676
7777
"""
@@ -113,7 +113,7 @@ def wc_inexact_accelerated_gradient(L, epsilon, n, verbose=True):
113113
# Print conclusion if required
114114
if verbose:
115115
print('*** Example file: worst-case performance of inexact accelerated gradient method ***')
116-
print('\tPEPit guarantee:\t\t f(x_n)-f_* <= {:.6} (f(x_0)-f_*)'.format(pepit_tau))
116+
print('\tPEPit guarantee:\t\t\t f(x_n)-f_* <= {:.6} (f(x_0)-f_*)'.format(pepit_tau))
117117
print('\tTheoretical guarantee for epsilon = 0 :\t f(x_n)-f_* <= {:.6} (f(x_0)-f_*)'.format(theoretical_tau))
118118

119119
# Return the worst-case guarantee of the evaluated method (and the reference theoretical value)

PEPit/pep.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ def _eval_points_and_function_values(self, F_value, G_value, verbose):
321321
# Verify negative eigenvalues are only precision mistakes and get rid of negative eigenvalues
322322
if np.min(eig_val) < 0:
323323
if verbose:
324-
print("\033[93m(PEPit) Postprocessing: solver\'s output is not entirely feasible"
324+
print("\033[96m(PEPit) Postprocessing: solver\'s output is not entirely feasible"
325325
" (smallest eigenvalue of the Gram matrix is: {:.3} < 0).\n"
326326
" Small deviation from 0 may simply be due to numerical error."
327327
" Big ones should be deeply investigated.\n"

ressources/demo/PEPit_demo.ipynb

Lines changed: 2 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@
321321
"(PEPit) Compiling SDP\n",
322322
"(PEPit) Calling SDP solver\n",
323323
"(PEPit) Solver status: optimal (solver: SCS); optimal value: 0.16666634633090185\n",
324-
"\u001b[93m(PEPit) Postprocessing: solver's output is not entirely feasible (smallest eigenvalue of the Gram matrix is: -2.6e-07 < 0).\n",
324+
"\u001b[96m(PEPit) Postprocessing: solver's output is not entirely feasible (smallest eigenvalue of the Gram matrix is: -2.6e-07 < 0).\n",
325325
" Small deviation from 0 may simply be due to numerical error. Big ones should be deeply investigated.\n",
326326
" In any case, from now the provided values of parameters are based on the projection of the Gram matrix onto the cone of symmetric semi-definite matrix.\u001b[0m\n"
327327
]
@@ -406,7 +406,7 @@
406406
"(PEPit) Compiling SDP\n",
407407
"(PEPit) Calling SDP solver\n",
408408
"(PEPit) Solver status: optimal (solver: SCS); optimal value: 0.16666634633090185\n",
409-
"\u001b[93m(PEPit) Postprocessing: solver's output is not entirely feasible (smallest eigenvalue of the Gram matrix is: -2.6e-07 < 0).\n",
409+
"\u001b[96m(PEPit) Postprocessing: solver's output is not entirely feasible (smallest eigenvalue of the Gram matrix is: -2.6e-07 < 0).\n",
410410
" Small deviation from 0 may simply be due to numerical error. Big ones should be deeply investigated.\n",
411411
" In any case, from now the provided values of parameters are based on the projection of the Gram matrix onto the cone of symmetric semi-definite matrix.\u001b[0m\n",
412412
"*** Example file: worst-case performance of gradient descent with fixed step-sizes ***\n",
@@ -1133,62 +1133,6 @@
11331133
"\n",
11341134
"plt.show()"
11351135
]
1136-
},
1137-
{
1138-
"cell_type": "code",
1139-
"execution_count": null,
1140-
"metadata": {},
1141-
"outputs": [],
1142-
"source": []
1143-
},
1144-
{
1145-
"cell_type": "code",
1146-
"execution_count": null,
1147-
"metadata": {},
1148-
"outputs": [],
1149-
"source": []
1150-
},
1151-
{
1152-
"cell_type": "code",
1153-
"execution_count": null,
1154-
"metadata": {},
1155-
"outputs": [],
1156-
"source": []
1157-
},
1158-
{
1159-
"cell_type": "code",
1160-
"execution_count": null,
1161-
"metadata": {},
1162-
"outputs": [],
1163-
"source": []
1164-
},
1165-
{
1166-
"cell_type": "code",
1167-
"execution_count": null,
1168-
"metadata": {},
1169-
"outputs": [],
1170-
"source": []
1171-
},
1172-
{
1173-
"cell_type": "code",
1174-
"execution_count": null,
1175-
"metadata": {},
1176-
"outputs": [],
1177-
"source": []
1178-
},
1179-
{
1180-
"cell_type": "code",
1181-
"execution_count": null,
1182-
"metadata": {},
1183-
"outputs": [],
1184-
"source": []
1185-
},
1186-
{
1187-
"cell_type": "code",
1188-
"execution_count": null,
1189-
"metadata": {},
1190-
"outputs": [],
1191-
"source": []
11921136
}
11931137
],
11941138
"metadata": {

0 commit comments

Comments
 (0)