ROL
dual-spaces/simple-eq-constr-1/example_01.cpp
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 
50 #include "ROL_Algorithm.hpp"
52 #include "ROL_CompositeStep.hpp"
53 #include "Teuchos_oblackholestream.hpp"
54 #include "Teuchos_GlobalMPISession.hpp"
55 
56 #include <iostream>
57 
58 typedef double RealT;
59 
60 /*** Declare four vector spaces. ***/
61 
62 // Forward declarations:
63 
64 template <class Real, class Element=Real>
65 class OptStdVector; // Optimization space.
66 
67 template <class Real, class Element=Real>
68 class OptDualStdVector; // Dual optimization space.
69 
70 template <class Real, class Element=Real>
71 class ConStdVector; // Constraint space.
72 
73 template <class Real, class Element=Real>
74 class ConDualStdVector; // Dual constraint space.
75 
76 // Vector space definitions:
77 
78 // Optimization space.
79 template <class Real, class Element>
80 class OptStdVector : public ROL::Vector<Real> {
81 
82 typedef std::vector<Element> vector;
84 typedef typename vector::size_type uint;
85 
86 private:
87 Teuchos::RCP<std::vector<Element> > std_vec_;
88 mutable Teuchos::RCP<OptDualStdVector<Real> > dual_vec_;
89 
90 public:
91 
92 OptStdVector(const Teuchos::RCP<std::vector<Element> > & std_vec) : std_vec_(std_vec), dual_vec_(Teuchos::null) {}
93 
94 void plus( const ROL::Vector<Real> &x ) {
95  using Teuchos::RCP; using Teuchos::dyn_cast;
96 
97  RCP<const vector> xp = dyn_cast<const OptStdVector>(x).getVector();
98 
99  uint dimension = std_vec_->size();
100  for (uint i=0; i<dimension; i++) {
101  (*std_vec_)[i] += (*xp)[i];
102  }
103 }
104 
105 void scale( const Real alpha ) {
106  uint dimension = std_vec_->size();
107  for (uint i=0; i<dimension; i++) {
108  (*std_vec_)[i] *= alpha;
109  }
110 }
111 
112 Real dot( const ROL::Vector<Real> &x ) const {
113 
114  using Teuchos::RCP; using Teuchos::dyn_cast;
115 
116  RCP<const vector> xp = dyn_cast<const OptStdVector>(x).getVector();
117  Real val = 0;
118 
119  uint dimension = std_vec_->size();
120  for (uint i=0; i<dimension; i++) {
121  val += (*std_vec_)[i]*(*xp)[i];
122  }
123  return val;
124 }
125 
126 Real norm() const {
127  Real val = 0;
128  val = std::sqrt( dot(*this) );
129  return val;
130 }
131 
132 Teuchos::RCP<ROL::Vector<Real> > clone() const {
133  return Teuchos::rcp( new OptStdVector( Teuchos::rcp( new std::vector<Element>(std_vec_->size()) ) ) );
134 }
135 
136 Teuchos::RCP<const std::vector<Element> > getVector() const {
137  return std_vec_;
138 }
139 
140 Teuchos::RCP<std::vector<Element> > getVector() {
141  return std_vec_;
142 }
143 
144 Teuchos::RCP<ROL::Vector<Real> > basis( const int i ) const {
145  using Teuchos::RCP; using Teuchos::rcp;
146  RCP<vector> e_rcp = rcp( new vector(std_vec_->size(),0.0) );
147  RCP<V> e = rcp( new OptStdVector( e_rcp ) );
148  (*e_rcp)[i] = 1.0;
149  return e;
150 }
151 
152 int dimension() const {return static_cast<int>(std_vec_->size());}
153 
154 const ROL::Vector<Real> & dual() const {
155  dual_vec_ = Teuchos::rcp( new OptDualStdVector<Real>( Teuchos::rcp( new std::vector<Element>(*std_vec_) ) ) );
156  return *dual_vec_;
157 }
158 
159 }; // class OptStdVector
160 
161 
162 // Dual optimization space.
163 template <class Real, class Element>
164 class OptDualStdVector : public ROL::Vector<Real> {
165 
166 typedef std::vector<Element> vector;
168 typedef typename vector::size_type uint;
169 
170 private:
171 Teuchos::RCP<std::vector<Element> > std_vec_;
172 mutable Teuchos::RCP<OptStdVector<Real> > dual_vec_;
173 
174 public:
175 
176 OptDualStdVector(const Teuchos::RCP<std::vector<Element> > & std_vec) : std_vec_(std_vec), dual_vec_(Teuchos::null) {}
177 
178 void plus( const ROL::Vector<Real> &x ) {
179  using Teuchos::RCP; using Teuchos::dyn_cast;
180  RCP<const vector> xp = dyn_cast<const OptDualStdVector>(x).getVector();
181  uint dimension = std_vec_->size();
182  for (uint i=0; i<dimension; i++) {
183  (*std_vec_)[i] += (*xp)[i];
184  }
185 }
186 
187 void scale( const Real alpha ) {
188  uint dimension = std_vec_->size();
189  for (uint i=0; i<dimension; i++) {
190  (*std_vec_)[i] *= alpha;
191  }
192 }
193 
194 Real dot( const ROL::Vector<Real> &x ) const {
195  using Teuchos::RCP; using Teuchos::dyn_cast;
196  RCP<const vector> xp = dyn_cast<const OptDualStdVector>(x).getVector();
197  Real val = 0;
198  uint dimension = std_vec_->size();
199  for (uint i=0; i<dimension; i++) {
200  val += (*std_vec_)[i]*(*xp)[i];
201  }
202  return val;
203 }
204 
205 Real norm() const {
206  Real val = 0;
207  val = std::sqrt( dot(*this) );
208  return val;
209 }
210 
211 Teuchos::RCP<ROL::Vector<Real> > clone() const {
212  return Teuchos::rcp( new OptDualStdVector( Teuchos::rcp( new std::vector<Element>(std_vec_->size()) ) ) );
213 }
214 
215 Teuchos::RCP<const std::vector<Element> > getVector() const {
216  return std_vec_;
217 }
218 
219 Teuchos::RCP<std::vector<Element> > getVector() {
220  return std_vec_;
221 }
222 
223 Teuchos::RCP<ROL::Vector<Real> > basis( const int i ) const {
224  using Teuchos::RCP; using Teuchos::rcp;
225  RCP<vector> e_rcp = rcp( new vector( std_vec_->size(), 0.0 ) );
226  RCP<V> e = rcp( new OptDualStdVector( e_rcp ) );
227  (*e_rcp)[i] = 1.0;
228  return e;
229 }
230 
231 int dimension() const {return static_cast<int>(std_vec_->size());}
232 
233 const ROL::Vector<Real> & dual() const {
234  dual_vec_ = Teuchos::rcp( new OptStdVector<Real>( Teuchos::rcp( new std::vector<Element>(*std_vec_) ) ) );
235  return *dual_vec_;
236 }
237 
238 }; // class OptDualStdVector
239 
240 
241 // Constraint space.
242 template <class Real, class Element>
243 class ConStdVector : public ROL::Vector<Real> {
244 
245 typedef std::vector<Element> vector;
247 typedef typename vector::size_type uint;
248 
249 private:
250 Teuchos::RCP<std::vector<Element> > std_vec_;
251 mutable Teuchos::RCP<ConDualStdVector<Real> > dual_vec_;
252 
253 public:
254 
255 ConStdVector(const Teuchos::RCP<std::vector<Element> > & std_vec) : std_vec_(std_vec), dual_vec_(Teuchos::null) {}
256 
257 void plus( const ROL::Vector<Real> &x ) {
258  using Teuchos::RCP; using Teuchos::dyn_cast;
259  RCP<const vector> xp = dyn_cast<const ConStdVector>(x).getVector();
260  uint dimension = std_vec_->size();
261  for (uint i=0; i<dimension; i++) {
262  (*std_vec_)[i] += (*xp)[i];
263  }
264 }
265 
266 void scale( const Real alpha ) {
267  uint dimension = std_vec_->size();
268  for (uint i=0; i<dimension; i++) {
269  (*std_vec_)[i] *= alpha;
270  }
271 }
272 
273 Real dot( const ROL::Vector<Real> &x ) const {
274  using Teuchos::RCP; using Teuchos::dyn_cast;
275  RCP<const vector> xp = dyn_cast<const ConStdVector>(x).getVector();
276  Real val = 0;
277  uint dimension = std_vec_->size();
278  for (uint i=0; i<dimension; i++) {
279  val += (*std_vec_)[i]*(*xp)[i];
280  }
281  return val;
282 }
283 
284 Real norm() const {
285  Real val = 0;
286  val = std::sqrt( dot(*this) );
287  return val;
288 }
289 
290 Teuchos::RCP<ROL::Vector<Real> > clone() const {
291  return Teuchos::rcp( new ConStdVector( Teuchos::rcp(new std::vector<Element>(std_vec_->size())) ) );
292 }
293 
294 Teuchos::RCP<const std::vector<Element> > getVector() const {
295  return std_vec_;
296 }
297 
298 Teuchos::RCP<std::vector<Element> > getVector() {
299  return std_vec_;
300 }
301 
302 Teuchos::RCP<ROL::Vector<Real> > basis( const int i ) const {
303  using Teuchos::RCP; using Teuchos::rcp;
304  RCP<vector> e_rcp = rcp( new vector(std_vec_->size(), 0.0) );
305  RCP<V> e = rcp( new ConStdVector( e_rcp ) );
306  (*e_rcp)[i] = 1.0;
307  return e;
308 }
309 
310 int dimension() const {return static_cast<int>(std_vec_->size());}
311 
312 const ROL::Vector<Real> & dual() const {
313  dual_vec_ = Teuchos::rcp( new ConDualStdVector<Real>( Teuchos::rcp( new std::vector<Element>(*std_vec_) ) ) );
314  return *dual_vec_;
315 }
316 
317 }; // class ConStdVector
318 
319 
320 // Dual constraint space.
321 template <class Real, class Element>
322 class ConDualStdVector : public ROL::Vector<Real> {
323 
324  typedef std::vector<Element> vector;
326  typedef typename vector::size_type uint;
327 
328 private:
329 
330 Teuchos::RCP<std::vector<Element> > std_vec_;
331 mutable Teuchos::RCP<ConStdVector<Real> > dual_vec_;
332 
333 public:
334 
335 ConDualStdVector(const Teuchos::RCP<std::vector<Element> > & std_vec) : std_vec_(std_vec), dual_vec_(Teuchos::null) {}
336 
337 void plus( const ROL::Vector<Real> &x ) {
338  using Teuchos::RCP; using Teuchos::dyn_cast;
339  RCP<const vector> xp = dyn_cast<const ConDualStdVector>(x).getVector();
340  uint dimension = std_vec_->size();
341  for (uint i=0; i<dimension; i++) {
342  (*std_vec_)[i] += (*xp)[i];
343  }
344 }
345 
346 void scale( const Real alpha ) {
347  uint dimension = std_vec_->size();
348  for (uint i=0; i<dimension; i++) {
349  (*std_vec_)[i] *= alpha;
350  }
351 }
352 
353 Real dot( const ROL::Vector<Real> &x ) const {
354  using Teuchos::RCP; using Teuchos::dyn_cast;
355  RCP<const vector> xp = dyn_cast<const ConDualStdVector>(x).getVector();
356  Real val = 0;
357  uint dimension = std_vec_->size();
358  for (uint i=0; i<dimension; i++) {
359  val += (*std_vec_)[i]*(*xp)[i];
360  }
361  return val;
362 }
363 
364 Real norm() const {
365  Real val = 0;
366  val = std::sqrt( dot(*this) );
367  return val;
368 }
369 
370 Teuchos::RCP<ROL::Vector<Real> > clone() const {
371  return Teuchos::rcp( new ConDualStdVector( Teuchos::rcp(new std::vector<Element>(std_vec_->size())) ) );
372 }
373 
374 Teuchos::RCP<const std::vector<Element> > getVector() const {
375  return std_vec_;
376 }
377 
378 Teuchos::RCP<std::vector<Element> > getVector() {
379  return std_vec_;
380 }
381 
382 Teuchos::RCP<ROL::Vector<Real> > basis( const int i ) const {
383  using Teuchos::RCP; using Teuchos::rcp;
384  RCP<vector> e_rcp = rcp( new vector(std_vec_->size(),0.0) );
385  RCP<V> e = rcp( new ConDualStdVector(e_rcp) );
386  (*e_rcp)[i] = 1.0;
387  return e;
388 }
389 
390 int dimension() const {return static_cast<int>(std_vec_->size());}
391 
392 const ROL::Vector<Real> & dual() const {
393  dual_vec_ = Teuchos::rcp( new ConStdVector<Real>( Teuchos::rcp( new std::vector<Element>(*std_vec_) ) ) );
394  return *dual_vec_;
395 }
396 
397 }; // class ConDualStdVector
398 
399 /*** End of declaration of four vector spaces. ***/
400 
401 
402 int main(int argc, char *argv[]) {
403 
404  typedef std::vector<RealT> vector;
405  typedef vector::size_type uint;
406 
407  using Teuchos::RCP; using Teuchos::rcp;
408 
409  Teuchos::GlobalMPISession mpiSession(&argc, &argv);
410 
411  // This little trick lets us print to std::cout only if a (dummy) command-line argument is provided.
412  int iprint = argc - 1;
413  Teuchos::RCP<std::ostream> outStream;
414  Teuchos::oblackholestream bhs; // outputs nothing
415  if (iprint > 0)
416  outStream = Teuchos::rcp(&std::cout, false);
417  else
418  outStream = Teuchos::rcp(&bhs, false);
419 
420  int errorFlag = 0;
421 
422  // *** Example body.
423 
424  try {
425 
426  RCP<ROL::Objective<RealT> > obj;
427  RCP<ROL::EqualityConstraint<RealT> > constr;
428  RCP<vector> x_rcp = rcp( new vector(0, 0.0) );
429  RCP<vector> sol_rcp = rcp( new vector(0, 0.0) );
430  OptStdVector<RealT> x(x_rcp); // Iteration vector.
431  OptStdVector<RealT> sol(sol_rcp); // Reference solution vector.
432 
433  // Retrieve objective, constraint, iteration vector, solution vector.
434  ROL::ZOO::getSimpleEqConstrained <RealT, OptStdVector<RealT>, OptDualStdVector<RealT>, ConStdVector<RealT>, ConDualStdVector<RealT> > (obj, constr, x, sol);
435 
436  // Run derivative checks, etc.
437  uint dim = 5;
438  uint nc = 3;
439  RealT left = -1e0, right = 1e0;
440  RCP<vector> xtest_rcp = rcp( new vector(dim, 0.0) );
441  RCP<vector> g_rcp = rcp( new vector(dim, 0.0) );
442  RCP<vector> d_rcp = rcp( new vector(dim, 0.0) );
443  RCP<vector> gd_rcp = rcp( new vector(dim, 0.0) );
444  RCP<vector> v_rcp = rcp( new vector(dim, 0.0) );
445  RCP<vector> vc_rcp = rcp( new vector(nc, 0.0) );
446  RCP<vector> vl_rcp = rcp( new vector(nc, 0.0) );
447  OptStdVector<RealT> xtest(xtest_rcp);
448  OptDualStdVector<RealT> g(g_rcp);
449  OptStdVector<RealT> d(d_rcp);
450  OptDualStdVector<RealT> gd(gd_rcp);
451  OptStdVector<RealT> v(v_rcp);
452  ConStdVector<RealT> vc(vc_rcp);
453  ConDualStdVector<RealT> vl(vl_rcp);
454  // set xtest, d, v
455  for (uint i=0; i<dim; i++) {
456  (*xtest_rcp)[i] = ( (RealT)rand() / (RealT)RAND_MAX ) * (right - left) + left;
457  (*d_rcp)[i] = ( (RealT)rand() / (RealT)RAND_MAX ) * (right - left) + left;
458  (*gd_rcp)[i] = ( (RealT)rand() / (RealT)RAND_MAX ) * (right - left) + left;
459  (*v_rcp)[i] = ( (RealT)rand() / (RealT)RAND_MAX ) * (right - left) + left;
460  }
461  // set vc, vl
462  for (uint i=0; i<nc; i++) {
463  (*vc_rcp)[i] = ( (RealT)rand() / (RealT)RAND_MAX ) * (right - left) + left;
464  (*vl_rcp)[i] = ( (RealT)rand() / (RealT)RAND_MAX ) * (right - left) + left;
465  }
466  obj->checkGradient(xtest, g, d, true, *outStream); *outStream << "\n";
467  obj->checkHessVec(xtest, g, v, true, *outStream); *outStream << "\n";
468  obj->checkHessSym(xtest, g, d, v, true, *outStream); *outStream << "\n";
469  constr->checkApplyJacobian(xtest, v, vc, true, *outStream); *outStream << "\n";
470  constr->checkApplyAdjointJacobian(xtest, vl, vc, g, true, *outStream); *outStream << "\n";
471  constr->checkApplyAdjointHessian(xtest, vl, d, g, true, *outStream); *outStream << "\n";
472 
473  RCP<vector> v1_rcp = rcp( new vector(dim, 0.0) );
474  RCP<vector> v2_rcp = rcp( new vector(nc, 0.0) );
475  OptStdVector<RealT> v1(v1_rcp);
476  ConDualStdVector<RealT> v2(v2_rcp);
477  RealT augtol = 1e-8;
478  constr->solveAugmentedSystem(v1, v2, gd, vc, xtest, augtol);
479 
480 
481  // Define algorithm.
482  Teuchos::ParameterList parlist;
483  std::string stepname = "Composite Step";
484  parlist.sublist("Step").sublist(stepname).sublist("Optimality System Solver").set("Nominal Relative Tolerance",1e-4);
485  parlist.sublist("Step").sublist(stepname).sublist("Optimality System Solver").set("Fix Tolerance",true);
486  parlist.sublist("Step").sublist(stepname).sublist("Tangential Subproblem Solver").set("Iteration Limit",20);
487  parlist.sublist("Step").sublist(stepname).sublist("Tangential Subproblem Solver").set("Relative Tolerance",1e-2);
488  parlist.sublist("Step").sublist(stepname).set("Output Level",0);
489  parlist.sublist("Status Test").set("Gradient Tolerance",1.e-12);
490  parlist.sublist("Status Test").set("Constraint Tolerance",1.e-12);
491  parlist.sublist("Status Test").set("Step Tolerance",1.e-18);
492  parlist.sublist("Status Test").set("Iteration Limit",100);
493  ROL::Algorithm<RealT> algo(stepname, parlist);
494 
495  // Run Algorithm
496  vl.zero();
497  //(*x_rcp)[0] = 3.0; (*x_rcp)[1] = 2.0; (*x_rcp)[2] = 2.0; (*x_rcp)[3] = 1.0; (*x_rcp)[4] = 1.0;
498  //(*x_rcp)[0] = -5.0; (*x_rcp)[1] = -5.0; (*x_rcp)[2] = -5.0; (*x_rcp)[3] = -6.0; (*x_rcp)[4] = -6.0;
499  algo.run(x, g, vl, vc, *obj, *constr, true, *outStream);
500 
501  // Compute Error
502  *outStream << "\nReference solution x_r =\n";
503  *outStream << std::scientific << " " << (*sol_rcp)[0] << "\n";
504  *outStream << std::scientific << " " << (*sol_rcp)[1] << "\n";
505  *outStream << std::scientific << " " << (*sol_rcp)[2] << "\n";
506  *outStream << std::scientific << " " << (*sol_rcp)[3] << "\n";
507  *outStream << std::scientific << " " << (*sol_rcp)[4] << "\n";
508  *outStream << "\nOptimal solution x =\n";
509  *outStream << std::scientific << " " << (*x_rcp)[0] << "\n";
510  *outStream << std::scientific << " " << (*x_rcp)[1] << "\n";
511  *outStream << std::scientific << " " << (*x_rcp)[2] << "\n";
512  *outStream << std::scientific << " " << (*x_rcp)[3] << "\n";
513  *outStream << std::scientific << " " << (*x_rcp)[4] << "\n";
514  x.axpy(-1.0, sol);
515  RealT abserr = x.norm();
516  RealT relerr = abserr/sol.norm();
517  *outStream << std::scientific << "\n Absolute Error: " << abserr;
518  *outStream << std::scientific << "\n Relative Error: " << relerr << "\n";
519  if ( relerr > sqrt(ROL::ROL_EPSILON<RealT>()) ) {
520  errorFlag += 1;
521  }
522  }
523  catch (std::logic_error err) {
524  *outStream << err.what() << "\n";
525  errorFlag = -1000;
526  }; // end try
527 
528  if (errorFlag != 0)
529  std::cout << "End Result: TEST FAILED\n";
530  else
531  std::cout << "End Result: TEST PASSED\n";
532 
533  return 0;
534 
535 }
536 
Teuchos::RCP< std::vector< Element > > std_vec_
Teuchos::RCP< OptDualStdVector< Real > > dual_vec_
void scale(const Real alpha)
Compute where .
OptStdVector(const Teuchos::RCP< std::vector< Element > > &std_vec)
const ROL::Vector< Real > & dual() const
Return dual representation of , for example, the result of applying a Riesz map, or change of basis...
Teuchos::RCP< ROL::Vector< Real > > clone() const
Clone to make a new (uninitialized) vector.
const ROL::Vector< Real > & dual() const
Return dual representation of , for example, the result of applying a Riesz map, or change of basis...
const ROL::Vector< Real > & dual() const
Return dual representation of , for example, the result of applying a Riesz map, or change of basis...
ConStdVector(const Teuchos::RCP< std::vector< Element > > &std_vec)
Real dot(const ROL::Vector< Real > &x) const
Compute where .
Real norm() const
Returns where .
Teuchos::RCP< std::vector< Element > > getVector()
Teuchos::RCP< std::vector< Element > > getVector()
Teuchos::RCP< const std::vector< Element > > getVector() const
Teuchos::RCP< ROL::Vector< Real > > basis(const int i) const
Return i-th basis vector.
Teuchos::RCP< OptStdVector< Real > > dual_vec_
Teuchos::RCP< std::vector< Element > > std_vec_
virtual void zero()
Set to zero vector.
Definition: ROL_Vector.hpp:157
const ROL::Vector< Real > & dual() const
Return dual representation of , for example, the result of applying a Riesz map, or change of basis...
Defines the linear algebra or vector space interface.
Definition: ROL_Vector.hpp:74
void plus(const ROL::Vector< Real > &x)
Compute , where .
Teuchos::RCP< ConDualStdVector< Real > > dual_vec_
Teuchos::RCP< ROL::Vector< Real > > basis(const int i) const
Return i-th basis vector.
int dimension() const
Return dimension of the vector space.
OptDualStdVector(const Teuchos::RCP< std::vector< Element > > &std_vec)
void scale(const Real alpha)
Compute where .
void scale(const Real alpha)
Compute where .
Real norm() const
Returns where .
Teuchos::RCP< const std::vector< Element > > getVector() const
Teuchos::RCP< ROL::Vector< Real > > basis(const int i) const
Return i-th basis vector.
Provides an interface to run optimization algorithms.
Teuchos::RCP< ROL::Vector< Real > > clone() const
Clone to make a new (uninitialized) vector.
Real dot(const ROL::Vector< Real > &x) const
Compute where .
Contains definitions for the equality constrained NLP from Nocedal/Wright, 2nd edition, page 574, example 18.2; note the typo in reversing the initial guess and the solution.
int dimension() const
Return dimension of the vector space.
Teuchos::RCP< std::vector< Element > > std_vec_
Teuchos::RCP< const std::vector< Element > > getVector() const
int dimension() const
Return dimension of the vector space.
Teuchos::RCP< ROL::Vector< Real > > clone() const
Clone to make a new (uninitialized) vector.
ConDualStdVector(const Teuchos::RCP< std::vector< Element > > &std_vec)
virtual std::vector< std::string > run(Vector< Real > &x, Objective< Real > &obj, bool print=false, std::ostream &outStream=std::cout)
Run algorithm on unconstrained problems (Type-U). This is the primary Type-U interface.
Teuchos::RCP< ConStdVector< Real > > dual_vec_
Teuchos::RCP< std::vector< Element > > getVector()
double RealT
Real dot(const ROL::Vector< Real > &x) const
Compute where .
void plus(const ROL::Vector< Real > &x)
Compute , where .
int main(int argc, char *argv[])
Teuchos::RCP< std::vector< Element > > std_vec_
Real dot(const ROL::Vector< Real > &x) const
Compute where .
void plus(const ROL::Vector< Real > &x)
Compute , where .
void plus(const ROL::Vector< Real > &x)
Compute , where .
Teuchos::RCP< ROL::Vector< Real > > basis(const int i) const
Return i-th basis vector.
Teuchos::RCP< std::vector< Element > > getVector()
Teuchos::RCP< const std::vector< Element > > getVector() const
void scale(const Real alpha)
Compute where .
int dimension() const
Return dimension of the vector space.
Teuchos::RCP< ROL::Vector< Real > > clone() const
Clone to make a new (uninitialized) vector.