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

Fix removevredundancy! #53

Merged
merged 5 commits into from
Jan 21, 2025
Merged

Fix removevredundancy! #53

merged 5 commits into from
Jan 21, 2025

Conversation

oyamad
Copy link
Member

@oyamad oyamad commented Jan 18, 2025

@oyamad oyamad added the bug label Jan 18, 2025
@blegat
Copy link
Member

blegat commented Jan 18, 2025

You can update redund directly here:

push!(redset, ineq)

by pushing ineq + 1
and here
function redundi(m::RepMatrix, ineq::Int)

You can replace ineq::Int by ineq::Polyhedra.Index.
Then it's clear we are talking about 1-based indexing because of:
0 < idx.value <= length(vrep) && isl == islin(idx) && isp == ispoint(idx)

@@ -55,8 +55,6 @@ function getine(p::Polyhedron)
else
p.ine = LiftedHRepresentation(getextm(p, :Fresh))
p.inem = nothing
p.hlinearitydetected = true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leave the setting of hlinearitydetected here and add a mention to the issue to say that in some examples there are still redundant elements

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed back p.hlinearitydetected = true and p.vlinearitydetected = true in getine and getext.

(By the way, please feel free to edit this branch.)

@oyamad
Copy link
Member Author

oyamad commented Jan 18, 2025

Pushing ineq + 1 in redund generates many errors; see #54.

@oyamad
Copy link
Member Author

oyamad commented Jan 20, 2025

@blegat Is it possible that for H-representation, the first column (row 0 in the C indexing) is used for the objective function, while it is not case for V-representation? (I.e., Does "row i" point to different rows between H- and V-representations?)

LRSLib.jl/src/matrix.jl

Lines 51 to 54 in 22915a1

# This is the objective. If I have no objective LRS might fail
if Hrep
setrow(P, Q, 0, ones(Rational{BigInt}, n), true)
end

LRSLib.jl/src/matrix.jl

Lines 77 to 80 in 22915a1

# This is the objective. If I have no objective LRS might fail
if inequality
setrow(P, Q, 0, ones(Rational{BigInt}, n), true)
end

@blegat
Copy link
Member

blegat commented Jan 20, 2025

Yes, and you always need to set an objective for the H-rep:

LRSLib.jl/src/matrix.jl

Lines 51 to 54 in 22915a1

# This is the objective. If I have no objective LRS might fail
if Hrep
setrow(P, Q, 0, ones(Rational{BigInt}, n), true)
end

@oyamad
Copy link
Member Author

oyamad commented Jan 21, 2025

I think I understand the things now.

  • redund returns 0-based indices, and removevredundancy! takes them as 1-based indices, and so it removes wrong rows.
  • The same applies to removehredundancy!, but for H-representation, the top row is reserved for the objective, and therefore removehredundancy! removes correct rows (by coincidence).

The bug can be fixed by either

  • adding 1 to the output of redund(extm) in removevredundancy! (this PR);
    or
  • adding 1 to ineq in redund and subtracting 1 in the output of redund(inem) in detectvlinearity! (Fix redund and removehredundancy! #54).

Each of this PR and #54 is ready to merge. Please choose one!

Copy link
Member

@blegat blegat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Let's merge this one as it is non-breaking for redund then we'll see if we want to additionally make a breaking change

@blegat blegat merged commit fc49d96 into master Jan 21, 2025
6 checks passed
@oyamad oyamad deleted the redund branch January 21, 2025 09:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: removevredundancy! removes wrong row
2 participants