-
-
Notifications
You must be signed in to change notification settings - Fork 480
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
sage.numerical.interactive_simplex_method
: improve support for base fields other than QQ
and RDF
#37865
base: develop
Are you sure you want to change the base?
Conversation
Documentation preview for this PR (built with commit e5035be; changes) is ready! 🎉 |
775dd97
to
998ccd4
Compare
sage.numerical.interactive_simplex_method
: improve support for base fields other than qq rdfsage.numerical.interactive_simplex_method
: improve support for base fields other than QQ
and RDF
@@ -301,22 +300,23 @@ def _latex_product(coefficients, variables, | |||
sage: var("x, y") # needs sage.symbolic | |||
(x, y) | |||
sage: print(_latex_product([-1, 3], [x, y])) # needs sage.symbolic | |||
- \mspace{-6mu}&\mspace{-6mu} x \mspace{-6mu}&\mspace{-6mu} + \mspace{-6mu}&\mspace{-6mu} 3 y | |||
- \mspace{-6mu}&\mspace{-6mu} 1 x \mspace{-6mu}&\mspace{-6mu} + \mspace{-6mu}&\mspace{-6mu} 3 y |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ComboProblem I think this is an unintended change. Could you investigate what's causing this behavior?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issue is in Line 316-322. For the text input, with c=-1
and v = var("x")
, we have that t.strip() = '-1'
and c = 1
. So the if block here isn't executed and the else block code writes a coefficient of c=1into the expression.
Furthermore, with fields that have a presentation of 1 that is not the string 1, we have that outputs are not as we'd expect for a coefficient of 1. See the attached example with RDF.
For the -1
as a coefficient example, I think a change to line 316 like if t.strip() == '1' or t.strip() == '-1':
would fix this. For fields with different presentations of 1 other than the string 1, I'm unsure of how to approach this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can live with 1.0 showing as 1.0; what's more surprising to me is that the objective constant shows as 0, not 0.0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default constructor for InteractiveLPProblem
specifies the objective_constant_term
term as the integer 0 rather than the base ring element 0. The code doesn't explicitly convert the objective_constant_term
to an element of the base ring.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. That should probably be changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've just opened a PR that fixes this with the other changes discussed so far.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I've merged your PR mkoeppe#41 now
@ComboProblem I've copied in the ticket description from the old ticket #31312. Part of what it's promising:
Could you add a test that uses an LP with coefficients from |
e5835cc
to
a637158
Compare
a3bef0e
to
61774e8
Compare
61774e8
to
b58c1c7
Compare
b58c1c7
to
20bbebf
Compare
20bbebf
to
4dce510
Compare
…- no longer needed now that algebraic polyhedra are supported in Sage
…nd a coefficient depend on the same test that sage.misc.repr.coeff_repr uses
… not compare coefficients with 0, compare latex representation with 0 instead
…-1 output; change default 0 to base ring 0.
…ermining the common base ring
4dce510
to
e5035be
Compare
We remove the ad-hoc conversion of data to
RDF
inInteractiveLPProblem.feasible_set
. This is outdated and problematic:RDF
is not robust at allWe also make the printing code in
_latex_product
more robust:SR
to decide whether a coefficient needs to be wrapped in parens; instead, we use the same simple test thatsage.misc.repr.coeff_repr
already usesSR
where==
is magicRebased version of:
Author: @mkoeppe, @ComboProblem
Resolves #31312.
📝 Checklist
⌛ Dependencies