You are here: Symbol Reference > Optimization Namespace > Functions > Optimization.SimplexTwoPhase Function
MtxVec VCL
ContentsIndex
Example

Solve the following LP problem: 

f(x) = x1+x2+2*x3-2*x4 

subject to: 

x1+2x <= 700 

2x2-8x4 <= 0 

x2-2x3+x4 > 1 

x1+x2+x3+x4 = 1 

which translates to using two-phase simplex method:

Uses MtxExpr, Optimization, Math387; procedure Example; var A, AF: Matrix; b,c,indexes,x: Vector; sol: TLPSolution; f: double: begin A.SetIt(4,4,false,[1,1,0,0 0,2,0,-8, 0,1,-2,1, 1,1,1,1]); b.SetIt(false,[700,0,1,1]); c.SetIt(false,[1,1,2,-2]); f := SimplexTwoPhase(A,b,c,'<<>=',AF,x,indexes,sol,true,nil); end;
#include "MtxExpr.hpp" #include "Math387.hpp" #include "Optimization.hpp" void __fastcall Example; { sMatrix A,Af; sVector b,c,x,indexes; TLPSolution sol; A.SetIt(4,3,false, OPENARRAY(double,(1,1,0,0 0,2,0,-8, 0,1,-2,1, 1,1,1,1))); b.SetIt(OPENARRAY(double,(700,0,1,1))); c.SetIt(OPENARRAY(double,(1,1,2,-2))); // Find minimum using above system double f = SimplexTwoPhase(A,b,c,"<<>=",Af,x,indexes,sol,true,NULL); }
Copyright (c) 1999-2025 by Dew Research. All rights reserved.