GithubHelp home page GithubHelp logo

Comments (9)

odow avatar odow commented on July 19, 2024 1

See https://jump.dev/JuMP.jl/stable/manual/constraints/#Set-inequality-syntax

The set defines the partial ordering of >=.

@constraint(model, X >= Y, Nonpositives() means X - Y in Nonpositives(), or X - Y <= 0.

from jump.jl.

odow avatar odow commented on July 19, 2024 1

but that's , which is not the same symbol as ,

Sure. We intentionally conflate the two because is hard to type in ASCII.

from jump.jl.

blegat avatar blegat commented on July 19, 2024

We can probably make this work

@constraint(model, Symmetric(A) == Symmetric(B))

by adding something like

function build_constraint(error_fn, Q::Symmetric, set::Union{Zeros,Nonnegatives,Nonpositives})
    n = LinearAlgebra.checksquare(Q)
    shape = SymmetricMatrixShape(n)
    return VectorConstraint(
        vectorize(Q, shape),
        set,
        shape,
    )
end

For the inequality, I'd prefer an explicit:

@constraint(model, Symmetric(A) >= Symmetric(B), Nonnegatives())

because most user would actually expect a PSD constraint, not elementwise inequality when you do an inequality between matrices so it would be too confusing to make it work without the extra argument.
Currently, Nonnegatives will be added by default and you get an error:

JuMP.jl/src/sd.jl

Lines 575 to 582 in 56b186f

function build_constraint(error_fn::Function, ::AbstractMatrix, ::Nonnegatives)
return error_fn(
"Unsupported matrix in vector-valued set. Did you mean to use the " *
"broadcasting syntax `.>=` instead? Alternatively, perhaps you are " *
"missing a set argument like `@constraint(model, X >= 0, PSDCone())` " *
"or `@constraint(model, X >= 0, HermmitianPSDCone())`.",
)
end

Adding the build_constraint I suggest above wouldn't distinguish between the case where Nonnegatives is added explicitly. We would need a way to distinguish it before allow Nonnegatives in build_constraint.

from jump.jl.

LebedevRI avatar LebedevRI commented on July 19, 2024

We can probably make this work

@constraint(model, Symmetric(A) == Symmetric(B))

Err, note that for equality, it already works.

For the inequality, I'd prefer an explicit:

@constraint(model, Symmetric(A) >= Symmetric(B), Nonnegatives())

Without ever having used the PSD side of things,
this syntax looks kinda weird to me.
What happens if the wrong set is specified?

from jump.jl.

odow avatar odow commented on July 19, 2024

because most user would actually expect a PSD constraint

Agreed. We discussed this, see #3281 (comment)

@constraint(model, Symmetric(A) >= Symmetric(B), Nonnegatives())

👍 this solves a lot of issues.

What happens if the wrong set is specified?

There is no such thing as the "wrong" set. The constraint is rewritten to Symmetric(A) - Symmetric(B) in Set()

from jump.jl.

LebedevRI avatar LebedevRI commented on July 19, 2024

What happens if the wrong set is specified?

There is no such thing as the "wrong" set. The constraint is rewritten to Symmetric(A) - Symmetric(B) in Set()

What i mean is, there's both the inequality comparison between A and B,
and a statement about the set to which the A-B belong to.
One of these is redundant.

A >= B, is A - B >= 0 aka A - B in Nonnegatives, sure, absolutely.

But what would A - B >= 0, Nonpositives aka A - B in Nonnegatives in Nonpositives mean?
That's a bogus constraint (it should be an equality-with-zero constraint), that is not exactly easy to spot,
so i would very much hope that it would be invalid and rejected with a diagnostic.
And by that point, what's the point of accepting both the set and the inequality operator?
It's a footgun. (At most, perhaps it should be some syntactic sugar placeholder set that is otherwise unused.)

from jump.jl.

LebedevRI avatar LebedevRI commented on July 19, 2024

Oh wow, that is the most exquisite design decision (strictly from the user-facing view,
i'm sure it makes sense from the internal implementation detail) i've seen in last few years...

from jump.jl.

odow avatar odow commented on July 19, 2024

I might be misinterpreting your comment, but this is not a design decision that is unique to JuMP.

It follows from the syntax for the generalized inequality of a cone:

$x \succeq_K y \iff x - y \in K$

See, e.g., Section 2.4.1 of Boyd and Vandenberghe.

from jump.jl.

LebedevRI avatar LebedevRI commented on July 19, 2024

I might be misinterpreting your comment,

It is more that i'm failing to fully convey my point :)

It follows from the syntax for the generalized inequality of a cone:

x⪰Ky⟺x−y∈K

See, e.g., Section 2.4.1 of Boyd and Vandenberghe.

Yes, but that's , which is not the same symbol as ,
though they may look similar in small font size.
I just feel like that have a very well defined meaning,
so reusing them in this context is confusing.

Anyways, that would be better than nothing i suppose :)

from jump.jl.

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.