solver
ConicProblem.hpp
Go to the documentation of this file.
1 
9 #pragma once
10 
14 
15 namespace solver {
16 
17  class Model;
18  class NcvxBnBSolver;
19 
27  {
28  public:
29  ConicProblem() { this->clean(); }
30  ~ConicProblem(){}
31 
32  void clean();
33  SolverSetting& getSetting() { return stgs_; }
34  const SolverSetting& getSetting() const { return stgs_; }
35  Var addVar(const VarType& type, double lb, double ub, double guess=0.0);
36  void addLinConstr(const LinExpr& lhs, const std::string sense, const LinExpr& rhs);
37  void addSocConstr(const DCPQuadExpr& qexpr, const std::string sense, const LinExpr& lexpr);
38  void addQuaConstr(const DCPQuadExpr& qexpr, const std::string sense, const LinExpr& expr, const QuadConstrApprox& qapprox = QuadConstrApprox::None );
39  void configSetting(const std::string cfg_file, const std::string stg_vars_yaml = "solver_variables");
40  void setObjective(const DCPQuadExpr& qexpr, const LinExpr& expr);
41  ExitCode optimize();
42 
43  const int numTrustRegions() const { return numTrustRegions_; }
44  const int numBinaryVariables() const { return bin_vars_.size(); }
45  const int numSoftConstraints() const { return numSoftConstraints_; }
46 
47  private:
48  friend class Model;
49  friend class NcvxBnBSolver;
50 
51  inline Cone& getCone() { return cone_; }
52  inline SolverStorage& getStorage() { return stg_; }
53  InteriorPointSolver& getSolver() { return ip_solver_; }
54 
55  ExitCode solveProblem();
56  void buildProblem(int iter_id, bool warm_start = false);
57 
58  // getter and setter methods
59  Eigen::VectorXd& binaryLowerBounds() { return bin_vars_lower_bound_; }
60  Eigen::VectorXd& binaryUpperBounds() { return bin_vars_upper_bound_; }
61  std::vector<std::shared_ptr<Var>>& problemVariables() { return vars_; }
62  std::vector<std::shared_ptr<Var>>& problemBinaryVariables() { return bin_vars_; }
63 
64  const Eigen::VectorXd& binaryLowerBounds() const { return bin_vars_lower_bound_; }
65  const Eigen::VectorXd& binaryUpperBounds() const { return bin_vars_upper_bound_; }
66  const std::vector<std::shared_ptr<Var>>& problemVariables() const { return vars_; }
67  const std::vector<std::shared_ptr<Var>>& problemBinaryVariables() const { return bin_vars_; }
68 
69  private:
70  Cone cone_;
71  SolverStorage stg_;
72  ExitCode exit_code_;
73  SolverSetting stgs_;
74  BnBSolver bnb_solver_;
75  InteriorPointSolver ip_solver_;
76 
77  DCPQuadExpr objective_;
78  int numTrustRegions_, numSoftConstraints_;
79  std::vector<LinExpr> leqcons_, lineqcons_;
80  std::vector<DCPQuadExpr> qineqcons_, soccons_;
81  std::vector<std::shared_ptr<Var> > vars_, bin_vars_;
82  Eigen::VectorXd bin_vars_lower_bound_, bin_vars_upper_bound_;
83  };
84 }
Definition: Model.hpp:16
Class that provides storage space for the optimization matrices, vectors and variables.
Definition: Cone.hpp:380
Helper class to ease the construction of a quadratic expression (e.g.
Definition: Exprs.hpp:100
Main class to construct a second-order cone optimization problem.
Definition: ConicProblem.hpp:26
Main class that implements an Interior Point Solver for Second-Order Cones.
Definition: IPSolver.hpp:31
Class that provides access to all environment variables required by the solver.
Definition: SolverSetting.hpp:43
ECOS - Embedded Conic Solver.
Definition: Cone.hpp:20
This class contains all information about the conic optimization problem, and provides functionality ...
Definition: Cone.hpp:87
Definition: NcvxBnBSolver.hpp:18
ECOS - Embedded Conic Solver.
Definition: BnBSolver.hpp:28
Helper class to define an optimization variable, used in the construction of linear and quadratic exp...
Definition: Var.hpp:36
Helper class to ease the construction of a linear expression (e.g.
Definition: Exprs.hpp:19