Coder Social home page Coder Social logo

dsp's Issues

Naming convention?

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

No module named 'cvxpy.reductions.dcp2cone.atom_canonicalizers'

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

variables and parameters for MinimizeMaximize

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.

Negative scaling of inner() atom

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.

DOC: typo?

Should saddle_innder(Fx, Gy) be saddle_inner(Fx, Gy)?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.