TVM  0.9.4
LexLSLeastSquareSolver.h
Go to the documentation of this file.
1 /* Copyright 2021-2022 CNRS-AIST JRL and CNRS-UM LIRMM */
2 
3 #pragma once
4 
7 
8 #include <lexls/lexlsi.h>
9 
10 namespace tvm::solver
11 {
12 class LexLSLSSolverFactory;
13 
16 {
17  TVM_ADD_NON_DEFAULT_OPTION(big_number, constant::big_number)
18  TVM_ADD_NON_DEFAULT_OPTION(verbose, false)
19  TVM_ADD_NON_DEFAULT_OPTION(warmStart, false)
20 
21 public:
23 };
24 
27 {
28 public:
30 
31 protected:
32  void initializeBuild_(int nObj, int nEq, int nIneq, bool useBounds) override;
33  ImpactFromChanges resize_(int nObj, int nEq, int nIneq, bool useBounds) override;
34  void addBound_(LinearConstraintPtr bound, RangePtr range, bool first) override;
37  void addObjective_(LinearConstraintPtr cstr, SolvingRequirementsPtr req, double additionalWeight) override;
38  void setMinimumNorm_() override;
39  void resetBounds_() override;
40  void preAssignmentProcess_() override;
41  void postAssignmentProcess_() override;
42  bool solve_() override;
43  const Eigen::VectorXd & result_() const override;
44  bool handleDoubleSidedConstraint_() const override { return true; }
48 
49  void removeBounds_(const Range & range) override;
54 
56 
57  void printProblemData_() const override;
58  void printDiagnostic_() const override;
59 
60 private:
61  using MatrixXdCol = decltype(Eigen::MatrixXd().col(0));
62  using MatrixXdBlock = decltype(Eigen::MatrixXd().leftCols(0));
63 
64  Eigen::MatrixXd data0_;
65  Eigen::MatrixXd data1_;
66  Eigen::MatrixXd data2_;
67 
68  MatrixXdCol xl_;
69  MatrixXdCol xu_;
70  MatrixXdBlock A1_;
71  MatrixXdCol l1_;
72  MatrixXdCol u1_;
73  MatrixXdBlock A2_;
74  MatrixXdCol l2_;
75  MatrixXdCol u2_;
76 
77  std::vector<LexLS::Index> varIndex_;
78 
79  bool warmStart_;
80  Eigen::VectorXd x0_;
81  std::vector<LexLS::ConstraintActivationType> act0_;
82  std::vector<LexLS::ConstraintActivationType> act1_;
83 
84  LexLS::internal::LexLSI solver_;
85 
86  bool autoMinNorm_;
87  double big_number_;
88 };
89 
94 {
95 public:
98 
99  std::unique_ptr<abstract::LSSolverFactory> clone() const override;
100  std::unique_ptr<abstract::LeastSquareSolver> createSolver() const override;
101 
102 private:
103  LexLSLSSolverOptions options_;
104 };
105 
106 } // namespace tvm::solver
#define TVM_ADD_NON_DEFAULT_OPTION(optionName, defaultValue)
Definition: Option.h:30
#define TVM_DLLAPI
Definition: api.h:35
Definition: Range.h:19
Definition: LinearConstraint.h:56
Definition: AssignmentTarget.h:37
Definition: LexLSLeastSquareSolver.h:94
std::unique_ptr< abstract::LeastSquareSolver > createSolver() const override
std::unique_ptr< abstract::LSSolverFactory > clone() const override
LexLSLSSolverFactory(const LexLSLSSolverOptions &options={})
Definition: LexLSLeastSquareSolver.h:16
Definition: LexLSLeastSquareSolver.h:27
void initializeBuild_(int nObj, int nEq, int nIneq, bool useBounds) override
bool handleDoubleSidedConstraint_() const override
Definition: LexLSLeastSquareSolver.h:44
void updateBoundTargetData(scheme::internal::AssignmentTarget &target) override
void removeBounds_(const Range &range) override
void printDiagnostic_() const override
LexLSLeastSquareSolver(const LexLSLSSolverOptions &options={})
void updateEqualityTargetData(scheme::internal::AssignmentTarget &target) override
void applyImpactLogic(ImpactFromChanges &impact)
void addObjective_(LinearConstraintPtr cstr, SolvingRequirementsPtr req, double additionalWeight) override
Range nextObjectiveRange_(const constraint::abstract::LinearConstraint &cstr) const override
Range nextEqualityConstraintRange_(const constraint::abstract::LinearConstraint &cstr) const override
void updateObjectiveTargetData(scheme::internal::AssignmentTarget &target) override
void addIneqalityConstraint_(LinearConstraintPtr cstr) override
void printProblemData_() const override
const Eigen::VectorXd & result_() const override
void updateInequalityTargetData(scheme::internal::AssignmentTarget &target) override
Range nextInequalityConstraintRange_(const constraint::abstract::LinearConstraint &cstr) const override
void addEqualityConstraint_(LinearConstraintPtr cstr) override
ImpactFromChanges resize_(int nObj, int nEq, int nIneq, bool useBounds) override
void addBound_(LinearConstraintPtr bound, RangePtr range, bool first) override
Definition: LexLSSolverOptions.h:18
Definition: LeastSquareSolver.h:220
Definition: LeastSquareSolver.h:37
Definition: HierarchicalLeastSquareSolver.h:18
std::shared_ptr< constraint::abstract::LinearConstraint > LinearConstraintPtr
Definition: defs.h:59
std::shared_ptr< Range > RangePtr
Definition: defs.h:61
std::shared_ptr< requirements::SolvingRequirementsWithCallbacks > SolvingRequirementsPtr
Definition: defs.h:63