Ask Your Question
0

Linear programming displaying Latex formated equations

asked 2020-07-28 16:55:19 +0200

Cyrille gravatar image

updated 2023-05-19 22:07:45 +0200

FrédéricC gravatar image

The following works fine:

A = ([1,0], [0, -1], [6,10], [-6,-10])
B = (18, -12,70, -70)
C = (-4.10, -8)
P = InteractiveLPProblem(A, B, C, ["x_1", "x_2"], variable_type=">=")
P
P.plot()

But when I run:

P.run_simplex_method()

SageMath says that the original problem is infeasible and should stop there. But some LaTeX formatted equations appear after. This could be troublesome for student so I would be glad to know how to stop displaying anything after the diagnosis of infeasibility. Is this possible? My students need to be confronted to infeasibility.

edit retag flag offensive close merge delete

Comments

slelievre I am sorry I know how to do but I cannot arrive to correct this bug from my computer. I have tried many time (today again) but I cannot arrive to fix this problem). No one of your suggestion works.

Cyrille gravatar imageCyrille ( 2020-07-29 11:59:42 +0200 )edit

Incidentaly I have the same problem with an other program which gives the solution (which exists) but display some step as Latex formated equations.

Cyrille gravatar imageCyrille ( 2020-07-29 12:01:21 +0200 )edit

I was just giving hints on how to format questions in Ask Sage.

I have now edited your question myself to fix the formatting.

slelievre gravatar imageslelievre ( 2020-07-29 14:02:42 +0200 )edit

I cannot reproduce. Here is what I get:

sage: A = ([1,0], [0, -1], [6,10], [-6,-10])
sage: B = (18, -12,70, -70)
sage: C = (-4.10, -8)
sage: P = InteractiveLPProblem(A, B, C, ["x_1", "x_2"], variable_type=">=")
sage: P
LP problem (use typeset mode to see details)
sage: P.plot()
Launched png viewer for Graphics object consisting of 19 graphics primitives
sage: P.run_simplex_method()
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-7-c3b26ca305e2> in <module>()
----> 1 P.run_simplex_method()

AttributeError: 'InteractiveLPProblem' object has no attribute 'run_simplex_method'

Do you use any extra optional package?

slelievre gravatar imageslelievre ( 2020-07-29 14:06:17 +0200 )edit

1 Answer

Sort by » oldest newest most voted
1

answered 2020-07-29 17:51:41 +0200

Emmanuel Charpentier gravatar image

From the documentation:

The simplex method can be applied only to problems in standard form, which can be created either directly

sage: InteractiveLPProblemStandardForm(A, b, c, ["C", "B"])
LP problem (use typeset mode to see details)

or from an already constructed problem of “general type”:

sage: P = P.standard_form()

So :

sage: foo=P.standard_form().run_simplex_method()
sage: type(foo)
<class 'sage.misc.html.HtmlFragment'>

This methods seems to be aimed at doing some computations on (supposedly toy) example(s) and "print" the wanted results, not to return any result further usable.

To get anything else, your best bet is probably to start from this method's source code ad wrap your own. Possibly following the module authors' advice :

This module, meant for educational purposes only, supports learning and exploring of the simplex method.

Do you want to solve Linear Programs efficiently? use MixedIntegerLinearProgram instead.

HTH,

edit flag offensive delete link more

Comments

But Slelievre I know how to use MixedIntegerLinearProgram, I use clearly this module for educational purposes. I have reread the doc in fact the result seems normal since the formulas are quite long, But Nobvoltsev could have change the lenght of the formula by adding \small. Also, I am not sure that \begin{equation*} is known by Mathjax

Cyrille gravatar imageCyrille ( 2020-07-30 11:59:45 +0200 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2020-07-28 16:55:19 +0200

Seen: 399 times

Last updated: Jul 29 '20