| ring r = (real,10),(x),lp;
// consider the max. problem:
//
// maximize x(1) + x(2) + 3*x(3) - 0.5*x(4)
//
// with constraints: x(1) + 2*x(3) <= 740
// 2*x(2) - 7*x(4) <= 0
// x(2) - x(3) + 2*x(4) >= 0.5
// x(1) + x(2) + x(3) + x(4) = 9
//
matrix sm[5][5]=( 0, 1, 1, 3,-0.5,
740,-1, 0,-2, 0,
0, 0,-2, 0, 7,
0.5, 0,-1, 1,-2,
9,-1,-1,-1,-1);
int n = 4; // number of constraints
int m = 4; // number of variables
int m1= 2; // number of <= constraints
int m2= 1; // number of >= constraints
int m3= 1; // number of == constraints
simplex(sm, n, m, m1, m2, m3);
→ [1]:
→ _[1,1]=17.025
→ _[1,2]=-0.95
→ _[1,3]=-0.05
→ _[1,4]=1.95
→ _[1,5]=-1.05
→ _[2,1]=730.55
→ _[2,2]=0.1
→ _[2,3]=-0.1
→ _[2,4]=-1.1
→ _[2,5]=0.9
→ _[3,1]=3.325
→ _[3,2]=-0.35
→ _[3,3]=-0.15
→ _[3,4]=0.35
→ _[3,5]=0.35
→ _[4,1]=0.95
→ _[4,2]=-0.1
→ _[4,3]=0.1
→ _[4,4]=0.1
→ _[4,5]=0.1
→ _[5,1]=4.725
→ _[5,2]=-0.55
→ _[5,3]=0.05
→ _[5,4]=0.55
→ _[5,5]=-0.45
→ [2]:
→ 0
→ [3]:
→ 5,2,4,3
→ [4]:
→ 1,6,8,7
→ [5]:
→ 4
→ [6]:
→ 4
|