ROL
ROL_OptimizationProblemRefactor.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_OPTIMIZATIONPROBLEMREFACTOR_HPP
45 #define ROL_OPTIMIZATIONPROBLEMREFACTOR_HPP
46 
50 
51 namespace ROL {
52 namespace Refactor {
53 
54 /* Represents optimization problems in Type-EB form
55  */
56 
57 template<class Real>
59 
60  typedef Vector<Real> V;
68 
69  typedef Elementwise::AbsoluteValue<Real> ABS;
70  typedef Elementwise::Fill<Real> FILL;
71 
72  typedef typename PV::size_type size_type;
73 
74 private:
75 
76  Teuchos::RCP<OBJ> obj_;
77  Teuchos::RCP<V> sol_;
78  Teuchos::RCP<BND> bnd_;
79  Teuchos::RCP<EQCON> con_;
80  Teuchos::RCP<V> mul_;
81 
82  Teuchos::RCP<Teuchos::ParameterList> parlist_;
83 
84 public:
85  virtual ~OptimizationProblem(void) {}
86 
87  // Complete option constructor [1]
88  OptimizationProblem( const Teuchos::RCP<Objective<Real> > &obj,
89  const Teuchos::RCP<Vector<Real> > &x,
90  const Teuchos::RCP<BoundConstraint<Real> > &bnd,
91  const Teuchos::RCP<EqualityConstraint<Real> > &eqcon,
92  const Teuchos::RCP<Vector<Real> > &le,
93  const Teuchos::RCP<InequalityConstraint<Real> > &incon,
94  const Teuchos::RCP<Vector<Real> > &li,
95  const Teuchos::RCP<Teuchos::ParameterList> &parlist = Teuchos::null ) :
96  parlist_(parlist) {
97 
98  using Teuchos::RCP; using Teuchos::rcp;
99 
100  // If we have an inequality constraint
101  if( incon != Teuchos::null ) {
102 
103  Real tol = 0;
104 
105  // Create slack variables s = |c_i(x)|
106  RCP<V> s = li->dual().clone();
107  incon->value(*s,*x,tol);
108  s->applyUnary(ABS());
109 
111 
112  RCP<BND> xbnd, sbnd;
113 
114  RCP<V> sl = s->clone();
115  RCP<V> su = s->clone();
116 
117  sl->applyUnary( FILL(0.0) );
118  su->applyUnary( FILL(ROL_INF<Real>()) );
119 
120  sbnd = rcp( new BND(sl,su) );
121 
122  // Create a do-nothing bound constraint for x if we don't have one
123  if( bnd == Teuchos::null ) {
124  xbnd = rcp( new BND(*x) );
125  }
126  else { // Otherwise use the given bound constraint on x
127  xbnd = bnd;
128  }
129 
130  // Create a partitioned bound constraint on the optimization and slack variables
132 
133  // Create partitioned lagrange multiplier and composite constraint
134  if( eqcon == Teuchos::null ) {
136  con_ = rcp( new CCON(incon) );
137  }
138  else {
139  mul_ = CreatePartitionedVector(li,le);
140  con_ = rcp( new CCON(incon,eqcon) );
141  }
142 
143  obj_ = rcp( new SLOBJ(obj) );
144  }
145 
146  else { // There is no inequality constraint
147 
148  obj_ = obj;
149  sol_ = x;
150  mul_ = le;
151  bnd_ = bnd;
152  con_ = eqcon;
153  }
154  }
155 
156  // No inequality constructor [2]
157  OptimizationProblem( const Teuchos::RCP<Objective<Real> > &obj,
158  const Teuchos::RCP<Vector<Real> > &x,
159  const Teuchos::RCP<BoundConstraint<Real> > &bnd,
160  const Teuchos::RCP<EqualityConstraint<Real> > &eqcon,
161  const Teuchos::RCP<Vector<Real> > &le,
162  const Teuchos::RCP<Teuchos::ParameterList> &parlist = Teuchos::null ) :
163  OptimizationProblem( obj, x, bnd, eqcon, le, Teuchos::null, Teuchos::null, parlist ) { }
164 
165  // No equality constructor [3]
166  OptimizationProblem( const Teuchos::RCP<Objective<Real> > &obj,
167  const Teuchos::RCP<Vector<Real> > &x,
168  const Teuchos::RCP<BoundConstraint<Real> > &bnd,
169  const Teuchos::RCP<InequalityConstraint<Real> > &incon,
170  const Teuchos::RCP<Vector<Real> > &li,
171  const Teuchos::RCP<Teuchos::ParameterList> &parlist = Teuchos::null ) :
172  OptimizationProblem( obj, x, bnd, Teuchos::null, Teuchos::null, incon, li, parlist ) { }
173 
174  // No bound constuctor [4]
175  OptimizationProblem( const Teuchos::RCP<Objective<Real> > &obj,
176  const Teuchos::RCP<Vector<Real> > &x,
177  const Teuchos::RCP<EqualityConstraint<Real> > &eqcon,
178  const Teuchos::RCP<Vector<Real> > &le,
179  const Teuchos::RCP<InequalityConstraint<Real> > &incon,
180  const Teuchos::RCP<Vector<Real> > &li,
181  const Teuchos::RCP<Teuchos::ParameterList> &parlist = Teuchos::null ) :
182  OptimizationProblem( obj, x, Teuchos::null, eqcon, le, incon, li, parlist ) {}
183 
184  // No inequality or equality [5]
185  OptimizationProblem( const Teuchos::RCP<Objective<Real> > &obj,
186  const Teuchos::RCP<Vector<Real> > &x,
187  const Teuchos::RCP<BoundConstraint<Real> > &bnd,
188  const Teuchos::RCP<Teuchos::ParameterList> &parlist = Teuchos::null ) :
189  OptimizationProblem( obj, x, bnd, Teuchos::null, Teuchos::null, Teuchos::null, Teuchos::null, parlist ) { }
190  // No inequality or bound [6]
191  OptimizationProblem( const Teuchos::RCP<Objective<Real> > &obj,
192  const Teuchos::RCP<Vector<Real> > &x,
193  const Teuchos::RCP<EqualityConstraint<Real> > &eqcon,
194  const Teuchos::RCP<Vector<Real> > &le,
195  const Teuchos::RCP<Teuchos::ParameterList> &parlist = Teuchos::null ) :
196  OptimizationProblem( obj, x, Teuchos::null, eqcon, le, Teuchos::null, Teuchos::null, parlist ) { }
197 
198  // No equality or bound [7]
199  OptimizationProblem( const Teuchos::RCP<Objective<Real> > &obj,
200  const Teuchos::RCP<Vector<Real> > &x,
201  const Teuchos::RCP<InequalityConstraint<Real> > &incon,
202  const Teuchos::RCP<Vector<Real> > &li,
203  const Teuchos::RCP<Teuchos::ParameterList> &parlist = Teuchos::null ) :
204  OptimizationProblem( obj, x, Teuchos::null, Teuchos::null, Teuchos::null, incon, li, parlist ) { }
205 
206  // Unconstrained problem [8]
207  OptimizationProblem( const Teuchos::RCP<Objective<Real> > &obj,
208  const Teuchos::RCP<Vector<Real> > &x,
209  const Teuchos::RCP<Teuchos::ParameterList> &parlist = Teuchos::null ) :
210  OptimizationProblem( obj, x, Teuchos::null, Teuchos::null, Teuchos::null,
211  Teuchos::null, Teuchos::null, parlist ) { }
212 
213  /* Get/Set methods */
214 
215  Teuchos::RCP<Objective<Real> > getObjective(void) {
216  return obj_;
217  }
218 
219  void setObjective(const Teuchos::RCP<Objective<Real> > &obj) {
220  obj_ = obj;
221  }
222 
223  Teuchos::RCP<Vector<Real> > getSolutionVector(void) {
224  return sol_;
225  }
226 
227  void setSolutionVector(const Teuchos::RCP<Vector<Real> > &sol) {
228  sol_ = sol;
229  }
230 
231  Teuchos::RCP<BoundConstraint<Real> > getBoundConstraint(void) {
232  return bnd_;
233  }
234 
235  void setBoundConstraint(const Teuchos::RCP<BoundConstraint<Real> > &bnd) {
236  bnd_ = bnd;
237  }
238 
239  Teuchos::RCP<EqualityConstraint<Real> > getEqualityConstraint(void) {
240  return con_;
241  }
242 
243  void setEqualityConstraint(const Teuchos::RCP<EqualityConstraint<Real> > &con) {
244  con_ = con;
245  }
246 
247  Teuchos::RCP<Vector<Real> > getMultiplierVector(void) {
248  return mul_;
249  }
250 
251  void setMultiplierVector(const Teuchos::RCP<Vector<Real> > &mul) {
252  mul_ = mul;
253  }
254 
255  Teuchos::RCP<Teuchos::ParameterList> getParameterList(void) {
256  return parlist_;
257  }
258 
259  void setParameterList( const Teuchos::RCP<Teuchos::ParameterList> &parlist ) {
260  parlist_ = parlist;
261  }
262 
263 }; // class OptimizationProblem
264 
265 } // namespace Refactor
266 
267 } // namespace ROL
268 
269 #endif // ROL_OPTIMIZATIONPROBLEMREFACTOR_HPP
Provides the interface to evaluate objective functions.
void setParameterList(const Teuchos::RCP< Teuchos::ParameterList > &parlist)
void setMultiplierVector(const Teuchos::RCP< Vector< Real > > &mul)
Teuchos::RCP< BoundConstraint< Real > > CreateBoundConstraint_Partitioned(const Teuchos::RCP< BoundConstraint< Real > > &bnd1, const Teuchos::RCP< BoundConstraint< Real > > &bnd2)
OptimizationProblem(const Teuchos::RCP< Objective< Real > > &obj, const Teuchos::RCP< Vector< Real > > &x, const Teuchos::RCP< EqualityConstraint< Real > > &eqcon, const Teuchos::RCP< Vector< Real > > &le, const Teuchos::RCP< InequalityConstraint< Real > > &incon, const Teuchos::RCP< Vector< Real > > &li, const Teuchos::RCP< Teuchos::ParameterList > &parlist=Teuchos::null)
Defines the linear algebra of vector space on a generic partitioned vector.
OptimizationProblem(const Teuchos::RCP< Objective< Real > > &obj, const Teuchos::RCP< Vector< Real > > &x, const Teuchos::RCP< InequalityConstraint< Real > > &incon, const Teuchos::RCP< Vector< Real > > &li, const Teuchos::RCP< Teuchos::ParameterList > &parlist=Teuchos::null)
Teuchos::RCP< BoundConstraint< Real > > getBoundConstraint(void)
void setEqualityConstraint(const Teuchos::RCP< EqualityConstraint< Real > > &con)
OptimizationProblem(const Teuchos::RCP< Objective< Real > > &obj, const Teuchos::RCP< Vector< Real > > &x, const Teuchos::RCP< BoundConstraint< Real > > &bnd, const Teuchos::RCP< EqualityConstraint< Real > > &eqcon, const Teuchos::RCP< Vector< Real > > &le, const Teuchos::RCP< InequalityConstraint< Real > > &incon, const Teuchos::RCP< Vector< Real > > &li, const Teuchos::RCP< Teuchos::ParameterList > &parlist=Teuchos::null)
OptimizationProblem(const Teuchos::RCP< Objective< Real > > &obj, const Teuchos::RCP< Vector< Real > > &x, const Teuchos::RCP< EqualityConstraint< Real > > &eqcon, const Teuchos::RCP< Vector< Real > > &le, const Teuchos::RCP< Teuchos::ParameterList > &parlist=Teuchos::null)
Teuchos::RCP< Vector< Real > > CreatePartitionedVector(const Teuchos::RCP< Vector< Real > > &a)
Defines the linear algebra or vector space interface.
Definition: ROL_Vector.hpp:74
void setObjective(const Teuchos::RCP< Objective< Real > > &obj)
Teuchos::RCP< Vector< Real > > getMultiplierVector(void)
Defines the equality constraint operator interface.
Teuchos::RCP< EqualityConstraint< Real > > getEqualityConstraint(void)
OptimizationProblem(const Teuchos::RCP< Objective< Real > > &obj, const Teuchos::RCP< Vector< Real > > &x, const Teuchos::RCP< BoundConstraint< Real > > &bnd, const Teuchos::RCP< EqualityConstraint< Real > > &eqcon, const Teuchos::RCP< Vector< Real > > &le, const Teuchos::RCP< Teuchos::ParameterList > &parlist=Teuchos::null)
Has both inequality and equality constraints. Treat inequality constraint as equality with slack vari...
Teuchos::RCP< Teuchos::ParameterList > parlist_
Provides the interface to apply upper and lower bound constraints.
This class strips out the slack variables from objective evaluations to create the new objective ...
Teuchos::RCP< Vector< Real > > getSolutionVector(void)
OptimizationProblem(const Teuchos::RCP< Objective< Real > > &obj, const Teuchos::RCP< Vector< Real > > &x, const Teuchos::RCP< BoundConstraint< Real > > &bnd, const Teuchos::RCP< Teuchos::ParameterList > &parlist=Teuchos::null)
std::vector< PV >::size_type size_type
Provides a unique argument for inequality constraints, which otherwise behave exactly as equality con...
OptimizationProblem(const Teuchos::RCP< Objective< Real > > &obj, const Teuchos::RCP< Vector< Real > > &x, const Teuchos::RCP< Teuchos::ParameterList > &parlist=Teuchos::null)
Teuchos::RCP< Teuchos::ParameterList > getParameterList(void)
void setBoundConstraint(const Teuchos::RCP< BoundConstraint< Real > > &bnd)
OptimizationProblem(const Teuchos::RCP< Objective< Real > > &obj, const Teuchos::RCP< Vector< Real > > &x, const Teuchos::RCP< BoundConstraint< Real > > &bnd, const Teuchos::RCP< InequalityConstraint< Real > > &incon, const Teuchos::RCP< Vector< Real > > &li, const Teuchos::RCP< Teuchos::ParameterList > &parlist=Teuchos::null)
void setSolutionVector(const Teuchos::RCP< Vector< Real > > &sol)
Teuchos::RCP< Objective< Real > > getObjective(void)