Debian Codegraph @

packages/nox/test/epetra/Thyra/ModelEvaluatorRosenbrock.hpp

raw
1 // @HEADER
2 // *****************************************************************************
3 // NOX: An Object-Oriented Nonlinear Solver Package
4 //
5 // Copyright 2002 NTESS and the NOX contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9
10 #ifndef NOX_THYRA_ROSENBROCK_MODEL_EVALUATOR_HPP
11 #define NOX_THYRA_ROSENBROCK_MODEL_EVALUATOR_HPP
12
13 #include "Thyra_StateFuncModelEvaluatorBase.hpp"
14
15 #include "Epetra_Map.h"
16 #include "Epetra_Vector.h"
17 #include "Epetra_Comm.h"
18 #include "Epetra_CrsGraph.h"
19
20 /** \brief ModelEvaluator for the Roesenbrock problem
21
22 This example is the "%Rosenbrock function" from Jorge J. More',
23 Burton S. Garbow, and Kenneth E. Hillstrom, Testing Unconstrained
24 Optimization Software, ACM TOMS, Vol. 7, No. 1, March 1981,
25 pp. 14-41.
26
27 It comes originally from H. H. %Rosenbrock, An Automatic Method for
28 Finding the Greatest or Least Value of a Function, J. Comput.
29 3(1960):175-184.
30
31 The function is defined as
32 \f[
33 F(x) = \left[
34 \begin{array}{c}
35 10 (x[2] - x[1]^2) \\
36 1 - x[1]
37 \end{array}
38 \right]
39 \f]
40
41 The initial guess is given by
42 \f[
43 x_0 = \left[
44 \begin{array}{c}
45 -1.2\\
46 1
47 \end{array}
48 \right]
49 \f]
50
51 The solution is
52 \f[
53 x_* = \left[
54 \begin{array}{c}
55 1\\
56 1
57 \end{array}
58 \right]
59 \f]
60 */
61 class RosenbrockModelEvaluator : public Thyra::StateFuncModelEvaluatorBase<double> {
62 public:
63
64 RosenbrockModelEvaluator(const Teuchos::RCP<const Epetra_Comm>& comm);
65
66 /** \name Public functions overridden from ModelEvaulator. */
67 //@{
68
69 Teuchos::RCP<const Thyra::VectorSpaceBase<double> > get_x_space() const;
70 Teuchos::RCP<const Thyra::VectorSpaceBase<double> > get_f_space() const;
71 Thyra::ModelEvaluatorBase::InArgs<double> getNominalValues() const;
72 Teuchos::RCP<Thyra::LinearOpBase<double> > create_W_op() const;
73 Teuchos::RCP<const Thyra::LinearOpWithSolveFactoryBase<double> > get_W_factory() const;
74 Thyra::ModelEvaluatorBase::InArgs<double> createInArgs() const;
75
76 //@}
77
78 void set_W_factory(const Teuchos::RCP<const ::Thyra::LinearOpWithSolveFactoryBase<double> >& W_factory);
79
80 Teuchos::RCP<const Epetra_Vector> get_analytic_solution() const;
81
82 private:
83
84 /** \name Private functions overridden from ModelEvaulatorDefaultBase. */
85 //@{
86
87 Thyra::ModelEvaluatorBase::OutArgs<double> createOutArgsImpl() const;
88
89 void evalModelImpl(
90 const Thyra::ModelEvaluatorBase::InArgs<double> &inArgs,
91 const Thyra::ModelEvaluatorBase::OutArgs<double> &outArgs
92 ) const;
93
94 //@}
95
96 private:
97
98 double d_;
99
100 Teuchos::RCP<const Epetra_Comm> epetra_comm_;
101
102 Teuchos::RCP<const Thyra::VectorSpaceBase<double> > x_space_;
103 Teuchos::RCP<const Epetra_Map> map_x_;
104
105 Teuchos::RCP<const Thyra::VectorSpaceBase<double> > f_space_;
106 Teuchos::RCP<const Epetra_Map> f_epetra_map_;
107
108 Teuchos::RCP<Epetra_Vector> x0_;
109 Teuchos::RCP<Epetra_Vector> x_analytic_;
110
111 Teuchos::RCP<Epetra_CrsGraph> W_graph_;
112
113 Teuchos::RCP<const Thyra::LinearOpWithSolveFactoryBase<double> > W_factory_;
114
115 mutable Thyra::ModelEvaluatorBase::InArgs<double> nominal_values_;
116 };
117
118 #endif