Giter Site home page Giter Site logo

Comments (6)

SteveDiamond avatar SteveDiamond commented on July 30, 2024 1

You have to solve the problem.

from cvxpy.

SteveDiamond avatar SteveDiamond commented on July 30, 2024

I was able to reproduce the issue.

from cvxpy.

PTNobel avatar PTNobel commented on July 30, 2024
import cvxpy as cp
import numpy as np
d = 10
np.random.seed(0)
A = np.random.randn(5, 10)
B = np.random.randn(4, 10)
C = np.random.randn(3, 10)
x = cp.Variable(d)
objective = cp.Minimize(cp.sum_squares(A@x) + cp.mixed_norm(cp.hstack([B @ x, C @ x, np.ones(d)]), 1, 2))

I was unable to reproduce the issue with this script. Is there any info I'm missing?

from cvxpy.

SteveDiamond avatar SteveDiamond commented on July 30, 2024

@raff0722 you're hitting this bug #1963
In your problem mixed_norm isn't doing anything different than regular norm because the hstack output is 1D. Possibly you didn't mean for it to be 1D. We follow NumPy conventions for hstack, vstack, concatenate, etc.

from cvxpy.

PTNobel avatar PTNobel commented on July 30, 2024

Here's the minimized script:

import cvxpy as cp
import numpy as np
d = 10
objective = cp.Minimize(0)
constr = [cp.mixed_norm(cp.hstack([np.ones(d)]), 1, 2) <= 1]
cp.Problem(objective, constr).solve()

It is worth at least fixing its error message.

from cvxpy.

raff0722 avatar raff0722 commented on July 30, 2024

@raff0722 you're hitting this bug #1963 In your problem mixed_norm isn't doing anything different than regular norm because the hstack output is 1D. Possibly you didn't mean for it to be 1D. We follow NumPy conventions for hstack, vstack, concatenate, etc.

Yes, that was the issue. Thank you! I expected a matrix with d rows and 3 columns. Now I used bmat as follows

cp.mixed_norm( cp.bmat([ [B@x], [C@x], [np.ones(d)] ), 1, 2 )

which works.

However, I find the doc about bmat a bit confusing. It says

Takes a list of lists. Each internal list is stacked horizontally. The internal lists are stacked vertically.

Morevoer, based on Meaning in
image
I would expect that I have to transpose the matrix, i.e., use

cp.mixed_norm( cp.bmat( [ [B@x], [C@x], [np.ones(d)] ] ).T, 1, 2 )

which however gave the wrong result.

from cvxpy.

Related Issues (20)

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.