Skip to content

Commit fda76a7

Browse files
authored
Merge pull request #49 from PerformanceEstimation/prepare_for_release_0.1.0
Prepare for release 0.1.0
2 parents 4029e00 + 6e3e3cf commit fda76a7

File tree

8 files changed

+84
-45
lines changed

8 files changed

+84
-45
lines changed

PEPit/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
from .constraint import Constraint
2-
from .expression import Expression
2+
from .expression import Expression, null_expression
33
from .function import Function
44
from .pep import PEP
5-
from .point import Point
5+
from .point import Point, null_point
66

77
__all__ = ['examples',
88
'functions',
99
'operators',
1010
'primitive_steps',
1111
'tools',
1212
'constraint', 'Constraint',
13-
'expression', 'Expression',
13+
'expression', 'Expression', 'null_expression',
1414
'function', 'Function',
1515
'pep', 'PEP',
16-
'point', 'Point',
16+
'point', 'Point', 'null_point',
1717
]

PEPit/expression.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,3 +401,7 @@ def eval(self):
401401

402402
# Return the value
403403
return self._value
404+
405+
406+
# Define a null Expression initialized to 0.
407+
null_expression = Expression(is_leaf=False, decomposition_dict=dict())

PEPit/pep.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@ class PEP(object):
2222
Typically the initial :class:`Constraint`.
2323
list_of_performance_metrics (list): list of :class:`Expression` objects.
2424
The pep maximizes the minimum of all performance metrics.
25-
null_point (Point): a :class:`Point` initialized to 0,
26-
easily callable to initialize a :class:`Point` before a for loop.
27-
null_expression (Expression): a :class:`Expression` initialized to 0,
28-
easily callable to initialize a :class:`Expression` before a for loop.
2925
counter (int): counts the number of :class:`PEP` objects.
3026
Ideally, only one is defined at a time.
3127
@@ -63,10 +59,6 @@ def __init__(self):
6359
self.list_of_performance_metrics = list()
6460
self.list_of_psd = list()
6561

66-
# Add useful attributes of Point and Expression initialized to 0 in their respective space.
67-
self.null_point = Point(is_leaf=False, decomposition_dict=dict())
68-
self.null_expression = Expression(is_leaf=False, decomposition_dict=dict())
69-
7062
def declare_function(self, function_class, **kwargs):
7163
"""
7264
Instantiate a leaf :class:`Function` and store it in the attribute `list_of_functions`.
@@ -152,6 +144,7 @@ def add_psd_matrix(self, matrix):
152144
153145
Raises:
154146
AssertionError: if provided matrix is not a square matrix.
147+
TypeError: if provided matrix does not contain only Expressions.
155148
156149
"""
157150

@@ -165,9 +158,16 @@ def add_psd_matrix(self, matrix):
165158
# Transform scalars into Expressions
166159
for i in range(size):
167160
for j in range(size):
168-
# If entry is neither an Expression nor a python scalar,
169-
# __radd__ method of class Expression raises an Exception.
170-
matrix[i, j] += self.null_expression
161+
# The entry must be an Expression ...
162+
if isinstance(matrix[i, j], Expression):
163+
pass
164+
# ... or a python scalar. If so, store it as an Expression
165+
elif isinstance(matrix[i, j], int) or isinstance(matrix[i, j], float):
166+
matrix[i, j] = Expression(is_leaf=False, decomposition_dict={1: matrix[i, j]})
167+
# Raise an Exception in any other scenario
168+
else:
169+
raise TypeError("PSD matrices contains only Expressions and / or scalar values!"
170+
"Got {}".format(type(matrix[i, j])))
171171

172172
# Add constraint to the list of self's constraints
173173
self.list_of_psd.append(matrix)

PEPit/point.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,3 +276,7 @@ def eval(self):
276276
self._value = value
277277

278278
return self._value
279+
280+
281+
# Define a null Point initialized to 0.
282+
null_point = Point(is_leaf=False, decomposition_dict=dict())

docs/source/whatsnew.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ What's new in PEPit
66
:maxdepth: 2
77
:caption: Contents:
88

9-
whatsnew/0.0.3
9+
whatsnew/0.1.0

docs/source/whatsnew/0.0.3.rst

Lines changed: 0 additions & 28 deletions
This file was deleted.

docs/source/whatsnew/0.1.0.rst

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
What's new in PEPit 0.1.0
2+
=========================
3+
4+
- Adding general constraints to your problem.
5+
6+
| The method ``add_constraint`` has been added to the class ``PEP`` for general constraints not necessarily related to a specific function.
7+
| For readability of your code,
8+
we suggest to use the method ``set_initial_condition`` when the constraint is the initial one,
9+
and the method ``add_constraint`` for any other constraint.
10+
11+
- Adding LMI constraints to your problem.
12+
13+
The method ``add_psd_matrix`` has been added to the class ``PEP`` and must be used to add LMI constraints to your problem.
14+
15+
- CVXPY options.
16+
17+
| PEPit uses CVXPY to solve the underlying SDP of your problem.
18+
| CVXPY solver options can be provided to the method ``PEP.solve``.
19+
20+
- Optimizing dimension of the solution.
21+
22+
| The ``tracetrick`` option of the method ``PEP.solve`` has been replaced by ``dimension_reduction_heuristic``.
23+
| Set to None by default, this option can be set to "`trace`" or "`logdet{followed by a number}`" to use one of those heuristic.
24+
25+
- Granularity of the verbose mode has evolved.
26+
27+
| The verbose mode of the method ``PEP.solve`` and of the provided examples files are now integers:
28+
- 0: No verbose at all
29+
- 1: PEPit information is printed but not CVXPY's
30+
- 2: Both PEPit and CVXPY details are printed
31+
32+
- Parameters of function classes.
33+
34+
| The parameters that characterize a function class must be provided directly as arguments of this function class, not through the dict "param" anymore.
35+
| Example: ``PEP.declare_function(function_class=SmoothStronglyConvexFunction, mu=.1, L=1.)``
36+
37+
- Initializing a Point or an Expression to 0.
38+
39+
``null_point`` and ``null_expression`` have been added to the module ``PEPit`` to facilitate the access to a ``Point`` or an ``Expression`` initialized to 0.
40+
41+
- 3 new function classes have been added:
42+
43+
- ``ConvexSupportFunction`` for convex support functions (see [1])
44+
- ``ConvexQGFunction``, for convex and quadratically upper bounded functions (see [2])
45+
- ``RsiEbFunction``, for functions verifying lower restricted secant inequality and upper error bound (see [3])
46+
47+
`[1] A. Taylor, J. Hendrickx, F. Glineur (2017).
48+
Exact worst-case performance of first-order methods for composite convex optimization.
49+
SIAM Journal on Optimization, 27(3):1283–1313.
50+
<https://arxiv.org/pdf/1512.07516.pdf>`_
51+
52+
`[2] B. Goujaud, A. Taylor, A. Dieuleveut (2022).
53+
Optimal first-order methods for convex functions with a quadratic upper bound.
54+
<https://arxiv.org/pdf/2205.15033.pdf>`_
55+
56+
`[3] C. Guille-Escuret, B. Goujaud, A. Ibrahim, I. Mitliagkas (2022).
57+
Gradient Descent Is Optimal Under Lower Restricted Secant Inequality And Upper Error Bound.
58+
arXiv 2203.00342.
59+
<https://arxiv.org/pdf/2203.00342.pdf>`_

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
with open("README.md", "r", encoding="utf-8") as fh:
44
long_description = fh.read()
55

6-
version = "0.0.3a1"
6+
version = "0.1.0"
77

88
setuptools.setup(
99
name="PEPit",

0 commit comments

Comments
 (0)