ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 31 Aug 2016 21:45:37 +0200How to get step by step table in Simplex method in sagemath?https://ask.sagemath.org/question/34649/how-to-get-step-by-step-table-in-simplex-method-in-sagemath/I have used the following commands to solve a linear programing problem in sagemath.
>p = MixedIntegerLinearProgram(maximization=True, solver='GLPK')
>x = p.new_variable(nonnegative=True)
> p.set_objective(12*x[0] + 3*x[1]+x[2])
> p.add_constraint(10*x[0] + 2*x[1]+x[2]<= 100)
>p.add_constraint(7*x[0] +3*x[1]+2*x[2] <= 77)
> p.add_constraint(2*x[0] + 4*x[1]+x[2] <= 80)
> p.show()
> print 'The optimal value:', QQ(p.solve())
It solved and gave the answer. But I want to generate a step by step table to explain to the students.
Is there any possible way to get the step by step table? or should we have to modify the program to do so?Tue, 30 Aug 2016 08:15:37 +0200https://ask.sagemath.org/question/34649/how-to-get-step-by-step-table-in-simplex-method-in-sagemath/Comment by kcrisman for <p>I have used the following commands to solve a linear programing problem in sagemath.</p>
<pre><code>>p = MixedIntegerLinearProgram(maximization=True, solver='GLPK')
>x = p.new_variable(nonnegative=True)
> p.set_objective(12*x[0] + 3*x[1]+x[2])
> p.add_constraint(10*x[0] + 2*x[1]+x[2]<= 100)
>p.add_constraint(7*x[0] +3*x[1]+2*x[2] <= 77)
> p.add_constraint(2*x[0] + 4*x[1]+x[2] <= 80)
> p.show()
> print 'The optimal value:', QQ(p.solve())
</code></pre>
<p>It solved and gave the answer. But I want to generate a step by step table to explain to the students.</p>
<p>Is there any possible way to get the step by step table? or should we have to modify the program to do so?</p>
https://ask.sagemath.org/question/34649/how-to-get-step-by-step-table-in-simplex-method-in-sagemath/?comment=34655#post-id-34655Probably you would have to write a completely new method, as `MILP` may not even use plain old simplex method internally, depending on the solver (it might, but I'm not sure of that). It certainly would not support a step-by-step table. However, such an addition would be of very useful pedagogical value for Sage-using educators! Edit - see tmonteil's answer instead!Tue, 30 Aug 2016 14:33:54 +0200https://ask.sagemath.org/question/34649/how-to-get-step-by-step-table-in-simplex-method-in-sagemath/?comment=34655#post-id-34655Answer by tmonteil for <p>I have used the following commands to solve a linear programing problem in sagemath.</p>
<pre><code>>p = MixedIntegerLinearProgram(maximization=True, solver='GLPK')
>x = p.new_variable(nonnegative=True)
> p.set_objective(12*x[0] + 3*x[1]+x[2])
> p.add_constraint(10*x[0] + 2*x[1]+x[2]<= 100)
>p.add_constraint(7*x[0] +3*x[1]+2*x[2] <= 77)
> p.add_constraint(2*x[0] + 4*x[1]+x[2] <= 80)
> p.show()
> print 'The optimal value:', QQ(p.solve())
</code></pre>
<p>It solved and gave the answer. But I want to generate a step by step table to explain to the students.</p>
<p>Is there any possible way to get the step by step table? or should we have to modify the program to do so?</p>
https://ask.sagemath.org/question/34649/how-to-get-step-by-step-table-in-simplex-method-in-sagemath/?answer=34662#post-id-34662Sage has an interactive simplex method designed for pedagogical use: you can have a look at [this page](http://doc.sagemath.org/html/en/reference/numerical/sage/numerical/interactive_simplex_method.html)
Wed, 31 Aug 2016 02:37:17 +0200https://ask.sagemath.org/question/34649/how-to-get-step-by-step-table-in-simplex-method-in-sagemath/?answer=34662#post-id-34662Comment by kcrisman for <p>Sage has an interactive simplex method designed for pedagogical use: you can have a look at <a href="http://doc.sagemath.org/html/en/reference/numerical/sage/numerical/interactive_simplex_method.html">this page</a></p>
https://ask.sagemath.org/question/34649/how-to-get-step-by-step-table-in-simplex-method-in-sagemath/?comment=34670#post-id-34670But this is great - I should have actually looked!Wed, 31 Aug 2016 21:45:37 +0200https://ask.sagemath.org/question/34649/how-to-get-step-by-step-table-in-simplex-method-in-sagemath/?comment=34670#post-id-34670