ROL
ROL_TestProblem.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 
15 #ifndef ROL_TESTPROBLEMS_HPP
16 #define ROL_TESTPROBLEMS_HPP
17 
19 
20 namespace ROL {
21 
22 template<class Real>
23 class TestProblem {
24 public:
25  virtual ~TestProblem(void) {}
26  TestProblem(void) {}
27  virtual Ptr<Objective<Real>> getObjective(void) const = 0;
28  virtual Ptr<Vector<Real>> getInitialGuess(void) const = 0;
29  virtual Ptr<Vector<Real>> getSolution(const int i = 0) const = 0;
30  virtual int getNumSolutions(void) const {
31  return 1;
32  }
33  virtual Ptr<BoundConstraint<Real>> getBoundConstraint(void) const {
34  return nullPtr;
35  }
36  virtual Ptr<Constraint<Real>> getEqualityConstraint(void) const {
37  return nullPtr;
38  }
39  virtual Ptr<Vector<Real>> getEqualityMultiplier(void) const {
40  return nullPtr;
41  }
42  virtual Ptr<Constraint<Real>> getInequalityConstraint(void) const {
43  return nullPtr;
44  }
45  virtual Ptr<Vector<Real>> getInequalityMultiplier(void) const {
46  return nullPtr;
47  }
48  virtual Ptr<BoundConstraint<Real>> getSlackBoundConstraint(void) const {
49  return nullPtr;
50  }
51 
52  void get(Ptr<OptimizationProblem<Real>> &problem,
53  Ptr<Vector<Real>> &x0,
54  std::vector<Ptr<Vector<Real>>> &x) const {
55  x0 = getInitialGuess()->clone(); x0->set(*getInitialGuess());
56  x.resize(getNumSolutions());
57  for (int i = 0; i < getNumSolutions(); ++i) {
58  x[i] = getSolution(i)->clone(); x[i]->set(*getSolution(i));
59  }
60 
61  problem = makePtr<OptimizationProblem<Real>>(getObjective(),
62  x0,
69  }
70 };
71 } // namespace ROL
72 
73 #endif
virtual ~TestProblem(void)
virtual Ptr< Vector< Real > > getEqualityMultiplier(void) const
virtual Ptr< Constraint< Real > > getEqualityConstraint(void) const
virtual Ptr< Vector< Real > > getInitialGuess(void) const =0
virtual Ptr< Vector< Real > > getSolution(const int i=0) const =0
virtual Ptr< Constraint< Real > > getInequalityConstraint(void) const
virtual int getNumSolutions(void) const
virtual Ptr< BoundConstraint< Real > > getSlackBoundConstraint(void) const
virtual Ptr< Objective< Real > > getObjective(void) const =0
virtual Ptr< Vector< Real > > getInequalityMultiplier(void) const
virtual Ptr< BoundConstraint< Real > > getBoundConstraint(void) const