Opened 6 years ago
Closed 6 years ago
#18852 closed defect (duplicate)
interactive_simplex_method: Enable typesetting of run_simplex_method in SageMathCloud
Reported by: | mkoeppe | Owned by: | |
---|---|---|---|
Priority: | minor | Milestone: | sage-duplicate/invalid/wontfix |
Component: | numerical | Keywords: | lp |
Cc: | novoselt, ncohen | Merged in: | |
Authors: | Reviewers: | ||
Report Upstream: | N/A | Work issues: | |
Branch: | Commit: | ||
Dependencies: | #18292, #19097 | Stopgaps: |
Description (last modified by )
I tried to use interactive_simplex_method in SageMathCloud?, and it seems the current model of InteractiveLPProblemStandardForm.run_simplex_method
and LPDictionary.ELLUL
to return a string of LaTeX code is not a good fit. (See screenshot.)
I propose to change these methods so they just call pretty_print
repeatedly and return nothing. An optional keyword argument, show=False, would turn off output. This is used when, for example, run_simplex_method
is called by final_dictionary
.
Attachments (1)
Change History (16)
Changed 6 years ago by
comment:1 Changed 6 years ago by
- Cc novoselt ncohen added
- Description modified (diff)
- Summary changed from interactive_simplex_method: Output improvements to interactive_simplex_method: Enable typesetting of run_simplex_method in SageMathCloud
comment:2 follow-up: ↓ 5 Changed 6 years ago by
Please don't make rush changes here - it was a lot of pain to make things work in SageNB and SageTeX. The name also may not be fitting if it was just printing something.
Note that it does not return just a string - it returns a LatexExpr
which should be typeset by frontends automatically.
Although there are problems because of the long LaTeX code - I had to increase limits on the size of expressions handled by SMC. So there may be some sense in showing steps as separate formulas in run_simplex_method
to ease the load on MathJax, but ELLUL
works exactly as it should - if SMC can't deal with it, SMC has to be tuned.
comment:3 Changed 6 years ago by
Thanks a lot for your comments! Do we need to Cc: someone working on SMC to make them aware of this?
comment:4 Changed 6 years ago by
I've opened https://github.com/sagemathinc/smc/issues/40
comment:5 in reply to: ↑ 2 Changed 6 years ago by
Replying to novoselt:
Although there are problems because of the long LaTeX code - I had to increase limits on the size of expressions handled by SMC. So there may be some sense in showing steps as separate formulas in
run_simplex_method
to ease the load on MathJax, butELLUL
works exactly as it should - if SMC can't deal with it, SMC has to be tuned.
I guess showing the steps as separate formulas would also allow to show a plot after each update step (if the user requests that), showing the current basic solution...
comment:6 Changed 6 years ago by
- Dependencies set to #18292
Once we have html blocks implemented, run_simplex_method
should return HTMLFragment
which will be the current string:
- it should display nicely when rendered as HTML
- formulas will be in math mode automatically and will be rendered one-by-one, helping to avoid problems with too long input for MathJax
- the same string should work as LaTeX code as well
ELLUL
on the other hand still should return LatexExpr
since it constructs a single formula.
comment:7 Changed 6 years ago by
This sounds like a plan, though I must say that I don't understand the output model of Sage.
I know that run_simplex_method stores the final dictionary in an attribute; but suppose it would have to be a return value instead. If the function wants to print its progress (sequence of dictionaries) on the screen AND return a value, would it then have to return two values: (1) the HTMLFragment and (2) the dictionary?
comment:8 Changed 6 years ago by
It is usually a bad idea to output "the progress": you can't be sure how output is handled and there will be no way to catch this output for further processing.
comment:9 Changed 6 years ago by
Well, it's called logging, and python has a somewhat sophisticated facility for this.
Without using the logging facility, one could simply pass a callback function to a productive function such as run_simplex_method that is called when there is something to be output.
comment:10 Changed 6 years ago by
Logging and output are quite orthogonal, I would say.
I am also not aware of many (if any) functions in Sage that use callbacks apart from "infrastructure". And there is certainly no need for them in this module.
comment:11 Changed 6 years ago by
OK, we'll just wait for #18292
comment:12 Changed 6 years ago by
- Dependencies changed from #18292 to #18292, #19097
- Milestone changed from sage-6.8 to sage-duplicate/invalid/wontfix
The new output code of #19097 is a better approach.
This ticket can be closed.
comment:13 Changed 6 years ago by
- Status changed from new to needs_review
comment:14 Changed 6 years ago by
- Status changed from needs_review to positive_review
comment:15 Changed 6 years ago by
- Resolution set to duplicate
- Status changed from positive_review to closed
screen shot - interactive simplex in SageMathCloud?