10#ifndef ROL_CONSTRAINT_ASSEMBLER_DEF_H
11#define ROL_CONSTRAINT_ASSEMBLER_DEF_H
15template<
typename Real>
22 con->value(*s,*x,tol);
26template<
typename Real>
32 Ptr<BoundConstraint<Real>> bnd0;
33 if ( bnd == nullPtr ) {
34 bnd0 = makePtr<BoundConstraint<Real>>(*xprim);
46 int cnt = 1, cnt_con = 0;
49 for (
auto it = input_con.begin(); it != input_con.end(); ++it) {
50 Ptr<Constraint<Real>> con = it->second.constraint;
51 Ptr<Vector<Real>> l = it->second.multiplier;
52 Ptr<Vector<Real>> r = it->second.residual;
53 Ptr<BoundConstraint<Real>> cbnd = it->second.bounds;
55 if ( con->isActivated() ) {
62 if (cbnd != nullPtr) {
63 if ( cbnd->isActivated() ) {
67 psvec_.push_back(r->clone());
68 dsvec_.push_back(l->clone());
71 sbnd_.push_back(cbnd);
86 mul_ = makePtr<PartitionedVector<Real>>(
lvec_);
87 res_ = makePtr<PartitionedVector<Real>>(
rvec_);
113template<
typename Real>
120 Ptr<BoundConstraint<Real>> bnd0;
121 if ( bnd == nullPtr ) {
122 bnd0 = makePtr<BoundConstraint<Real>>(*xprim);
135 int cnt = 1, cnt_con = 0, cnt_lcon = 0;
138 for (
auto it = input_con.begin(); it != input_con.end(); ++it) {
139 Ptr<Constraint<Real>> con = it->second.constraint;
140 Ptr<Vector<Real>> l = it->second.multiplier;
141 Ptr<Vector<Real>> r = it->second.residual;
142 Ptr<BoundConstraint<Real>> cbnd = it->second.bounds;
143 if (con != nullPtr) {
144 if ( con->isActivated() ) {
148 cvec_.push_back(con);
151 if (cbnd != nullPtr) {
152 if ( cbnd->isActivated() ) {
156 psvec_.push_back(r->clone());
157 dsvec_.push_back(l->clone());
160 sbnd_.push_back(cbnd);
171 for (
auto it = input_lcon.begin(); it != input_lcon.end(); ++it) {
172 Ptr<Constraint<Real>> con = it->second.constraint;
173 Ptr<Vector<Real>> l = it->second.multiplier;
174 Ptr<Vector<Real>> r = it->second.residual;
175 Ptr<BoundConstraint<Real>> cbnd = it->second.bounds;
176 if (con != nullPtr) {
177 if ( con->isActivated() ) {
184 if (cbnd != nullPtr) {
185 if ( cbnd->isActivated() ) {
189 psvec_.push_back(r->clone());
190 dsvec_.push_back(l->clone());
193 sbnd_.push_back(cbnd);
208 mul_ = makePtr<PartitionedVector<Real>>(
lvec_);
209 res_ = makePtr<PartitionedVector<Real>>(
rvec_);
248template<
typename Real>
257template<
typename Real>
267template<
typename Real>
272template<
typename Real>
277template<
typename Real>
282template<
typename Real>
287template<
typename Real>
292template<
typename Real>
297template<
typename Real>
302template<
typename Real>
307template<
typename Real>
312template<
typename Real>
317template<
typename Real>
322template<
typename Real>
325 int size =
static_cast<int>(
cvec_.size());
327 for (
int i = 0; i < size; ++i) {
334 size =
static_cast<int>(
lcvec_.size());
335 for (
int i = 0; i < size; ++i) {
Provides the interface to apply upper and lower bound constraints.
std::vector< Ptr< Vector< Real > > > lvec_
void initializeSlackVariable(const Ptr< Constraint< Real > > &con, const Ptr< BoundConstraint< Real > > &cbnd, const Ptr< Vector< Real > > &s, const Ptr< Vector< Real > > &x) const
const Ptr< Constraint< Real > > & getLinearConstraint() const
std::vector< bool > isInequality_
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)
ConstraintAssembler(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)
Ptr< Constraint< Real > > con_
Ptr< BoundConstraint< Real > > bnd_
void resetSlackVariables()
std::vector< Ptr< Vector< Real > > > psvec_
std::vector< Ptr< Constraint< Real > > > cvec_
Ptr< Vector< Real > > mul_
Ptr< Constraint< Real > > linear_con_
const Ptr< Vector< Real > > & getMultiplier() const
std::vector< Ptr< Vector< Real > > > dsvec_
std::vector< bool > isLinearInequality_
const Ptr< Vector< Real > > & getLinearResidual() const
const Ptr< Vector< Real > > & getDualOptVector() const
Ptr< Vector< Real > > linear_mul_
std::vector< Ptr< Vector< Real > > > rvec_
Ptr< Vector< Real > > xdual_
const Ptr< BoundConstraint< Real > > & getBoundConstraint() const
std::vector< Ptr< Vector< Real > > > llvec_
Ptr< Vector< Real > > linear_res_
Ptr< Vector< Real > > xprim_
std::vector< Ptr< BoundConstraint< Real > > > sbnd_
const Ptr< Constraint< Real > > & getConstraint() const
const Ptr< Vector< Real > > & getLinearMultiplier() const
Ptr< Vector< Real > > res_
std::vector< Ptr< Vector< Real > > > lrvec_
const Ptr< Vector< Real > > & getOptVector() const
bool hasInequality() const
std::vector< Ptr< Constraint< Real > > > lcvec_
const Ptr< Vector< Real > > & getResidual() const
Defines the general constraint operator interface.
Defines the linear algebra or vector space interface.
Real ROL_EPSILON(void)
Platform-dependent machine epsilon.