Skip to content

Commit 50c901f

Browse files
Merge branch 'PerformanceEstimation:master' into minmax_block
2 parents e826704 + e50f05f commit 50c901f

58 files changed

Lines changed: 7998 additions & 373 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/execute_notebook.yaml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,46 +11,48 @@ on:
1111
branches:
1212
- 'master'
1313
- 'develop'
14+
1415
create:
1516
branches:
1617
- 'master'
1718
tags:
1819
- '**'
1920

21+
2022
jobs:
2123
linux:
22-
runs-on: ubuntu-latest
24+
runs-on: ubuntu-22.04
2325
if: "!contains(github.event.head_commit.message, 'no ci')"
2426
strategy:
2527
max-parallel: 5
2628
matrix:
27-
os: [ubuntu-latest]
2829
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
2930

3031
steps:
31-
- uses: actions/checkout@v1
32+
- uses: actions/checkout@v4
3233

3334
- name: Set up Python ${{ matrix.python-version }}
34-
uses: actions/setup-python@v4
35+
uses: actions/setup-python@v5
3536
with:
3637
python-version: ${{ matrix.python-version }}
38+
cache: 'pip'
3739

3840
- name: Install dependencies
3941
run: |
4042
python -m pip install --upgrade pip
41-
pip install lxml_html_clean
42-
pip install -r requirements.txt
43-
pip install mosek
43+
python -m pip install lxml_html_clean
44+
python -m pip install -r requirements.txt
45+
python -m pip install mosek
4446
4547
- name: Update version in setup.py
4648
run: sed -i "s/{{VERSION_PLACEHOLDER}}/0.0.0/g" setup.py
4749

4850
- name: Install PEPit
49-
run: pip install -e .
51+
run: python -m pip install -e .
5052

5153
- name: Install notebook runner deps (papermill etc.)
5254
run: |
53-
pip install papermill ipykernel nbformat nbconvert
55+
python -m pip install papermill ipykernel nbformat nbconvert
5456
5557
- name: Run demo notebook with papermill
5658
env:

.github/workflows/pypi_release.yaml

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,40 @@ name: Publish Python 🐍 distributions 📦 to PyPI
33
on:
44
push:
55
tags:
6-
- '*'
6+
- '*'
77

88
jobs:
99
build-n-publish:
1010
name: Build and publish Python 🐍 distributions 📦 to PyPI
11-
runs-on: ubuntu-latest
11+
runs-on: ubuntu-22.04
12+
1213
steps:
13-
- uses: actions/checkout@master
14-
- name: Set up Python 3.10
15-
uses: actions/setup-python@v3
16-
with:
17-
python-version: '3.10'
18-
- name: Install pypa/setuptools
19-
run: >-
20-
python -m
21-
pip install wheel
22-
- name: Extract tag name
23-
id: tag
24-
run: echo ::set-output name=TAG_NAME::$(echo $GITHUB_REF | cut -d / -f 3)
25-
- name: Update version in setup.py
26-
run: >-
27-
sed -i "s/{{VERSION_PLACEHOLDER}}/${{ steps.tag.outputs.TAG_NAME }}/g" setup.py
28-
- name: Build a binary wheel
29-
run: >-
30-
python setup.py sdist bdist_wheel
31-
- name: Publish distribution 📦 to PyPI
32-
uses: pypa/gh-action-pypi-publish@master
33-
with:
34-
password: ${{ secrets.PYPI_API_TOKEN }}
14+
- uses: actions/checkout@v4
15+
16+
- name: Set up Python 3.10
17+
uses: actions/setup-python@v5
18+
with:
19+
python-version: '3.10'
20+
21+
- name: Install build tooling
22+
run: |
23+
python -m pip install --upgrade pip
24+
python -m pip install build
25+
26+
- name: Extract tag name
27+
id: tag
28+
run: |
29+
echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
30+
31+
- name: Update version in setup.py
32+
run: |
33+
sed -i "s/{{VERSION_PLACEHOLDER}}/${{ steps.tag.outputs.TAG_NAME }}/g" setup.py
34+
35+
- name: Build distributions
36+
run: |
37+
python -m build
38+
39+
- name: Publish distribution 📦 to PyPI
40+
uses: pypa/gh-action-pypi-publish@release/v1
41+
with:
42+
password: ${{ secrets.PYPI_API_TOKEN }}

.github/workflows/tests.yaml

Lines changed: 89 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -21,107 +21,119 @@ on:
2121

2222
jobs:
2323
linux:
24-
25-
runs-on: ubuntu-latest
24+
runs-on: ubuntu-22.04
2625
if: "!contains(github.event.head_commit.message, 'no ci')"
2726
strategy:
2827
max-parallel: 5
2928
matrix:
3029
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
3130

3231
steps:
33-
- uses: actions/checkout@v1
34-
- name: Set up Python ${{ matrix.python-version }}
35-
uses: actions/setup-python@v1
36-
with:
37-
python-version: ${{ matrix.python-version }}
38-
- name: Install dependencies
39-
run: |
40-
python -m pip install --upgrade pip
41-
pip install -r requirements.txt
42-
pip install coverage
43-
- name: Update version in setup.py
44-
run: >-
45-
sed -i "s/{{VERSION_PLACEHOLDER}}/0.0.0/g" setup.py
46-
- name: Install PEPit
47-
run: |
48-
pip install -e .
49-
- name: Install MOSEK
50-
run: |
51-
pip install mosek
52-
- name: Setup MOSEK license, run tests and generate report
53-
env:
54-
MOSEKLM_LICENSE_FILE: ${{ secrets.MSK_LICENSE }}
55-
run: |
56-
coverage run -m unittest tests/test_*
57-
- name: Upload Coverage to Codecov
58-
uses: codecov/codecov-action@v3
32+
- uses: actions/checkout@v4
5933

34+
- name: Set up Python ${{ matrix.python-version }}
35+
uses: actions/setup-python@v5
36+
with:
37+
python-version: ${{ matrix.python-version }}
38+
cache: 'pip'
6039

61-
linux_no_mosek:
40+
- name: Install dependencies
41+
run: |
42+
python -m pip install --upgrade pip
43+
python -m pip install -r requirements.txt
44+
python -m pip install coverage
45+
46+
- name: Update version in setup.py
47+
run: sed -i "s/{{VERSION_PLACEHOLDER}}/0.0.0/g" setup.py
48+
49+
- name: Install PEPit
50+
run: python -m pip install -e .
51+
52+
- name: Install MOSEK
53+
run: python -m pip install mosek
54+
55+
- name: Setup MOSEK license, run tests and generate report
56+
env:
57+
MOSEKLM_LICENSE_FILE: ${{ secrets.MSK_LICENSE }}
58+
run: |
59+
coverage run -m unittest tests/test_*
6260
63-
runs-on: ubuntu-latest
61+
- name: Upload Coverage to Codecov
62+
uses: codecov/codecov-action@v3
63+
64+
65+
linux_no_mosek:
66+
runs-on: ubuntu-22.04
6467
if: "!contains(github.event.head_commit.message, 'no ci')"
6568
strategy:
6669
max-parallel: 5
6770
matrix:
6871
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
6972

7073
steps:
71-
- uses: actions/checkout@v1
72-
- name: Set up Python ${{ matrix.python-version }}
73-
uses: actions/setup-python@v1
74-
with:
75-
python-version: ${{ matrix.python-version }}
76-
- name: Install dependencies
77-
run: |
78-
python -m pip install --upgrade pip
79-
pip install -r requirements.txt
80-
pip install coverage
81-
- name: Update version in setup.py
82-
run: >-
83-
sed -i "s/{{VERSION_PLACEHOLDER}}/0.0.0/g" setup.py
84-
- name: Install PEPit
85-
run: |
86-
pip install -e .
87-
- name: Run tests and generate report
88-
run: |
89-
coverage run -m unittest tests/test_*
90-
- name: Upload Coverage to Codecov
91-
uses: codecov/codecov-action@v3
74+
- uses: actions/checkout@v4
9275

76+
- name: Set up Python ${{ matrix.python-version }}
77+
uses: actions/setup-python@v5
78+
with:
79+
python-version: ${{ matrix.python-version }}
80+
cache: 'pip'
9381

94-
linux_no_mosek_license:
82+
- name: Install dependencies
83+
run: |
84+
python -m pip install --upgrade pip
85+
python -m pip install -r requirements.txt
86+
python -m pip install coverage
87+
88+
- name: Update version in setup.py
89+
run: sed -i "s/{{VERSION_PLACEHOLDER}}/0.0.0/g" setup.py
90+
91+
- name: Install PEPit
92+
run: python -m pip install -e .
9593

96-
runs-on: ubuntu-latest
94+
- name: Run tests and generate report
95+
run: |
96+
coverage run -m unittest tests/test_*
97+
98+
- name: Upload Coverage to Codecov
99+
uses: codecov/codecov-action@v3
100+
101+
102+
linux_no_mosek_license:
103+
runs-on: ubuntu-22.04
97104
if: "!contains(github.event.head_commit.message, 'no ci')"
98105
strategy:
99106
max-parallel: 5
100107
matrix:
101108
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
102109

103110
steps:
104-
- uses: actions/checkout@v1
105-
- name: Set up Python ${{ matrix.python-version }}
106-
uses: actions/setup-python@v1
107-
with:
108-
python-version: ${{ matrix.python-version }}
109-
- name: Install dependencies
110-
run: |
111-
python -m pip install --upgrade pip
112-
pip install -r requirements.txt
113-
pip install coverage
114-
- name: Update version in setup.py
115-
run: >-
116-
sed -i "s/{{VERSION_PLACEHOLDER}}/0.0.0/g" setup.py
117-
- name: Install PEPit
118-
run: |
119-
pip install -e .
120-
- name: Setup MOSEK
121-
run: |
122-
pip install mosek
123-
- name: Run tests and generate report
124-
run: |
125-
coverage run -m unittest tests/test_*
126-
- name: Upload Coverage to Codecov
127-
uses: codecov/codecov-action@v3
111+
- uses: actions/checkout@v4
112+
113+
- name: Set up Python ${{ matrix.python-version }}
114+
uses: actions/setup-python@v5
115+
with:
116+
python-version: ${{ matrix.python-version }}
117+
cache: 'pip'
118+
119+
- name: Install dependencies
120+
run: |
121+
python -m pip install --upgrade pip
122+
python -m pip install -r requirements.txt
123+
python -m pip install coverage
124+
125+
- name: Update version in setup.py
126+
run: sed -i "s/{{VERSION_PLACEHOLDER}}/0.0.0/g" setup.py
127+
128+
- name: Install PEPit
129+
run: python -m pip install -e .
130+
131+
- name: Setup MOSEK
132+
run: python -m pip install mosek
133+
134+
- name: Run tests and generate report
135+
run: |
136+
coverage run -m unittest tests/test_*
137+
138+
- name: Upload Coverage to Codecov
139+
uses: codecov/codecov-action@v3

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,3 +137,4 @@ dmypy.json
137137
# Documentation
138138
docs/autodocgen-output
139139
docs/build
140+
docs/source/notebooks_folder

PEPit/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from .constraint import Constraint
33
from .expression import Expression, null_expression
44
from .function import Function
5+
from .interpolator import Interpolator
56
from .psd_matrix import PSDMatrix
67
from .wrapper import Wrapper
78
from .pep import PEP
@@ -10,13 +11,15 @@
1011
__all__ = ['block_partition', 'BlockPartition',
1112
'examples',
1213
'functions',
14+
'interpolators',
1315
'operators',
1416
'primitive_steps',
1517
'tools',
1618
'wrappers',
1719
'constraint', 'Constraint',
1820
'expression', 'Expression', 'null_expression',
1921
'function', 'Function',
22+
'interpolator', 'Interpolator',
2023
'psd_matrix', 'PSDMatrix',
2124
'pep', 'PEP',
2225
'point', 'Point', 'null_point',

PEPit/constraint.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ class Constraint(object):
88
99
Attributes:
1010
name (str): A name set through the set_name method. None is no name is given.
11+
activated (bool): A boolean flag used to activate/deactivate the Constraint in the PEP.
1112
expression (Expression): The :class:`Expression` that is compared to 0.
1213
equality_or_inequality (str): "equality" or "inequality". Encodes the type of constraint.
1314
_value (float): numerical value of `self.expression` obtained after solving the PEP via SDP solver.
@@ -56,13 +57,16 @@ def __init__(self,
5657
AssertionError: if provided `equality_or_inequality` argument is neither "equality" nor "inequality".
5758
5859
"""
59-
# Initialize name of the constraint
60-
self.name = None
60+
# Initialize the activated attribute to True
61+
self.activated = True
6162

6263
# Update the counter
6364
self.counter = Constraint.counter
6465
Constraint.counter += 1
6566

67+
# Initialize name of the constraint
68+
self.name = "Constraint {}".format(self.counter)
69+
6670
# Store the underlying expression
6771
self.expression = expression
6872

@@ -92,6 +96,20 @@ def get_name(self):
9296
"""
9397
return self.name
9498

99+
def activate(self):
100+
"""
101+
Activate the use of the Constraint.
102+
103+
"""
104+
self.activated = True
105+
106+
def deactivate(self):
107+
"""
108+
Deactivate the use of the Constraint.
109+
110+
"""
111+
self.activated = False
112+
95113
def eval(self):
96114
"""
97115
Compute, store and return the value of the underlying :class:`Expression` of this :class:`Constraint`.

0 commit comments

Comments
 (0)