ROL
ROL_NewConstraintManager.hpp
Go to the documentation of this file.
1// @HEADER
2// ************************************************************************
3//
4// Rapid Optimization Library (ROL) Package
5// Copyright (2014) Sandia Corporation
6//
7// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8// license for use of this work by or on behalf of the U.S. Government.
9//
10// Redistribution and use in source and binary forms, with or without
11// modification, are permitted provided that the following conditions are
12// met:
13//
14// 1. Redistributions of source code must retain the above copyright
15// notice, this list of conditions and the following disclaimer.
16//
17// 2. Redistributions in binary form must reproduce the above copyright
18// notice, this list of conditions and the following disclaimer in the
19// documentation and/or other materials provided with the distribution.
20//
21// 3. Neither the name of the Corporation nor the names of the
22// contributors may be used to endorse or promote products derived from
23// this software without specific prior written permission.
24//
25// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36//
37// Questions? Contact lead developers:
38// Drew Kouri (dpkouri@sandia.gov) and
39// Denis Ridzal (dridzal@sandia.gov)
40//
41// ************************************************************************
42// @HEADER
43
44#ifndef ROL_NEW_CONSTRAINT_MANAGER_H
45#define ROL_NEW_CONSTRAINT_MANAGER_H
46
49#include <unordered_map>
50
58namespace ROL {
59
60template<typename Real>
61struct ConstraintData {
62 const Ptr<Constraint<Real>> constraint;
63 const Ptr<Vector<Real>> multiplier;
64 const Ptr<Vector<Real>> residual;
65 const Ptr<BoundConstraint<Real>> bounds;
66
68 const Ptr<Vector<Real>> &mul,
69 const Ptr<Vector<Real>> &res=nullPtr,
70 const Ptr<BoundConstraint<Real>> &bnd=nullPtr)
71 : constraint(con), multiplier(mul),
72 residual(res==nullPtr ? mul->dual().clone() : res), bounds(bnd) {}
73};
74
75template<typename Real>
77private:
78 Ptr<Constraint<Real>> con_;
79 Ptr<Vector<Real>> mul_;
80 Ptr<Vector<Real>> res_;
81 Ptr<Constraint<Real>> linear_con_;
82 Ptr<Vector<Real>> linear_mul_;
83 Ptr<Vector<Real>> linear_res_;
84 Ptr<Vector<Real>> xprim_;
85 Ptr<Vector<Real>> xdual_;
86 Ptr<BoundConstraint<Real>> bnd_;
87
88 std::vector<Ptr<Constraint<Real>>> cvec_; // General constraints
89 std::vector<Ptr<Vector<Real>>> lvec_; // General multiplier vector
90 std::vector<Ptr<Vector<Real>>> rvec_; // General residual vector
91 std::vector<Ptr<Constraint<Real>>> lcvec_; // Linear constraints
92 std::vector<Ptr<Vector<Real>>> llvec_; // Linear multiplier vector
93 std::vector<Ptr<Vector<Real>>> lrvec_; // Linear residual vector
94 std::vector<Ptr<Vector<Real>>> psvec_; // Primal slack vector
95 std::vector<Ptr<Vector<Real>>> dsvec_; // Dual slack vector
96 std::vector<Ptr<BoundConstraint<Real>>> sbnd_; // Slack bound constraint
97
99
102
103 void initializeSlackVariable(const Ptr<Constraint<Real>> &con,
104 const Ptr<BoundConstraint<Real>> &cbnd,
105 const Ptr<Vector<Real>> &s,
106 const Ptr<Vector<Real>> &x) const;
107
108 void initialize(const std::unordered_map<std::string,ConstraintData<Real>> &input_con,
109 const Ptr<Vector<Real>> &xprim,
110 const Ptr<Vector<Real>> &xdual,
111 const Ptr<BoundConstraint<Real>> &bnd);
112
113 void initialize(const std::unordered_map<std::string,ConstraintData<Real>> &input_con,
114 const std::unordered_map<std::string,ConstraintData<Real>> &input_lcon,
115 const Ptr<Vector<Real>> &xprim,
116 const Ptr<Vector<Real>> &xdual,
117 const Ptr<BoundConstraint<Real>> &bnd);
118
119public:
120 virtual ~NewConstraintManager(void) {}
121
122 NewConstraintManager(const std::unordered_map<std::string,ConstraintData<Real>> &con,
123 const Ptr<Vector<Real>> &xprim,
124 const Ptr<Vector<Real>> &xdual,
125 const Ptr<BoundConstraint<Real>> &bnd = nullPtr);
126
127 NewConstraintManager(const std::unordered_map<std::string,ConstraintData<Real>> &con,
128 const std::unordered_map<std::string,ConstraintData<Real>> &linear_con,
129 const Ptr<Vector<Real>> &xprim,
130 const Ptr<Vector<Real>> &xdual,
131 const Ptr<BoundConstraint<Real>> &bnd = nullPtr);
132
133 const Ptr<Constraint<Real>> getConstraint(void) const;
134 const Ptr<Vector<Real>> getMultiplier(void) const;
135 const Ptr<Vector<Real>> getResidual(void) const;
136 const Ptr<Constraint<Real>> getLinearConstraint(void) const;
137 const Ptr<Vector<Real>> getLinearMultiplier(void) const;
138 const Ptr<Vector<Real>> getLinearResidual(void) const;
139 const Ptr<Vector<Real>> getOptVector(void) const;
140 const Ptr<Vector<Real>> getDualOptVector(void) const;
141 const Ptr<BoundConstraint<Real>> getBoundConstraint(void) const;
142
143 bool isNull(void) const;
144 bool hasInequality(void) const;
145
146 void resetSlackVariables(void);
147
148}; // class NewConstraintManager
149
150} // namespace ROL
151
153
154#endif
Provides the interface to apply upper and lower bound constraints.
Defines the general constraint operator interface.
Provides a wrapper for multiple constraints.
std::vector< Ptr< Vector< Real > > > llvec_
std::vector< Ptr< Vector< Real > > > rvec_
std::vector< Ptr< Vector< Real > > > lrvec_
const Ptr< Vector< Real > > getDualOptVector(void) const
std::vector< Ptr< Vector< Real > > > lvec_
std::vector< Ptr< Constraint< Real > > > lcvec_
const Ptr< Vector< Real > > getOptVector(void) const
const Ptr< Vector< Real > > getResidual(void) const
const Ptr< BoundConstraint< Real > > getBoundConstraint(void) const
const Ptr< Vector< Real > > getLinearMultiplier(void) const
const Ptr< Constraint< Real > > getConstraint(void) const
const Ptr< Vector< Real > > getMultiplier(void) const
Ptr< Constraint< Real > > linear_con_
std::vector< Ptr< Vector< Real > > > psvec_
Ptr< BoundConstraint< Real > > bnd_
Ptr< Constraint< Real > > con_
void initializeSlackVariable(const Ptr< Constraint< Real > > &con, const Ptr< BoundConstraint< Real > > &cbnd, const Ptr< Vector< Real > > &s, const Ptr< Vector< Real > > &x) const
std::vector< Ptr< BoundConstraint< Real > > > sbnd_
const Ptr< Vector< Real > > getLinearResidual(void) const
std::vector< Ptr< Constraint< Real > > > cvec_
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)
std::vector< Ptr< Vector< Real > > > dsvec_
const Ptr< Constraint< Real > > getLinearConstraint(void) const
Defines the linear algebra or vector space interface.
Definition: ROL_Vector.hpp:84
const Ptr< Constraint< Real > > constraint
const Ptr< BoundConstraint< Real > > bounds
const Ptr< Vector< Real > > residual
const Ptr< Vector< Real > > multiplier
ConstraintData(const Ptr< Constraint< Real > > &con, const Ptr< Vector< Real > > &mul, const Ptr< Vector< Real > > &res=nullPtr, const Ptr< BoundConstraint< Real > > &bnd=nullPtr)