SundanceModelEvaluatorBase.hpp
Go to the documentation of this file.
00001 /* @HEADER@ */
00002 // ************************************************************************
00003 // 
00004 //                              Sundance
00005 //                 Copyright (2005) Sandia Corporation
00006 // 
00007 // Copyright (year first published) Sandia Corporation.  Under the terms 
00008 // of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government 
00009 // retains certain rights in this software.
00010 // 
00011 // This library is free software; you can redistribute it and/or modify
00012 // it under the terms of the GNU Lesser General Public License as
00013 // published by the Free Software Foundation; either version 2.1 of the
00014 // License, or (at your option) any later version.
00015 //  
00016 // This library is distributed in the hope that it will be useful, but
00017 // WITHOUT ANY WARRANTY; without even the implied warranty of
00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00019 // Lesser General Public License for more details.
00020 //                                                                                 
00021 // You should have received a copy of the GNU Lesser General Public
00022 // License along with this library; if not, write to the Free Software
00023 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00024 // USA                                                                                
00025 // Questions? Contact Kevin Long (krlong@sandia.gov), 
00026 // Sandia National Laboratories, Livermore, California, USA
00027 // 
00028 // ************************************************************************
00029 /* @HEADER@ */
00030 
00031 #ifndef SUNDANCE_SUNDANCEMODELEVALUATORBASE_H
00032 #define SUNDANCE_SUNDANCEMODELEVALUATORBASE_H
00033 
00034 #include "SundanceDefs.hpp"
00035 
00036 #ifdef HAVE_SUNDANCE_MOOCHO
00037 
00038 #include "Sundance.hpp"
00039 #include "Thyra_StateFuncModelEvaluatorBase.hpp"
00040 
00041 namespace Thyra
00042 {
00043   using namespace Sundance;
00044   using namespace Sundance;
00045   using namespace Sundance;
00046   using namespace Sundance;
00047   using namespace Sundance;
00048   using namespace Teuchos;
00049 
00050   /** 
00051    * 
00052    */
00053   class SundanceModelEvaluator : public StateFuncModelEvaluatorBase<double>,
00054                                  public ObjectWithClassVerbosity<SundanceModelEvaluator>
00055   {
00056   public:
00057     /** */
00058     SundanceModelEvaluator(const VectorType<double>& vecType);
00059 
00060     /** */
00061     virtual ~SundanceModelEvaluator() {;}
00062 
00063     /** Get the space of state variables */
00064     RCP<const VectorSpaceBase<double> > get_x_space() const 
00065     {return stateSpace().ptr();}
00066 
00067     /** Get the range space of the constraints */
00068     RCP<const VectorSpaceBase<double> > get_f_space() const 
00069     {return constraintSpace().ptr();}
00070 
00071     /** Get the space of model parameters */
00072     RCP<const VectorSpaceBase<double> > get_p_space(int i) const 
00073     {
00074       TEST_FOR_EXCEPTION(i != 0, RuntimeError, "invalid index for parameter space");
00075       return paramSpace().ptr();
00076     }
00077 
00078     /** Get the range space of the objective function */
00079     RCP<const VectorSpaceBase<double> > get_g_space(int i) const 
00080     {
00081       TEST_FOR_EXCEPTION(i != 0, RuntimeError, "invalid index for objective space");
00082       return objectiveSpace_.ptr();
00083     }
00084 
00085     /** Get an initial guess for the variables */
00086     InArgs<double> getNominalValues() const;
00087 
00088     /** Create an object for df/dx */
00089     RCP<LinearOpBase<double> > create_W_op() const 
00090     {return createW().ptr();}
00091 
00092     /** Create a container for the input arguments */
00093     InArgs<double> createInArgs() const ;
00094 
00095     /** Create a container for the output arguments */
00096     OutArgs<double> createOutArgsImpl() const ;
00097 
00098     /** Wrapper to convert the Thyra arguments to/from Sundance arguments */
00099     void evalModelImpl(const InArgs<double>& inArgs,
00100       const OutArgs<double>& outArgs) const ;
00101 
00102 
00103     /** Run the model  */
00104     virtual void internalEvalModel(const Vector<double>& stateVec,
00105                                    const Vector<double>& params,
00106                                    Vector<double>& resid,
00107                                    double& objFuncVal,
00108                                    LinearOperator<double>& df_dx,
00109                                    Array<Vector<double> >& df_dp,
00110                                    Vector<double>& dg_dp_T,
00111                                    Vector<double>& dg_dx_T) const = 0 ;
00112                                    
00113     /** */
00114     virtual VectorSpace<double> paramSpace() const = 0;        
00115            
00116     /** */
00117     virtual VectorSpace<double> stateSpace() const = 0;   
00118                                    
00119     /** */
00120     virtual Vector<double> getInitialState() const = 0;        
00121            
00122     /** */
00123     virtual Vector<double> getInitialParameters() const = 0;   
00124            
00125     /** */
00126     virtual VectorSpace<double> constraintSpace() const = 0;
00127            
00128     /** */
00129     virtual VectorSpace<double> objectiveSpace() const {return objectiveSpace_;}
00130 
00131     /** */
00132     virtual LinearOperator<double> createW() const = 0;
00133 
00134     /** */
00135     const VectorType<double>& vecType() const {return vecType_;}
00136 
00137     
00138 
00139   private:
00140     VectorType<double> vecType_;
00141     VectorSpace<double> objectiveSpace_;
00142 
00143   };
00144     
00145 }
00146 
00147 
00148 #endif
00149 
00150 #endif

Site Contact