Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It eliminated the incorrect variable, didn't it? #338

Closed
WuSiren opened this issue Apr 3, 2024 · 5 comments · Fixed by #339
Closed

It eliminated the incorrect variable, didn't it? #338

WuSiren opened this issue Apr 3, 2024 · 5 comments · Fixed by #339

Comments

@WuSiren
Copy link

WuSiren commented Apr 3, 2024

using JuMP, Polyhedra, CDDLib
m = Model()
@variable(m, d[1:2])
@variable(m, 0 <= g[1:2] <= 1)
@constraint(m, d[1] == 1 + 100g[1])
@constraint(m, d[2] == 2 + 100g[2])
all_variables(m) # To check the dimension names.
p = polyhedron(m, CDDLib.Library(:exact))
P = eliminate(p, [3:4;])
[1, 2] in P, [0, 0] in P

The result is (false, true), which indicates the projection polyhedron is with respect to the eliminated variable g[1:2] but not the expected d[1:2].

Is this a bug, or I didn't use it correctly?

Looking forward to response. Thanks!

@schillic
Copy link
Contributor

schillic commented Apr 3, 2024

Let me add some more information.

This is the variable order:

julia> all_variables(m)
4-element Vector{VariableRef}:
 d[1]
 d[2]
 g[1]
 g[2]

The result P is

Polyhedron CDDLib.Polyhedron{Rational{BigInt}}:
4-element iterator of HalfSpace{Rational{BigInt}, Vector{Rational{BigInt}}}:
 HalfSpace(Rational{BigInt}[-1, 0], 0//1)
 HalfSpace(Rational{BigInt}[0, -1], 0//1)
 HalfSpace(Rational{BigInt}[1, 0], 1//1)
 HalfSpace(Rational{BigInt}[0, 1], 1//1)

which is $0 \le x_1 \le 1 \land 0 \le x_2 \le 1$.

And for completeness, here is the other projection:

julia> P = eliminate(p, [1:2;])
Polyhedron CDDLib.Polyhedron{Rational{BigInt}}:
4-element iterator of HalfSpace{Rational{BigInt}, Vector{Rational{BigInt}}}:
 HalfSpace(Rational{BigInt}[-1, 0], -1//1)
 HalfSpace(Rational{BigInt}[0, -1], -2//1)
 HalfSpace(Rational{BigInt}[1, 0], 101//1)
 HalfSpace(Rational{BigInt}[0, 1], 102//1)

which is $1 \le x_1 \le 101 \land 2 \le x_2 \le 102$.

@WuSiren
Copy link
Author

WuSiren commented Apr 3, 2024

Yes, thanks. But it behaves oppositely to the example here, doesn't it?

@WuSiren
Copy link
Author

WuSiren commented Apr 6, 2024

Pardon me, is there any change? I retested the above example, why didn't I see any changes?

@schillic
Copy link
Contributor

schillic commented Apr 6, 2024

@WuSiren there is not yet a new release of this package. For now you can use the development version via the dev command:

pkg> dev Polyhedra

@WuSiren
Copy link
Author

WuSiren commented Apr 7, 2024

Oh, I see. Many thanks! 🤝

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants