ROL
ROL_GetTestProblems.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 
49 #ifndef ROL_TESTOBJECTIVES_HPP
50 #define ROL_TESTOBJECTIVES_HPP
51 
52 
53 #include "ROL_Rosenbrock.hpp"
54 #include "ROL_FreudensteinRoth.hpp"
55 #include "ROL_Beale.hpp"
56 #include "ROL_Powell.hpp"
57 #include "ROL_SumOfSquares.hpp"
58 #include "ROL_LeastSquares.hpp"
59 #include "ROL_PoissonControl.hpp"
60 #include "ROL_PoissonInversion.hpp"
61 #include "ROL_Zakharov.hpp"
62 #include "ROL_HS1.hpp"
63 #include "ROL_HS2.hpp"
64 #include "ROL_HS3.hpp"
65 #include "ROL_HS4.hpp"
66 #include "ROL_HS5.hpp"
67 #include "ROL_HS24.hpp"
68 #include "ROL_HS25.hpp"
69 #include "ROL_HS29.hpp"
70 #include "ROL_HS32.hpp"
71 #include "ROL_HS38.hpp"
72 #include "ROL_HS39.hpp"
73 #include "ROL_HS45.hpp"
74 #include "ROL_BVP.hpp"
75 #include "ROL_ParaboloidCircle.hpp"
77 #include "ROL_CantileverBeam.hpp"
78 #include "ROL_Cubic.hpp"
79 #include "ROL_Quartic.hpp"
80 #include "ROL_CylinderHead.hpp"
81 #include "ROL_Cantilever.hpp"
82 #include "ROL_Minimax1.hpp"
83 #include "ROL_Minimax2.hpp"
84 #include "ROL_Minimax3.hpp"
85 
86 
87 namespace ROL {
88 
159  };
160 
161  inline std::string ETestOptProblemToString(ETestOptProblem to) {
162  std::string retString;
163  switch(to) {
164  case TESTOPTPROBLEM_ROSENBROCK: retString = "Rosenbrock's Function"; break;
165  case TESTOPTPROBLEM_FREUDENSTEINANDROTH: retString = "Freudenstein and Roth's Function"; break;
166  case TESTOPTPROBLEM_BEALE: retString = "Beale's Function"; break;
167  case TESTOPTPROBLEM_POWELL: retString = "Powell's Badly Scaled Function"; break;
168  case TESTOPTPROBLEM_SUMOFSQUARES: retString = "Sum of Squares Function"; break;
169  case TESTOPTPROBLEM_LEASTSQUARES: retString = "Least Squares Function"; break;
170  case TESTOPTPROBLEM_POISSONCONTROL: retString = "Poisson Optimal Control"; break;
171  case TESTOPTPROBLEM_POISSONINVERSION: retString = "Poisson Inversion Problem"; break;
172  case TESTOPTPROBLEM_ZAKHAROV: retString = "Zakharov's Function"; break;
173  case TESTOPTPROBLEM_HS1: retString = "Hock and Schittkowski Test Problem #1"; break;
174  case TESTOPTPROBLEM_HS2: retString = "Hock and Schittkowski Test Problem #2"; break;
175  case TESTOPTPROBLEM_HS3: retString = "Hock and Schittkowski Test Problem #3"; break;
176  case TESTOPTPROBLEM_HS4: retString = "Hock and Schittkowski Test Problem #4"; break;
177  case TESTOPTPROBLEM_HS5: retString = "Hock and Schittkowski Test Problem #5"; break;
178  case TESTOPTPROBLEM_HS24: retString = "Hock and Schittkowski Test Problem #24"; break;
179  case TESTOPTPROBLEM_HS25: retString = "Hock and Schittkowski Test Problem #25"; break;
180  case TESTOPTPROBLEM_HS29: retString = "Hock and Schittkowski Test Problem #29"; break;
181  case TESTOPTPROBLEM_HS32: retString = "Hock and Schittkowski Test Problem #32"; break;
182  case TESTOPTPROBLEM_HS38: retString = "Hock and Schittkowski Test Problem #38"; break;
183  case TESTOPTPROBLEM_HS39: retString = "Hock and Schittkowski Test Problem #39"; break;
184  case TESTOPTPROBLEM_HS45: retString = "Hock and Schittkowski Test Problem #45"; break;
185  case TESTOPTPROBLEM_BVP: retString = "Boundary Value Problem"; break;
186  case TESTOPTPROBLEM_PARABOLOIDCIRCLE: retString = "Paraboloid Circle"; break;
187  case TESTOPTPROBLEM_SIMPLEEQCONSTRAINED: retString = "Simple Equality Constrained"; break;
188  case TESTOPTPROBLEM_CANTILEVERBEAM: retString = "Cantilever Beam"; break;
189  case TESTOPTPROBLEM_CUBIC: retString = "Cubic"; break;
190  case TESTOPTPROBLEM_QUARTIC: retString = "Quartic"; break;
191  case TESTOPTPROBLEM_CYLINDERHEAD: retString = "Cylinder Head"; break;
192  case TESTOPTPROBLEM_CANTILEVER: retString = "Cantilever"; break;
193  case TESTOPTPROBLEM_MINIMAX1: retString = "Minimax #1"; break;
194  case TESTOPTPROBLEM_MINIMAX2: retString = "Minimax #2"; break;
195  case TESTOPTPROBLEM_MINIMAX3: retString = "Minimax #3"; break;
196  case TESTOPTPROBLEM_LAST: retString = "Last Type (Dummy)"; break;
197  default: retString = "INVALID ETestOptProblem";
198  }
199  return retString;
200  }
201 
208  return( (to == TESTOPTPROBLEM_ROSENBROCK) ||
210  (to == TESTOPTPROBLEM_BEALE) ||
211  (to == TESTOPTPROBLEM_POWELL) ||
212  (to == TESTOPTPROBLEM_SUMOFSQUARES) ||
213  (to == TESTOPTPROBLEM_LEASTSQUARES) ||
216  (to == TESTOPTPROBLEM_ZAKHAROV) ||
217  (to == TESTOPTPROBLEM_HS1) ||
218  (to == TESTOPTPROBLEM_HS2) ||
219  (to == TESTOPTPROBLEM_HS3) ||
220  (to == TESTOPTPROBLEM_HS4) ||
221  (to == TESTOPTPROBLEM_HS5) ||
222  (to == TESTOPTPROBLEM_HS24) ||
223  (to == TESTOPTPROBLEM_HS25) ||
224  (to == TESTOPTPROBLEM_HS29) ||
225  (to == TESTOPTPROBLEM_HS32) ||
226  (to == TESTOPTPROBLEM_HS38) ||
227  (to == TESTOPTPROBLEM_HS39) ||
228  (to == TESTOPTPROBLEM_HS45) ||
229  (to == TESTOPTPROBLEM_BVP) ||
233  (to == TESTOPTPROBLEM_CUBIC) ||
234  (to == TESTOPTPROBLEM_QUARTIC) ||
235  (to == TESTOPTPROBLEM_CYLINDERHEAD) ||
236  (to == TESTOPTPROBLEM_CANTILEVER) ||
237  (to == TESTOPTPROBLEM_MINIMAX1) ||
238  (to == TESTOPTPROBLEM_MINIMAX2) ||
239  (to == TESTOPTPROBLEM_MINIMAX3) );
240  }
241 
243  return type = static_cast<ETestOptProblem>(type+1);
244  }
245 
247  ETestOptProblem oldval = type;
248  ++type;
249  return oldval;
250  }
251 
253  return type = static_cast<ETestOptProblem>(type-1);
254  }
255 
257  ETestOptProblem oldval = type;
258  --type;
259  return oldval;
260  }
261 
262  inline ETestOptProblem StringToETestOptProblem(std::string s) {
263  s = removeStringFormat(s);
265  if ( !s.compare(removeStringFormat(ETestOptProblemToString(to))) ) {
266  return to;
267  }
268  }
270  }
271 
272  template<class Real>
274  Ptr<Vector<Real> > &x0,
275  std::vector<Ptr<Vector<Real> > > &x,
276  const ETestOptProblem test ) {
277  Ptr<TestProblem<Real>> tp;
278  switch (test) {
279  case TESTOPTPROBLEM_ROSENBROCK: tp = makePtr<ZOO::getRosenbrock<Real>>(); break;
280  case TESTOPTPROBLEM_FREUDENSTEINANDROTH: tp = makePtr<ZOO::getFreudensteinRoth<Real>>(); break;
281  case TESTOPTPROBLEM_BEALE: tp = makePtr<ZOO::getBeale<Real>>(); break;
282  case TESTOPTPROBLEM_POWELL: tp = makePtr<ZOO::getPowell<Real>>(); break;
283  case TESTOPTPROBLEM_SUMOFSQUARES: tp = makePtr<ZOO::getSumOfSquares<Real>>(); break;
284  case TESTOPTPROBLEM_LEASTSQUARES: tp = makePtr<ZOO::getLeastSquares<Real>>(); break;
285  case TESTOPTPROBLEM_POISSONCONTROL: tp = makePtr<ZOO::getPoissonControl<Real>>(); break;
286  case TESTOPTPROBLEM_POISSONINVERSION: tp = makePtr<ZOO::getPoissonInversion<Real>>(); break;
287  case TESTOPTPROBLEM_ZAKHAROV: tp = makePtr<ZOO::getZakharov<Real>>(); break;
288  case TESTOPTPROBLEM_HS1: tp = makePtr<ZOO::getHS1<Real>>(); break;
289  case TESTOPTPROBLEM_HS2: tp = makePtr<ZOO::getHS2<Real>>(); break;
290  case TESTOPTPROBLEM_HS3: tp = makePtr<ZOO::getHS3<Real>>(); break;
291  case TESTOPTPROBLEM_HS4: tp = makePtr<ZOO::getHS4<Real>>(); break;
292  case TESTOPTPROBLEM_HS5: tp = makePtr<ZOO::getHS5<Real>>(); break;
293  case TESTOPTPROBLEM_HS24: tp = makePtr<ZOO::getHS24<Real>>(); break;
294  case TESTOPTPROBLEM_HS25: tp = makePtr<ZOO::getHS25<Real>>(); break;
295  case TESTOPTPROBLEM_HS29: tp = makePtr<ZOO::getHS29<Real>>(); break;
296  case TESTOPTPROBLEM_HS32: tp = makePtr<ZOO::getHS32<Real>>(); break;
297  case TESTOPTPROBLEM_HS38: tp = makePtr<ZOO::getHS38<Real>>(); break;
298  case TESTOPTPROBLEM_HS39: tp = makePtr<ZOO::getHS39<Real>>(); break;
299  case TESTOPTPROBLEM_HS45: tp = makePtr<ZOO::getHS45<Real>>(); break;
300  case TESTOPTPROBLEM_BVP: tp = makePtr<ZOO::getBVP<Real>>(); break;
301  case TESTOPTPROBLEM_PARABOLOIDCIRCLE: tp = makePtr<ZOO::getParaboloidCircle<Real>>(); break;
302  case TESTOPTPROBLEM_SIMPLEEQCONSTRAINED: tp = makePtr<ZOO::getSimpleEqConstrained<Real>>(); break;
303  case TESTOPTPROBLEM_CANTILEVERBEAM: tp = makePtr<ZOO::getCantileverBeam<Real>>(); break;
304  case TESTOPTPROBLEM_CUBIC: tp = makePtr<ZOO::getCubic<Real>>(2); break;
305  case TESTOPTPROBLEM_QUARTIC: tp = makePtr<ZOO::getQuartic<Real>>(); break;
306  case TESTOPTPROBLEM_CYLINDERHEAD: tp = makePtr<ZOO::getCylinderHead<Real>>(); break;
307  case TESTOPTPROBLEM_CANTILEVER: tp = makePtr<ZOO::getCantilever<Real>>(); break;
308  case TESTOPTPROBLEM_MINIMAX1: tp = makePtr<ZOO::getMinimax1<Real>>(); break;
309  case TESTOPTPROBLEM_MINIMAX2: tp = makePtr<ZOO::getMinimax1<Real>>(); break;
310  case TESTOPTPROBLEM_MINIMAX3: tp = makePtr<ZOO::getMinimax1<Real>>(); break;
311  case TESTOPTPROBLEM_LAST: break;
312  }
313  tp->get(problem,x0,x);
314  }
315 } // namespace ROL
316 
317 #endif
ETestOptProblem
Enumeration of test optimization problems.
Contains definitions for W. Hock and K. Schittkowski 38th test function.
Contains definitions for W. Hock and K. Schittkowski 32nd test problem which contains only inequality...
Contains definitions for a cubic test problem.
std::string removeStringFormat(std::string s)
Definition: ROL_Types.hpp:247
Contains definitions for Poisson optimal control.
Contains definitions for the cylinder head test problem.
Contains definitions for W. Hock and K. Schittkowski 25th test function.
int isValidTestOptProblem(ETestOptProblem to)
Verifies validity of a TestOptProblem enum.
Contains definitions for Beale&#39;s function.
Contains definitions for Rosenbrock&#39;s function.
Defines the linear algebra or vector space interface.
Definition: ROL_Vector.hpp:80
void GetTestProblem(Ptr< OptimizationProblem< Real > > &problem, Ptr< Vector< Real > > &x0, std::vector< Ptr< Vector< Real > > > &x, const ETestOptProblem test)
Contains definitions for Cantilevered Beam example in G. N. Vanderplaats, Numerical Optimization Tech...
Contains definitions for W. Hock and K. Schittkowski 4th test function.
Contains definitions for Poisson material inversion.
Contains definitions for W. Hock and K. Schittkowski 39th test function.
Contains definitions for Freudenstein and Roth&#39;s function.
Contains definitions for a quartic test problem.
Contains definitions for the cylinder head test problem.
std::string ETestOptProblemToString(ETestOptProblem to)
Contains definitions for least squares function.
Contains definitions for Powell&#39;s badly scaled function.
ETrustRegion & operator--(ETrustRegion &type)
Contains definitions for the Zakharov function as evaluated using only the ROL::Vector interface...
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.
Contains definitions for W. Hock and K. Schittkowski 24th test problem which contains bound and inequ...
Contains definitions for the discrete boundary value problem (More, Garbow, Hillstrom, 1981).
Contains definitions for W. Hock and K. Schittkowski 1st test function.
Contains definitions for W. Hock and K. Schittkowski 32nd test problem which contains both inequality...
Contains definitions for W. Hock and K. Schittkowski 3rd test function.
Contains definitions for W. Hock and K. Schittkowski 5th test function.
Contains definitions for W. Hock and K. Schittkowski 45th test function.
ETrustRegion & operator++(ETrustRegion &type)
ETestOptProblem StringToETestOptProblem(std::string s)
Contains definitions for W. Hock and K. Schittkowski 2nd test function.
Contains definitions for sum of squares function.
Contains definitions for the equality constrained NLP: