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

interactive_simplex_method: Enable typesetting of run_simplex_method in SageMathCloud #18852

Closed
mkoeppe opened this issue Jul 6, 2015 · 16 comments

Comments

@mkoeppe
Copy link
Contributor

mkoeppe commented Jul 6, 2015

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.

Depends on #18292
Depends on #19097

CC: @novoselt @nathanncohen

Component: numerical

Issue created by migration from https://trac.sagemath.org/ticket/18852

@mkoeppe mkoeppe added this to the sage-6.8 milestone Jul 6, 2015
@mkoeppe
Copy link
Contributor Author

mkoeppe commented Jul 6, 2015

screen shot - interactive simplex in SageMathCloud

@mkoeppe

This comment has been minimized.

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Jul 6, 2015

comment:1

Attachment: Screen Shot 2015-07-05 at 7.26.06 PM.png

@mkoeppe mkoeppe changed the title interactive_simplex_method: Output improvements interactive_simplex_method: Enable typesetting of run_simplex_method in SageMathCloud Jul 6, 2015
@novoselt
Copy link
Member

novoselt commented Jul 6, 2015

comment:2

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.

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Jul 6, 2015

comment:3

Thanks a lot for your comments!
Do we need to Cc: someone working on SMC to make them aware of this?

@novoselt
Copy link
Member

novoselt commented Jul 6, 2015

comment:4

I've opened sagemathinc/cocalc#40

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Jul 22, 2015

comment:5

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, but ELLUL 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...

@novoselt
Copy link
Member

Dependencies: #18292

@novoselt
Copy link
Member

comment:6

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.

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Aug 26, 2015

comment:7

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?

@novoselt
Copy link
Member

comment:8

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.

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Aug 26, 2015

comment:9

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.

@novoselt
Copy link
Member

comment:10

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.

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Aug 26, 2015

comment:11

OK, we'll just wait for #18292

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Nov 13, 2015

comment:12

The new output code of #19097 is a better approach.

This ticket can be closed.

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Nov 13, 2015

Changed dependencies from #18292 to #18292, #19097

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

No branches or pull requests

3 participants