solveLP
import { solveLP } from '@banou/opencv-wasm'Use after await initOpenCV(). See the initialization and named imports guide.
Solve given (non-integer) linear programming problem using the Simplex Algorithm (Simplex Method).
What we mean here by "linear programming problem" (or LP problem, for short) can be formulated as:
\mbox{Maximize } c\cdot x\\
\mbox{Subject to:}\\
Ax\leq b\\
x\geq 0
Where c is fixed 1-by-n row-vector, A is fixed m-by-n matrix, b is fixed m-by-1
column vector and x is an arbitrary n-by-1 column vector, which satisfies the constraints.
Simplex algorithm is one of many algorithms that are designed to handle this sort of problems efficiently. Although it is not optimal in theoretical sense (there exist algorithms that can solve any problem written as above in polynomial time, while simplex method degenerates to exponential time for some special cases), it is well-studied, easy to implement and is shown to work well for real-life purposes.
The particular implementation is taken almost verbatim from Introduction to Algorithms, third edition by T. H. Cormen, C. E. Leiserson, R. L. Rivest and Clifford Stein. In particular, the Bland's rule http://en.wikipedia.org/wiki/Bland%27s_rule is used to prevent cycling.
solveLP(Func: Mat, Constr: Mat, z: Mat, constr_eps: number): number;FuncThis row-vector corresponds to
cin the LP problem formulation (see above). It should contain 32- or 64-bit floating point numbers. As a convenience, column-vector may be also submitted, in the latter case it is understood to correspond toc^T.Constrm-by-n+1matrix, whose rightmost column corresponds tobin formulation above and the remaining toA. It should contain 32- or 64-bit floating point numbers.zOutput destination, filled by the native operation. The solution will be returned here as a column-vector - it corresponds to
cin the formulation above. It will contain 64-bit floating point numbers.constr_epsallowed numeric disparity for constraints
One of cv::SolveLPResult
These signatures describe this package. Upstream documentation can mention optional backends that are absent from this build. Check runtime compatibility before choosing a backend or file format.