cvxgrp / dsp Goto Github PK
View Code? Open in Web Editor NEWA CVXPY extension for saddle problems
License: Apache License 2.0
A CVXPY extension for saddle problems
License: Apache License 2.0
I think it would be helpful to have all cvxpy related packages in a cvx namespace. E.g. you would introduce a folder cvx (without init.py) and in there you would the dsp package. This would avoid collision if you work in projects with multiple cvx related packages. I do this for example in cvxmarkowitz or in the cvxrisk also in the simulator package. cvx is always the route of the source folders. Having a name like cvx.. makes it also nice when you poetry show (or similar)... @phschiele @PTNobel
cvxpy_integration.py
currently throws
ModuleNotFoundError: No module named 'cvxpy.reductions.dcp2cone.atom_canonicalizers'
when used with cvxpy 1.4.
Hello,
Using both cvxpy-1.4.1 and cvxpy-1.4.2, trying to import dsp, I get this error:
File [~/mambaforge/envs/torch2/lib/python3.11/site-packages/dsp/__init__.py:1](https://vscode-remote+ssh-002dremote-002blaurent-002dworkstation-002elan-002eetive-002ecom.vscode-resource.vscode-cdn.net/home/laurent/code/market-downloader/~/mambaforge/envs/torch2/lib/python3.11/site-packages/dsp/__init__.py:1)
----> [1](https://vscode-remote+ssh-002dremote-002blaurent-002dworkstation-002elan-002eetive-002ecom.vscode-resource.vscode-cdn.net/home/laurent/code/market-downloader/~/mambaforge/envs/torch2/lib/python3.11/site-packages/dsp/__init__.py:1) from dsp.cvxpy_integration import add_is_dsp, extend_cone_canon_methods
[2](https://vscode-remote+ssh-002dremote-002blaurent-002dworkstation-002elan-002eetive-002ecom.vscode-resource.vscode-cdn.net/home/laurent/code/market-downloader/~/mambaforge/envs/torch2/lib/python3.11/site-packages/dsp/__init__.py:2) from dsp.local import LocalVariable
[3](https://vscode-remote+ssh-002dremote-002blaurent-002dworkstation-002elan-002eetive-002ecom.vscode-resource.vscode-cdn.net/home/laurent/code/market-downloader/~/mambaforge/envs/torch2/lib/python3.11/site-packages/dsp/__init__.py:3) from dsp.problem import MinimizeMaximize, SaddlePointProblem, is_dsp
File [~/mambaforge/envs/torch2/lib/python3.11/site-packages/dsp/cvxpy_integration.py:2](https://vscode-remote+ssh-002dremote-002blaurent-002dworkstation-002elan-002eetive-002ecom.vscode-resource.vscode-cdn.net/home/laurent/code/market-downloader/~/mambaforge/envs/torch2/lib/python3.11/site-packages/dsp/cvxpy_integration.py:2)
[1](https://vscode-remote+ssh-002dremote-002blaurent-002dworkstation-002elan-002eetive-002ecom.vscode-resource.vscode-cdn.net/home/laurent/code/market-downloader/~/mambaforge/envs/torch2/lib/python3.11/site-packages/dsp/cvxpy_integration.py:1) from cvxpy import Expression, Problem
----> [2](https://vscode-remote+ssh-002dremote-002blaurent-002dworkstation-002elan-002eetive-002ecom.vscode-resource.vscode-cdn.net/home/laurent/code/market-downloader/~/mambaforge/envs/torch2/lib/python3.11/site-packages/dsp/cvxpy_integration.py:2) from cvxpy.reductions.dcp2cone.atom_canonicalizers import CANON_METHODS
[4](https://vscode-remote+ssh-002dremote-002blaurent-002dworkstation-002elan-002eetive-002ecom.vscode-resource.vscode-cdn.net/home/laurent/code/market-downloader/~/mambaforge/envs/torch2/lib/python3.11/site-packages/dsp/cvxpy_integration.py:4) from dsp.problem import is_dsp
[5](https://vscode-remote+ssh-002dremote-002blaurent-002dworkstation-002elan-002eetive-002ecom.vscode-resource.vscode-cdn.net/home/laurent/code/market-downloader/~/mambaforge/envs/torch2/lib/python3.11/site-packages/dsp/cvxpy_integration.py:5) from dsp.saddle_extremum import conjugate, saddle_max, saddle_min
ModuleNotFoundError: No module named 'cvxpy.reductions.dcp2cone.atom_canonicalizers'
Looking at the code of CVXPY 1.3.2, I can indeed see the required symbol: https://github.com/cvxpy/cvxpy/blob/v1.3.2/cvxpy/reductions/dcp2cone/atom_canonicalizers/__init__.py
However, CVXPY 1.4.0, renamed it as https://github.com/cvxpy/cvxpy/blob/v1.4.0/cvxpy/reductions/dcp2cone/canonicalizers/__init__.py
@phschiele
Could you please grant me access such that I could create branches. Please no powers to write to main...
In cvxpy, problem.solve() returns the optimal value. It might be better if dsp.Problem had the same behavior.
It would be better if MinimizeMaximize
supported more of the standard methods for cvxpy objects, such as .variables()
to get all the variables and .parameters()
to get all the parameters.
It says
Copyright 2017 Steven Diamond
Not sure I'm using it correctly, but here is a MWE:
import dsp
import cvxpy as cvx
from numpy.random import default_rng
rng = default_rng(seed=777)
def mwe():
n = 5
A = rng.integers(low=1, high=5, size=(n, n))
print(A)
x = cvx.Variable(n)
y = cvx.Variable(n)
constraints = [x >= 0, y >= 0, cvx.sum(x) == 1, cvx.sum(y) == 1]
objs = [
dsp.MinimizeMaximize(f)
for f in (
dsp.inner(-x, A @ y),
dsp.inner(x, -A @ y),
-dsp.inner(x, A @ y),
)
]
for obj in objs:
prob = dsp.SaddlePointProblem(obj, constraints)
prob.solve()
print(prob.value)
if __name__ == "__main__":
mwe()
This prints out
[[4 3 2 2 1]
[3 2 4 2 1]
[2 2 2 3 2]
[3 2 3 1 2]
[4 1 3 1 3]]
-2.00000000020348
-2.00000000020348
-2.333333332964706
Why is the third one different, and which is the right way? The docs just reference scaling in general, not restricting it to positive.
Should saddle_innder(Fx, Gy)
be saddle_inner(Fx, Gy)
?
"Saddle functions can scaled ..."
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.