MOOCHO (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MoochoPack_MoochoThyraSolver.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ***********************************************************************
3 //
4 // Moocho: Multi-functional Object-Oriented arCHitecture for Optimization
5 // Copyright (2003) 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 Roscoe A. Bartlett (rabartl@sandia.gov)
38 //
39 // ***********************************************************************
40 // @HEADER
41 
42 #ifndef MOOCHOPACK_MOOCHO_THYRA_SOLVER_HPP
43 #define MOOCHOPACK_MOOCHO_THYRA_SOLVER_HPP
44 
46 #include "Thyra_ModelEvaluator.hpp"
47 #include "Thyra_DirectionalFiniteDiffCalculator.hpp"
48 #include "Thyra_DefaultNominalBoundsOverrideModelEvaluator.hpp"
49 #include "Thyra_DefaultFinalPointCaptureModelEvaluator.hpp"
50 #include "Thyra_MultiVectorFileIOBase.hpp"
51 #include "Thyra_ParameterDrivenMultiVectorInput.hpp"
53 
54 namespace MoochoPack {
55 
57 using Teuchos::RCP;
58 
84  : virtual public Teuchos::ParameterListAcceptor
85 {
86 public:
87 
90 
92  enum ESolveMode {
95  };
96 
98 
101 
110  const std::string &paramsXmlFileName = ""
111  ,const std::string &extraParamsXmlString = ""
112  ,const std::string &paramsUsedXmlOutFileName = ""
113  ,const std::string &paramsXmlFileNameOption = "moocho-thyra-params-file"
114  ,const std::string &extraParamsXmlStringOption = "extra-moocho-thyra-params"
115  ,const std::string &paramsUsedXmlOutFileNameOption = "moocho-thyra-params-used-file"
116  );
117 
120 
124  STANDARD_MEMBER_COMPOSITION_MEMBERS(std::string,paramsXmlFileName);
125 
129  STANDARD_MEMBER_COMPOSITION_MEMBERS(std::string,extraParamsXmlString);
130 
134  STANDARD_MEMBER_COMPOSITION_MEMBERS(std::string,paramsUsedXmlOutFileName);
135 
139  STANDARD_MEMBER_COMPOSITION_MEMBERS(std::string,paramsXmlFileNameOption);
140 
144  STANDARD_MEMBER_COMPOSITION_MEMBERS(std::string,extraParamsXmlStringOption);
145 
149  STANDARD_MEMBER_COMPOSITION_MEMBERS(std::string,paramsUsedXmlOutFileNameOption);
150 
159  STANDARD_NONCONST_COMPOSITION_MEMBERS( Thyra::MultiVectorFileIOBase<value_type>, stateVectorIO );
160 
173  STANDARD_NONCONST_COMPOSITION_MEMBERS( Thyra::MultiVectorFileIOBase<value_type>, parameterVectorIO );
174 
183  void setupCLP(
185  );
186 
206  void readParameters( std::ostream *out );
207 
209 
212 
214  void setParameterList(RCP<Teuchos::ParameterList> const& paramList);
223 
225 
227  //@
228 
230  void setSolveMode( const ESolveMode solveMode );
231 
233  ESolveMode getSolveMode() const;
234 
237 
239  const MoochoSolver& getSolver() const;
240 
242 
245 
247  void setModel(
248  const RCP<Thyra::ModelEvaluator<value_type> > &origModel,
249  const int p_idx = 0,
250  const int g_idx = 0
251  );
252 
255  getOrigModel() const;
256 
259  getOuterModel() const;
260 
262  void readInitialGuess(
263  std::ostream *out = NULL
264  );
265 
267  void setInitialGuess(
268  const RCP<const Thyra::ModelEvaluatorBase::InArgs<value_type> > &initialGuess
269  );
270 
272  void setInitialGuess(
273  const Thyra::ModelEvaluatorBase::InArgs<value_type> &initialGuess
274  );
275 
278 
280  const Thyra::ModelEvaluatorBase::InArgs<value_type>& getFinalPoint() const;
281 
285  void writeFinalSolution(
286  std::ostream *out = NULL
287  ) const;
288 
303  void writeParamsFile(
304  const std::string &outputXmlFileName = ""
305  ) const;
306 
308 
309 public:
310 
311  // I am just making these public so that I can access them from
312  // the anonymous namespace in the *.cpp file
314 
315 private:
316 
318 
320 
322  int p_idx_;
323  int g_idx_;
324 
325  mutable Thyra::ParameterDrivenMultiVectorInput<value_type> x_reader_;
326  mutable Thyra::ParameterDrivenMultiVectorInput<value_type> p_reader_;
327  mutable Thyra::ParameterDrivenMultiVectorInput<value_type> p_l_reader_;
328  mutable Thyra::ParameterDrivenMultiVectorInput<value_type> p_u_reader_;
329 
331 
334 
337 
339 
351  std::string outputFileTag_;
353  std::string stateSoluFileBase_;
354  std::string paramSoluFileBase_;
355 
356 };
357 
358 } // namespace MoochoPack
359 
360 #endif // MOOCHOPACK_MOOCHO_THYRA_SOLVER_HPP
void setParameterList(RCP< Teuchos::ParameterList > const &paramList)
RCP< Teuchos::ParameterList > unsetParameterList()
const RCP< Thyra::ModelEvaluator< value_type > > getOrigModel() const
void readParameters(std::ostream *out)
Force the parameters to be read from a file or from the commandline arguments.
Thyra::ParameterDrivenMultiVectorInput< value_type > x_reader_
RCP< Thyra::ModelEvaluator< value_type > > outerModel_
void setupCLP(Teuchos::CommandLineProcessor *clp)
Sets up the commandline for reading in the parameter list for this object (minus the options for Mooc...
RCP< Teuchos::ParameterList > paramList_
RCP< const Teuchos::ParameterList > getValidParameters() const
MoochoThyraSolver(const std::string &paramsXmlFileName="", const std::string &extraParamsXmlString="", const std::string &paramsUsedXmlOutFileName="", const std::string &paramsXmlFileNameOption="moocho-thyra-params-file", const std::string &extraParamsXmlStringOption="extra-moocho-thyra-params", const std::string &paramsUsedXmlOutFileNameOption="moocho-thyra-params-used-file")
Construct with default settings.
MOOCHO NLP Solver class for models represented through Thyra::ModelEvaluator.
MoochoSolver::ESolutionStatus solve()
RCP< Thyra::DefaultFinalPointCaptureModelEvaluator< value_type > > finalPointModel_
const RCP< Thyra::ModelEvaluator< value_type > > getOuterModel() const
Thyra::ParameterDrivenMultiVectorInput< value_type > p_reader_
void writeFinalSolution(std::ostream *out=NULL) const
Write the final solution to a file specified by the parameter list option ???.
RCP< Teuchos::ParameterList > getNonconstParameterList()
std::ostream * out
STANDARD_NONCONST_COMPOSITION_MEMBERS(Thyra::MultiVectorFileIOBase< value_type >, stateVectorIO)
MultiVectorFileIOBase object used to read and write state vectors to and from files.
RCP< Thyra::ModelEvaluator< value_type > > origModel_
void setSolveMode(const ESolveMode solveMode)
Universal interface to a MOOCHO solver.
void writeParamsFile(const std::string &outputXmlFileName="") const
Write the parameters list for a this object to a file after the parameters are read in order to show ...
Solve an optimization problem for states and parameters.
void setModel(const RCP< Thyra::ModelEvaluator< value_type > > &origModel, const int p_idx=0, const int g_idx=0)
RCP< Thyra::DefaultNominalBoundsOverrideModelEvaluator< value_type > > nominalModel_
const Thyra::ModelEvaluatorBase::InArgs< value_type > & getFinalPoint() const
Return the final point.
void readInitialGuess(std::ostream *out=NULL)
AbstractLinAlgPack::value_type value_type
RCP< const Teuchos::ParameterList > getParameterList() const
Thyra::ParameterDrivenMultiVectorInput< value_type > p_u_reader_
STANDARD_MEMBER_COMPOSITION_MEMBERS(std::string, paramsXmlFileName)
The name an XML file that will be read to get XML parameters (if not "").
void setInitialGuess(const RCP< const Thyra::ModelEvaluatorBase::InArgs< value_type > > &initialGuess)
Thyra::ParameterDrivenMultiVectorInput< value_type > p_l_reader_