|
TVM
0.9.4
|
#include <tvm/solver/abstract/LeastSquareSolver.h>

Classes | |
| struct | ImpactFromChanges |
| struct | MarkedAssignment |
Public Types | |
| template<typename K , typename T > | |
| using | map = utils::internal::map< K, T > |
| using | AssignmentVector = std::vector< std::unique_ptr< MarkedAssignment > > |
| using | AssignmentPtrVector = std::vector< MarkedAssignment * > |
| using | MapToAssignment = map< constraint::abstract::LinearConstraint *, AssignmentPtrVector > |
Public Member Functions | |
| LeastSquareSolver (bool verbose=false) | |
| LeastSquareSolver (const LeastSquareSolver &)=delete | |
| LeastSquareSolver & | operator= (const LeastSquareSolver &)=delete |
| virtual | ~LeastSquareSolver ()=default |
| void | startBuild (const VariableVector &x, int nObj, int nEq, int nIneq, bool useBounds=true, const hint::internal::Substitutions *const subs=nullptr) |
| void | finalizeBuild () |
| void | addBound (LinearConstraintPtr bound) |
| void | addConstraint (LinearConstraintPtr cstr) |
| void | addObjective (LinearConstraintPtr obj, SolvingRequirementsPtr req, double additionalWeight=1) |
| void | setMinimumNorm () |
| bool | solve () |
| const Eigen::VectorXd & | result () const |
| int | constraintSize (const constraint::abstract::LinearConstraint &c) const |
| void | process (const internal::SolverEvents &se) |
Protected Attributes | |
| int | nEq_ |
| int | nIneq_ |
| int | nObj_ |
| int | objSize_ |
| int | eqSize_ |
| int | ineqSize_ |
Base class for a (constrained) least-square solver.
The problem to be solved has the general form min. ||Ax-b||^2 s.t. C_e x = d l <= C_i x <= u xl <= x <= xu
where l or u might be set to -inf or +inf, and the explicit bounds are optional.
When deriving this class, also remember to derive the factory class LSSolverFactory as well.
| using tvm::solver::abstract::LeastSquareSolver::AssignmentPtrVector = std::vector<MarkedAssignment *> |
| using tvm::solver::abstract::LeastSquareSolver::AssignmentVector = std::vector<std::unique_ptr<MarkedAssignment> > |
| using tvm::solver::abstract::LeastSquareSolver::map = utils::internal::map<K, T> |
| using tvm::solver::abstract::LeastSquareSolver::MapToAssignment = map<constraint::abstract::LinearConstraint *, AssignmentPtrVector> |
| tvm::solver::abstract::LeastSquareSolver::LeastSquareSolver | ( | bool | verbose = false | ) |
|
delete |
|
virtualdefault |
|
inlineprotected |
| void tvm::solver::abstract::LeastSquareSolver::addBound | ( | LinearConstraintPtr | bound | ) |
Add a bound constraint to the solver. If multiple bounds appears on the same variable, their intersection is taken.
|
protectedpure virtual |
| void tvm::solver::abstract::LeastSquareSolver::addConstraint | ( | LinearConstraintPtr | cstr | ) |
Add a constraint to the solver.
|
protectedpure virtual |
|
protectedpure virtual |
| void tvm::solver::abstract::LeastSquareSolver::addObjective | ( | LinearConstraintPtr | obj, |
| SolvingRequirementsPtr | req, | ||
| double | additionalWeight = 1 |
||
| ) |
Add an objective to the solver with given requirements
| obj | The linear expression added in least-square form |
| req | The solving requirements. Only the weight-related requirements will be taken into account |
| additionalWeight | An additional factor that will multiply the other weights. |
|
protectedpure virtual |
|
protectedvirtual |
If for a derived class, the change on a category implies the change on others, impact is changed accordingly.
Reimplemented in tvm::solver::QuadprogLeastSquareSolver, tvm::solver::QLDLeastSquareSolver, tvm::solver::LSSOLLeastSquareSolver, and tvm::solver::LexLSLeastSquareSolver.
| int tvm::solver::abstract::LeastSquareSolver::constraintSize | ( | const constraint::abstract::LinearConstraint & | c | ) | const |
Return the constraint size for the solver. This can be different from the actual constraint size if the constraint is a double-sided inequality but the solver only accept simple sided constraints
| void tvm::solver::abstract::LeastSquareSolver::finalizeBuild | ( | ) |
Finalize the build.
|
protectedpure virtual |
|
protectedpure virtual |
|
protectedpure virtual |
|
protectedpure virtual |
|
protectedpure virtual |
|
delete |
|
inlineprotectedvirtual |
|
inlineprotectedvirtual |
|
protectedpure virtual |
|
protectedpure virtual |
| void tvm::solver::abstract::LeastSquareSolver::process | ( | const internal::SolverEvents & | se | ) |
Update the data according to the events
|
protectedpure virtual |
Remove the bounds on variable at given range from the data passed to the solver (e.g. set the bounds to -/+Inf).
Implemented in tvm::solver::QuadprogLeastSquareSolver, tvm::solver::LSSOLLeastSquareSolver, tvm::solver::LexLSLeastSquareSolver, and tvm::solver::QLDLeastSquareSolver.
|
protectedpure virtual |
|
protectedpure virtual |
| const Eigen::VectorXd& tvm::solver::abstract::LeastSquareSolver::result | ( | ) | const |
Get the result of the previous call to solve()
|
protectedpure virtual |
| void tvm::solver::abstract::LeastSquareSolver::setMinimumNorm | ( | ) |
Set ||x||^2 as the least square objective of the problem.
|
protectedpure virtual |
| bool tvm::solver::abstract::LeastSquareSolver::solve | ( | ) |
Solve the problem
|
protectedpure virtual |
| void tvm::solver::abstract::LeastSquareSolver::startBuild | ( | const VariableVector & | x, |
| int | nObj, | ||
| int | nEq, | ||
| int | nIneq, | ||
| bool | useBounds = true, |
||
| const hint::internal::Substitutions *const | subs = nullptr |
||
| ) |
Open a build sequence for a problem on the current variables (set through the inherited ProblemComputationData::addVariable) with the specified dimensions, allocating the memory needed.
| x | The variables of the problem. The object need to be valid until ::finalizeBuild is called. |
| nObj | Row size of A. |
| nEq | Row size of C_e. |
| nIneq | Row size of C_i. |
| useBounds | Presence of explicit bounds in the problem. |
| subs | Possible substitutions used for solving. |
Once a build is started, objective, constraints and bounds can be added through ::addObjective, ::addConstraint and ::addBound, until ::finalizeBuild is called.
|
inlineprotected |
|
protectedpure virtual |
|
protectedpure virtual |
|
protectedpure virtual |
|
protectedpure virtual |
|
inlineprotected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |