Skip to content

Commit e826704

Browse files
committed
Corrected Interpolation conditions
1 parent e949fde commit e826704

2 files changed

Lines changed: 33 additions & 42 deletions

File tree

PEPit/examples/minmax_optimization/minmax_prox_blockcoordinate.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from PEPit.functions import BlockConvexConcaveFunction
33
from PEPit.point import Point
44
from PEPit.expression import Expression
5-
5+
import numpy as np
66

77
def wc_proximal_point(gamma, n, wrapper="cvxpy", solver=None, verbose=1):
88
"""
@@ -100,7 +100,6 @@ def wc_proximal_point(gamma, n, wrapper="cvxpy", solver=None, verbose=1):
100100
func = problem.declare_function(function_class=BlockConvexConcaveFunction, partition=block_partition)
101101
# Start by defining its unique optimal point xs = x_* and corresponding function value fs = f_*
102102
zs = func.stationary_point()
103-
fs = func(zs)
104103

105104
# Then define the starting point x0 of the algorithm
106105
z0 = problem.set_initial_point()
@@ -110,42 +109,42 @@ def wc_proximal_point(gamma, n, wrapper="cvxpy", solver=None, verbose=1):
110109

111110
# Run n steps of the proximal point method
112111
z = z0
113-
z_avg = z
114-
count = 1
112+
z_prev = z
113+
115114
for _ in range(n):
116115

117116

118117
# Compute x from the docstring equation.
119118
gz = Point()
120119
fz = Expression()
120+
z_prev = z
121121
z = z - gamma * block_partition.get_block(gz, 0)
122122
z = z + gamma * block_partition.get_block(gz, 1)
123-
z_avg += z
124-
count+=1
123+
125124
# Add point to Function f.
126125
func.add_point((z, gz, fz))
127126

128-
z_avg /= count
129-
#func.add_point((z_avg, func.gradient(z_avg), func(z_avg)))
127+
130128
# Set the performance metric to the final distance to optimum in function values
131-
problem.set_performance_metric(func(z_avg)-fs)
129+
problem.set_performance_metric((z-z_prev)**2)
132130

133131
# Solve the PEP
134132
pepit_verbose = max(verbose, 0)
135133
pepit_tau = problem.solve(wrapper=wrapper, solver=solver, verbose=pepit_verbose)
136134

137135
# Compute theoretical guarantee (for comparison)
138-
theoretical_tau = 1 / (gamma * n)
136+
#theoretical_tau = 1 / (gamma * n)
137+
theoretical_tau = np.power((1.0 - (1.0/n)), n-1)/n
139138

140139
# Print conclusion if required
141140
if verbose != -1:
142141
print('*** Example file: worst-case performance of proximal point method ***')
143-
print('\tPEPit guarantee:\t f(z_avg)-f_* <= {:.6} ||z_0 - z_*||^2'.format(pepit_tau))
144-
print('\tTheoretical guarantee:\t f(z_avg)-f_* <= {:.6} ||z_0 - z_*||^2'.format(theoretical_tau))
142+
print('\tPEPit guarantee:\t ||z_n - z_n-1||^2 <= {:.6} ||z_0 - z_*||^2'.format(pepit_tau))
143+
print('\tTheoretical guarantee:\t||z_n - z_n-1||^2<= {:.6} ||z_0 - z_*||^2'.format(theoretical_tau))
145144

146145
# Return the worst-case guarantee of the evaluated method (and the reference theoretical value)
147146
return pepit_tau, theoretical_tau
148147

149148

150149
if __name__ == "__main__":
151-
pepit_tau, theoretical_tau = wc_proximal_point(gamma=0.2, n=10, wrapper="cvxpy", solver=None, verbose=1)
150+
pepit_tau, theoretical_tau = wc_proximal_point(gamma=2, n=5, wrapper="cvxpy", solver=None, verbose=1)

PEPit/functions/block_convex_concave_function.py

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -80,45 +80,37 @@ def add_class_constraints(self):
8080
function_id = "Function_{}".format(self.counter)
8181

8282
# Set tables_of_constraints attributes
83-
self.tables_of_constraints["convexity_block_{}".format(0)] = [[]]*len(self.list_of_points)
84-
self.tables_of_constraints["concavity_block_{}".format(1)] = [[]]*len(self.list_of_points)
83+
self.tables_of_constraints["convexity_concavity_block_{}".format(0)] = [[]]*len(self.list_of_points)
8584

8685
# Browse list of points and create interpolation constraints
8786
for i, point_i in enumerate(self.list_of_points):
8887

89-
xi, gi, fi = point_i
90-
xi_id = xi.get_name()
91-
if xi_id is None:
92-
xi_id = "Point_{}".format(i)
88+
zi, gi, fi = point_i
89+
zi_id = zi.get_name()
90+
if zi_id is None:
91+
zi_id = "Point_{}".format(i)
9392

9493
for j, point_j in enumerate(self.list_of_points):
9594

96-
xj, gj, fj = point_j
97-
xj_id = xj.get_name()
98-
if xj_id is None:
99-
xj_id = "Point_{}".format(j)
95+
zj, gj, fj = point_j
96+
zj_id = zj.get_name()
97+
if zj_id is None:
98+
zj_id = "Point_{}".format(j)
10099

101100
if point_i == point_j:
102-
self.tables_of_constraints["convexity_block_{}".format(0)][i].append(0)
103-
self.tables_of_constraints["concavity_block_{}".format(1)][i].append(0)
101+
self.tables_of_constraints["convexity_concavity_block_{}".format(0)][i].append(0)
104102

105103
else:
106-
gj_cvx = self.partition.get_block(gj, 0)
107-
xi_cvx = self.partition.get_block(xi, 0)
108-
xj_cvx = self.partition.get_block(xj, 0)
109-
constraint = fi - fj >= gj_cvx * (xi_cvx - xj_cvx)
110-
constraint.set_name("IC_{}_convexity_block_{}({}, {})".format(function_id, 0,
111-
xi_id, xj_id))
112-
self.tables_of_constraints["convexity_block_{}".format(0)][i].append(constraint)
104+
gj_x = self.partition.get_block(gj, 0)
105+
xi = self.partition.get_block(zi, 0)
106+
xj = self.partition.get_block(zj, 0)
107+
108+
gi_y = self.partition.get_block(gi, 1)
109+
yi = self.partition.get_block(zi, 1)
110+
yj = self.partition.get_block(zj, 1)
111+
constraint = fi >= fj + gj_x * (xi - xj) + gi_y * (yi - yj)
112+
constraint.set_name("IC_{}_convexity_concavity_block_{}({}, {})".format(function_id, 0,
113+
zi_id, zj_id))
114+
self.tables_of_constraints["convexity_concavity_block_{}".format(0)][i].append(constraint)
113115
self.list_of_class_constraints.append(constraint)
114-
115-
gj_ccv = self.partition.get_block(gj, 1)
116-
xi_ccv = self.partition.get_block(xi, 1)
117-
xj_ccv = self.partition.get_block(xj, 1)
118-
constraint = fi - fj <= gj_ccv * (xi_ccv - xj_ccv)
119-
constraint.set_name("IC_{}_concavity_block_{}({}, {})".format(function_id, 1,
120-
xi_id, xj_id))
121-
self.tables_of_constraints["concavity_block_{}".format(1)][i].append(constraint)
122-
self.list_of_class_constraints.append(constraint)
123-
124116

0 commit comments

Comments
 (0)