ROL
ROL_NewConstraintManager.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Rapid Optimization Library (ROL) Package
4 //
5 // Copyright 2014 NTESS and the ROL contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef ROL_NEW_CONSTRAINT_MANAGER_H
11 #define ROL_NEW_CONSTRAINT_MANAGER_H
12 
15 #include <unordered_map>
16 
24 namespace ROL {
25 
26 template<typename Real>
27 struct ConstraintData {
28  const Ptr<Constraint<Real>> constraint;
29  const Ptr<Vector<Real>> multiplier;
30  const Ptr<Vector<Real>> residual;
31  const Ptr<BoundConstraint<Real>> bounds;
32 
34  const Ptr<Vector<Real>> &mul,
35  const Ptr<Vector<Real>> &res=nullPtr,
36  const Ptr<BoundConstraint<Real>> &bnd=nullPtr)
37  : constraint(con), multiplier(mul),
38  residual(res==nullPtr ? mul->dual().clone() : res), bounds(bnd) {}
39 };
40 
41 template<typename Real>
43 private:
44  Ptr<Constraint<Real>> con_;
45  Ptr<Vector<Real>> mul_;
46  Ptr<Vector<Real>> res_;
47  Ptr<Constraint<Real>> linear_con_;
48  Ptr<Vector<Real>> linear_mul_;
49  Ptr<Vector<Real>> linear_res_;
50  Ptr<Vector<Real>> xprim_;
51  Ptr<Vector<Real>> xdual_;
52  Ptr<BoundConstraint<Real>> bnd_;
53 
54  std::vector<Ptr<Constraint<Real>>> cvec_; // General constraints
55  std::vector<Ptr<Vector<Real>>> lvec_; // General multiplier vector
56  std::vector<Ptr<Vector<Real>>> rvec_; // General residual vector
57  std::vector<Ptr<Constraint<Real>>> lcvec_; // Linear constraints
58  std::vector<Ptr<Vector<Real>>> llvec_; // Linear multiplier vector
59  std::vector<Ptr<Vector<Real>>> lrvec_; // Linear residual vector
60  std::vector<Ptr<Vector<Real>>> psvec_; // Primal slack vector
61  std::vector<Ptr<Vector<Real>>> dsvec_; // Dual slack vector
62  std::vector<Ptr<BoundConstraint<Real>>> sbnd_; // Slack bound constraint
63 
64  std::vector<bool> isInequality_, isLinearInequality_;
65 
66  bool isNull_;
68 
69  void initializeSlackVariable(const Ptr<Constraint<Real>> &con,
70  const Ptr<BoundConstraint<Real>> &cbnd,
71  const Ptr<Vector<Real>> &s,
72  const Ptr<Vector<Real>> &x) const;
73 
74  void initialize(const std::unordered_map<std::string,ConstraintData<Real>> &input_con,
75  const Ptr<Vector<Real>> &xprim,
76  const Ptr<Vector<Real>> &xdual,
77  const Ptr<BoundConstraint<Real>> &bnd);
78 
79  void initialize(const std::unordered_map<std::string,ConstraintData<Real>> &input_con,
80  const std::unordered_map<std::string,ConstraintData<Real>> &input_lcon,
81  const Ptr<Vector<Real>> &xprim,
82  const Ptr<Vector<Real>> &xdual,
83  const Ptr<BoundConstraint<Real>> &bnd);
84 
85 public:
86  virtual ~NewConstraintManager(void) {}
87 
88  NewConstraintManager(const std::unordered_map<std::string,ConstraintData<Real>> &con,
89  const Ptr<Vector<Real>> &xprim,
90  const Ptr<Vector<Real>> &xdual,
91  const Ptr<BoundConstraint<Real>> &bnd = nullPtr);
92 
93  NewConstraintManager(const std::unordered_map<std::string,ConstraintData<Real>> &con,
94  const std::unordered_map<std::string,ConstraintData<Real>> &linear_con,
95  const Ptr<Vector<Real>> &xprim,
96  const Ptr<Vector<Real>> &xdual,
97  const Ptr<BoundConstraint<Real>> &bnd = nullPtr);
98 
99  const Ptr<Constraint<Real>> getConstraint(void) const;
100  const Ptr<Vector<Real>> getMultiplier(void) const;
101  const Ptr<Vector<Real>> getResidual(void) const;
102  const Ptr<Constraint<Real>> getLinearConstraint(void) const;
103  const Ptr<Vector<Real>> getLinearMultiplier(void) const;
104  const Ptr<Vector<Real>> getLinearResidual(void) const;
105  const Ptr<Vector<Real>> getOptVector(void) const;
106  const Ptr<Vector<Real>> getDualOptVector(void) const;
107  const Ptr<BoundConstraint<Real>> getBoundConstraint(void) const;
108 
109  bool isNull(void) const;
110  bool hasInequality(void) const;
111 
112  void resetSlackVariables(void);
113 
114 }; // class NewConstraintManager
115 
116 } // namespace ROL
117 
119 
120 #endif
Ptr< Vector< Real > > multiplier
std::vector< Ptr< Vector< Real > > > rvec_
std::vector< Ptr< Vector< Real > > > llvec_
const Ptr< BoundConstraint< Real > > bounds
Ptr< Constraint< Real > > linear_con_
std::vector< Ptr< Vector< Real > > > lvec_
const Ptr< Constraint< Real > > getLinearConstraint(void) const
Ptr< BoundConstraint< Real > > bnd_
const Ptr< Vector< Real > > multiplier
NewConstraintManager(const std::unordered_map< std::string, ConstraintData< Real >> &con, const Ptr< Vector< Real >> &xprim, const Ptr< Vector< Real >> &xdual, const Ptr< BoundConstraint< Real >> &bnd=nullPtr)
std::vector< Ptr< BoundConstraint< Real > > > sbnd_
Defines the linear algebra or vector space interface.
Definition: ROL_Vector.hpp:46
ConstraintData(const Ptr< Constraint< Real >> &con, const Ptr< Vector< Real >> &mul, const Ptr< Vector< Real >> &res=nullPtr, const Ptr< BoundConstraint< Real >> &bnd=nullPtr)
void initializeSlackVariable(const Ptr< Constraint< Real >> &con, const Ptr< BoundConstraint< Real >> &cbnd, const Ptr< Vector< Real >> &s, const Ptr< Vector< Real >> &x) const
Provides a wrapper for multiple constraints.
const Ptr< Vector< Real > > getMultiplier(void) const
const Ptr< Vector< Real > > getOptVector(void) const
const Ptr< Vector< Real > > residual
const Ptr< Vector< Real > > getLinearMultiplier(void) const
Ptr< Constraint< Real > > con_
std::vector< Ptr< Vector< Real > > > psvec_
Ptr< BoundConstraint< Real > > bounds
void initialize(const std::unordered_map< std::string, ConstraintData< Real >> &input_con, const Ptr< Vector< Real >> &xprim, const Ptr< Vector< Real >> &xdual, const Ptr< BoundConstraint< Real >> &bnd)
const Ptr< Vector< Real > > getDualOptVector(void) const
Ptr< Vector< Real > > residual
std::vector< Ptr< Constraint< Real > > > lcvec_
const Ptr< Vector< Real > > getResidual(void) const
Provides the interface to apply upper and lower bound constraints.
const Ptr< Vector< Real > > getLinearResidual(void) const
const Ptr< Constraint< Real > > getConstraint(void) const
Ptr< Constraint< Real > > constraint
const Ptr< BoundConstraint< Real > > getBoundConstraint(void) const
std::vector< Ptr< Constraint< Real > > > cvec_
Defines the general constraint operator interface.
std::vector< Ptr< Vector< Real > > > lrvec_
const Ptr< Constraint< Real > > constraint
std::vector< Ptr< Vector< Real > > > dsvec_