ROL
ROL_PolyhedralProjectionFactory.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_POLYHEDRALPROJECTIONFACTORY_H
11 #define ROL_POLYHEDRALPROJECTIONFACTORY_H
12 
18 #include "ROL_BrentsProjection.hpp"
19 
20 namespace ROL {
21 
38 };
39 
40 inline std::string EPolyProjAlgoToString(EPolyProjAlgo alg) {
41  std::string retString;
42  switch(alg) {
43  case PPA_DAIFLETCHER: retString = "Dai-Fletcher"; break;
44  case PPA_DYKSTRA: retString = "Dysktra"; break;
45  case PPA_DOUGLASRACHFORD: retString = "Douglas-Rachford"; break;
46  case PPA_NEWTON: retString = "Semismooth Newton"; break;
47  case PPA_RIDDERS: retString = "Ridders"; break;
48  case PPA_BRENTS: retString = "Brents"; break;
49  case PPA_LAST: retString = "Last Type (Dummy)"; break;
50  default: retString = "INVALID EPolyProjAlgo";
51  }
52  return retString;
53 }
54 
61  return( (alg == PPA_DAIFLETCHER) ||
62  (alg == PPA_DYKSTRA) ||
63  (alg == PPA_DOUGLASRACHFORD) ||
64  (alg == PPA_NEWTON) ||
65  (alg == PPA_RIDDERS) ||
66  (alg == PPA_BRENTS) ||
67  (alg == PPA_LAST)
68  );
69 }
70 
72  return type = static_cast<EPolyProjAlgo>(type+1);
73 }
74 
76  EPolyProjAlgo oldval = type;
77  ++type;
78  return oldval;
79 }
80 
82  return type = static_cast<EPolyProjAlgo>(type-1);
83 }
84 
86  EPolyProjAlgo oldval = type;
87  --type;
88  return oldval;
89 }
90 
91 inline EPolyProjAlgo StringToEPolyProjAlgo(std::string s) {
92  s = removeStringFormat(s);
93  for ( EPolyProjAlgo alg = PPA_DAIFLETCHER; alg < PPA_LAST; alg++ ) {
94  if ( !s.compare(removeStringFormat(EPolyProjAlgoToString(alg))) ) {
95  return alg;
96  }
97  }
98  return PPA_DYKSTRA;
99 }
100 
101 template<typename Real>
102 inline Ptr<PolyhedralProjection<Real>> PolyhedralProjectionFactory(const Vector<Real> &xprim,
103  const Vector<Real> &xdual,
104  const Ptr<BoundConstraint<Real>> &bnd,
105  const Ptr<Constraint<Real>> &con,
106  const Vector<Real> &mul,
107  const Vector<Real> &res,
108  ParameterList &list) {
109  std::string projectionType = list.sublist("General").sublist("Polyhedral Projection").get("Type","Dykstra");
110  EPolyProjAlgo ealg = StringToEPolyProjAlgo(projectionType);
111  switch(ealg) {
112  case PPA_DAIFLETCHER: return makePtr<DaiFletcherProjection<Real>>(xprim,xdual,bnd,con,mul,res,list); break;
113  case PPA_DYKSTRA: return makePtr<DykstraProjection<Real>>(xprim,xdual,bnd,con,mul,res,list); break;
114  case PPA_DOUGLASRACHFORD: return makePtr<DouglasRachfordProjection<Real>>(xprim,xdual,bnd,con,mul,res,list); break;
115  case PPA_NEWTON: return makePtr<SemismoothNewtonProjection<Real>>(xprim,xdual,bnd,con,mul,res,list); break;
116  case PPA_RIDDERS: return makePtr<RiddersProjection<Real>>(xprim,xdual,bnd,con,mul,res,list); break;
117  case PPA_BRENTS: return makePtr<BrentsProjection<Real>>(xprim,xdual,bnd,con,mul,res,list); break;
118  default: return nullPtr;
119  }
120 }
121 } // namespace ROL
122 
123 #endif
std::string EPolyProjAlgoToString(EPolyProjAlgo alg)
EPolyProjAlgo StringToEPolyProjAlgo(std::string s)
EPolyProjAlgo & operator++(EPolyProjAlgo &type)
Ptr< PolyhedralProjection< Real > > PolyhedralProjectionFactory(const Vector< Real > &xprim, const Vector< Real > &xdual, const Ptr< BoundConstraint< Real >> &bnd, const Ptr< Constraint< Real >> &con, const Vector< Real > &mul, const Vector< Real > &res, ParameterList &list)
std::string removeStringFormat(std::string s)
Definition: ROL_Types.hpp:215
Defines the linear algebra or vector space interface.
Definition: ROL_Vector.hpp:46
EPolyProjAlgo
Enumeration of polyhedral projecdtion algorithm types.
EPolyProjAlgo & operator--(EPolyProjAlgo &type)
int isValidPolyProjAlgo(EPolyProjAlgo alg)
Verifies validity of a PolyProjAlgo enum.
Provides the interface to apply upper and lower bound constraints.
Defines the general constraint operator interface.