Visual Servoing Platform
version 3.6.1 under development (2024-12-17)
|
#include <visp3/core/vpLinProg.h>
Public Types | |
typedef std::pair< unsigned int, double > | BoundedIndex |
Static Public Member Functions | |
Solvers <br> | |
static bool | simplex (const vpColVector &c, vpMatrix A, vpColVector b, vpColVector &x, const double &tol=1e-6) |
static bool | solveLP (const vpColVector &c, vpMatrix A, vpColVector b, const vpMatrix &C, const vpColVector &d, vpColVector &x, std::vector< BoundedIndex > l={}, std::vector< BoundedIndex > u={}, const double &tol=1e-6) |
Dimension reduction for equality constraints <br> | |
static bool | colReduction (vpMatrix &A, vpColVector &b, bool full_rank=false, const double &tol=1e-6) |
static bool | rowReduction (vpMatrix &A, vpColVector &b, const double &tol=1e-6) |
Vector and equality checking <br> | |
static bool | allZero (const vpColVector &x, const double &tol=1e-6) |
static bool | allClose (const vpMatrix &A, const vpColVector &x, const vpColVector &b, const double &tol=1e-6) |
static bool | allLesser (const vpMatrix &C, const vpColVector &x, const vpColVector &d, const double &thr=1e-6) |
static bool | allLesser (const vpColVector &x, const double &thr=1e-6) |
static bool | allGreater (const vpColVector &x, const double &thr=1e-6) |
This class provides two solvers for Linear Programs.
One is a classical simplex, the other can deal with various inequality or bound constraints.
Utility functions to reduce or check linear equalities or inequalities are also available.
Definition at line 62 of file vpLinProg.h.
typedef std::pair<unsigned int, double> vpLinProg::BoundedIndex |
Used to pass a list of bounded variables to solveLP(), as a list of (index, bound).
The type is compatible with C++11's braced initialization. Construction can be done in the call to solveLP or before, as shown in this example:
Here the lower bound is built explicitly while the upper one is built during the call to solveLP():
Definition at line 119 of file vpLinProg.h.
|
inlinestatic |
Check if is near .
A | : matrix (dimension m x n) |
x | : vector (dimension n) |
b | : vector (dimension m) |
tol | : tolerance |
Definition at line 168 of file vpLinProg.h.
References vpMatrix::getRow(), and vpArray2D< Type >::getRows().
Referenced by colReduction(), rowReduction(), simplex(), and solveLP().
|
inlinestatic |
Check if all elements of are greater or equal to threshold.
x | : vector (dimension n) |
thr | : threshold |
Definition at line 220 of file vpLinProg.h.
References vpArray2D< Type >::getRows().
Referenced by simplex(), and vpQuadProg::solveQPi().
|
inlinestatic |
Check if all elements of are lesser or equal to threshold.
x | : vector (dimension n) |
thr | : threshold |
Definition at line 203 of file vpLinProg.h.
References vpArray2D< Type >::getRows().
|
inlinestatic |
Check if all elements of are lesser or equal to threshold.
C | : matrix (dimension m x n) |
x | : vector (dimension n) |
d | : vector (dimension m) |
thr | : threshold |
Definition at line 186 of file vpLinProg.h.
References vpMatrix::getRow().
Referenced by simplex(), solveLP(), vpQuadProg::solveQP(), and vpQuadProg::solveQPi().
|
inlinestatic |
Check if all elements of are near zero.
x | : vector to be checked |
tol | : tolerance |
Definition at line 149 of file vpLinProg.h.
References vpArray2D< Type >::getRows().
Referenced by colReduction(), and vpQuadProg::solveQPi().
|
static |
Reduces the search space induced by an equality constraint.
Changes A and b so that the constraint can be written
This method is destructive for A and b.
A | : in = equality matrix (dimension m x n), out = projector to kernel (dimension n x (n-rank(A))) |
b | : in = equality vector (dimension m), out = particular solution (dimension n) |
full_rank | : if we think A is full rank, leads to a faster result but a slower one if A is actually not full rank. |
tol | : tolerance to test the ranks |
Here is an example with and that become and .
We indeed have
Definition at line 97 of file vpLinProg.cpp.
References allClose(), allZero(), vpMatrix::extract(), vpColVector::extract(), vpMatrix::eye(), vpMatrix::getCol(), vpArray2D< Type >::getCols(), vpArray2D< Type >::getRows(), vpColVector::infinityNorm(), vpMatrix::infinityNorm(), vpMatrix::inverseTriangular(), vpMatrix::juxtaposeMatrices(), vpMatrix::qr(), vpMatrix::qrPivot(), vpColVector::resize(), vpArray2D< Type >::resize(), vpMatrix::t(), and vpMatrix::transpose().
Referenced by vpQuadProg::setEqualityConstraint(), vpQuadProg::solveByProjection(), solveLP(), and vpQuadProg::solveQP().
|
static |
Reduces the number of equality constraints.
Changes A and b so that the constraint is written with minimal rows.
This method is destructive for A and b.
A | : equality matrix (dimension in = (m x n), out = (rank(A) x n) |
b | : equality vector (dimension in = (m), out = (rank(A))) |
tol | : tolerance to test the ranks |
Here is an example with and (feasible) or (not feasible).
Definition at line 252 of file vpLinProg.cpp.
References allClose(), vpMatrix::extract(), vpArray2D< Type >::getCols(), vpArray2D< Type >::getRows(), vpColVector::infinityNorm(), vpMatrix::infinityNorm(), vpMatrix::inverseTriangular(), vpMatrix::qrPivot(), vpColVector::resize(), vpArray2D< Type >::resize(), vpMatrix::stack(), and vpMatrix::transpose().
Referenced by simplex().
|
static |
Solves a Linear Program under simplex canonical form
c | : cost vector (dimension n) |
A | : equality matrix (dimension m x n) |
b | : equality vector (dimension m) |
x | : in: feasible point if any, out: solution (dimension n) |
tol | : tolerance to test the ranks |
Here is an example:
That can be re-written as:
Definition at line 553 of file vpLinProg.cpp.
References allClose(), allGreater(), allLesser(), vpColVector::extract(), vpMatrix::getCol(), vpArray2D< Type >::getRows(), vpMatrix::inverseByQR(), vpColVector::resize(), rowReduction(), vpColVector::t(), and vpMatrix::t().
Referenced by solveLP(), and vpQuadProg::solveQPi().
|
static |
Solves a Linear Program under various constraints
c | : cost vector (dimension n) |
A | : equality matrix (dimension m x n) |
b | : equality vector (dimension m) |
C | : inequality matrix (dimension p x n) |
d | : inequality vector (dimension p) |
x | : in: feasible point if any, out: solution (dimension n) |
l | : lower bounds (if any) |
u | : upper bounds (if any) |
tol | : tolerance to test the ranks |
Lower and upper bounds may be passed as a list of (index, bound) with C++11's braced initialization.
Here is an example:
Definition at line 349 of file vpLinProg.cpp.
References allClose(), allLesser(), colReduction(), vpColVector::extract(), vpMatrix::eye(), vpArray2D< Type >::getCols(), vpMatrix::getRow(), vpArray2D< Type >::getRows(), vpColVector::resize(), vpArray2D< Type >::resize(), simplex(), and vpMatrix::transpose().