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

Linear optimization by Two-Phase Simplex algorithm.

Pascal
function SimplexTwoPhase(const A: TMtx; const b: TVec; const c: TVec; const relations: String; const AFinal: TMtx; const X: TVec; const Indexes: TVecInt; out SolutionType: TLPSolution; Minimize: boolean = true; const Verbose: TStrings = nil): double;

Solves the following optimization problem: 

 

where rel holds the relation signs. For example, relation string ' < = > ' means the constraints system consists of one inequality ' <= ', one equality ' = ' and one more inequality ' >= '

Optionally, you can also assign TOptControl object to the Verbose parameter. This allows the optimization procedure to be interrupted from another thread and optionally also allows logging and iteration count monitoring.

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); }
Examples on GitHub
Copyright (c) 1999-2024 by Dew Research. All rights reserved.
What do you think about this topic? Send feedback!