Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

All published worksheets from http://sagenb.org

Views: 168731
Image: ubuntu2004
%maxima load("simplex") minimize_lp(21*x1+19*x2+22*x3, [x1+0.9*x2+1.2*x3<=56,x1+x2+x3>=60]), nonegative_lp=true;
"/sagenb/sage_install/sage-4.8-sage.math.washington.edu-x86_64-Linux/local/share/maxima/5.23.2/share/contrib/simplex/simplex.mac" [1140.0,[x3=0,x2=60.0,x1=0]]
c=vector([21,19,22]) G=matrix([[1,0.9,1.2], [-1,-1,-1],[-1,0,0],[0,-1,0],[0,0,-1]]) h=vector([56,-60,0,0,0]) sol=linear_program(c,G,h) print sol['primal objective'] print sol['x']
1140.00000103 (7.37318396282e-07, 59.9999992338, 4.86619292156e-09)
c=vector([21,19,22]) G=matrix([[1,0.9,1.2], [-1,-1,-1],[-1,0,0],[0,-1,0],[0,0,-1]]) h=vector([56,-60,0,0,0]) sol=linear_program(c,G,h,solver='glpk') print sol['primal objective'] print sol['x']
GLPK Simplex Optimizer, v4.44 5 rows, 3 columns, 9 non-zeros Preprocessing... 2 rows, 3 columns, 6 non-zeros Scaling... A: min|aij| = 9.000e-01 max|aij| = 1.200e+00 ratio = 1.333e+00 Problem data seem to be well scaled Constructing initial basis... Size of triangular part = 2 0: obj = 0.000000000e+00 infeas = 6.000e+01 (0) * 2: obj = 1.180000000e+03 infeas = 0.000e+00 (0) * 3: obj = 1.140000000e+03 infeas = 0.000e+00 (0) OPTIMAL SOLUTION FOUND 1140.0 (-0.0, 60.0, -0.0)
%maxima load("simplex") maximize_lp(100*x1+100*x2+100*x3, [20*x1+50*x2+10*x3<=5000, 20*x1+0*x2+40*x3<=4000, 20*x1+10*x2+10*x3<=4000]), nonegative_lp=true;
"/sagenb/sage_install/sage-4.8-sage.math.washington.edu-x86_64-Linux/local/share/maxima/5.23.2/share/contrib/simplex/simplex.mac" [65000/3,[x3=25/3,x2=25,x1=550/3]]
c=vector([-100,-100,-100]) G=matrix([[20,50,10], [20,0,40],[20,10,10],[-1,0,0],[0,-1,0],[0,0,-1]]) h=vector([5000,4000,4000,0,0,0]) sol=linear_program(c,G,h) print sol['primal objective'] print sol['x']
-21666.6666635 (183.333333184, 25.0000000435, 8.33333340722)