45 #include "Teuchos_ScalarTraits.hpp"
46 #include "Epetra_SerialComm.h"
47 #include "Epetra_CrsMatrix.h"
50 # include "Epetra_MpiComm.h"
52 # include "Epetra_SerialComm.h"
57 inline double sqr(
const double& s ) {
return s*s; }
72 :xt0_(xt0),xt1_(xt1),pt0_(pt0),pt1_(pt1),d_(d),
73 isInitialized_(false),supportDerivs_(true)
79 const int nx = 2, np = 2, ng = 1;
81 map_x_ = rcp(
new Epetra_Map(nx,0,*epetra_comm_));
82 map_p_ = rcp(
new Epetra_Map(np,0,*epetra_comm_));
83 map_g_ = rcp(
new Epetra_Map(ng,0,*epetra_comm_));
86 const double inf = 1e+50;
90 x0_ = rcp(
new Epetra_Vector(*map_x_)); (*x0_)[0] = x00; (*x0_)[1] = x01;
93 p0_ = rcp(
new Epetra_Vector(*map_p_)); (*p0_)[0] = p00; (*p0_)[1] = p01;
100 int indices[nx] = { 0, 1 };
101 for(
int i = 0; i < nx; ++i )
102 W_graph_->InsertGlobalIndices(i,nx,indices);
104 W_graph_->FillComplete();
106 isInitialized_ =
true;
113 supportDerivs_ = supportDerivs;
118 double pL0,
double pL1,
double pU0,
double pU1
128 double xL0,
double xL1,
double xU0,
double xU1
139 Teuchos::RCP<const Epetra_Map>
145 Teuchos::RCP<const Epetra_Map>
151 Teuchos::RCP<const Epetra_Map>
154 TEUCHOS_TEST_FOR_EXCEPT(l!=0);
158 Teuchos::RCP<const Epetra_Map>
161 TEUCHOS_TEST_FOR_EXCEPT(j!=0);
165 Teuchos::RCP<const Epetra_Vector>
171 Teuchos::RCP<const Epetra_Vector>
174 TEUCHOS_TEST_FOR_EXCEPT(l!=0);
178 Teuchos::RCP<const Epetra_Vector>
184 Teuchos::RCP<const Epetra_Vector>
190 Teuchos::RCP<const Epetra_Vector>
193 TEUCHOS_TEST_FOR_EXCEPT(l!=0);
197 Teuchos::RCP<const Epetra_Vector>
200 TEUCHOS_TEST_FOR_EXCEPT(l!=0);
204 Teuchos::RCP<Epetra_Operator>
235 if (supportDerivs_) {
269 using Teuchos::dyn_cast;
270 using Teuchos::rcp_dynamic_cast;
274 Teuchos::RCP<const Epetra_Vector> p_in = inArgs.
get_p(0);
292 f[0] = x[0] + x[1]*x[1] - p[0];
293 f[1] = d_ * ( x[0]*x[0] - x[1] - p[1] );
297 g[0] = 0.5 * ( sqr(x[0]-xt0_) + sqr(x[1]-xt1_) + sqr(p[0]-pt0_) + sqr(p[1]-pt1_) );
311 values[0] = 1.0; indexes[0] = 0;
312 values[1] = 2.0*x[1]; indexes[1] = 1;
315 values[0] = 2.0*d_*x[0]; indexes[0] = 0;
316 values[1] = -d_; indexes[1] = 1;
327 DgDx_trans[0] = x[0]-xt0_;
328 DgDx_trans[1] = x[1]-xt1_;
332 DgDp_trans[0] = p[0]-pt0_;
333 DgDp_trans[1] = p[1]-pt1_;
void set_x_bounds(double xL0, double xL1, double xU0, double xU1)
Teuchos::RCP< const Epetra_Map > get_x_map() const
void set_W_properties(const DerivativeProperties &properties)
Evaluation< Epetra_Vector > get_g(int j) const
Get g(j) where 0 <= j && j < this->Ng().
void setSupports(EOutArgsMembers arg, bool supports=true)
virtual int SumIntoGlobalValues(int GlobalRow, int NumEntries, const double *Values, const int *Indices)
Teuchos::RCP< const Epetra_Map > get_f_map() const
Teuchos::RCP< Epetra_MultiVector > get_DgDp_mv(const int j, const int l, const ModelEvaluator::OutArgs &outArgs, const ModelEvaluator::EDerivativeMultiVectorOrientation mvOrientation)
void evalModel(const InArgs &inArgs, const OutArgs &outArgs) const
Teuchos::RCP< Epetra_Operator > get_W() const
void setSupports(EInArgsMembers arg, bool supports=true)
void set_p_bounds(double pL0, double pL1, double pU0, double pU1)
Teuchos::RCP< const Epetra_Map > get_p_map(int l) const
.
Teuchos::RCP< const Epetra_Vector > get_p_init(int l) const
Teuchos::RCP< const Epetra_Vector > get_p(int l) const
OutArgs createOutArgs() const
Teuchos::RCP< const Epetra_Vector > get_x_init() const
int PutScalar(double ScalarConstant)
void set_DgDp_properties(int j, int l, const DerivativeProperties &properties)
void set_DfDp_properties(int l, const DerivativeProperties &properties)
Teuchos::RCP< const Epetra_Vector > get_p_lower_bounds(int l) const
void setModelEvalDescription(const std::string &modelEvalDescription)
Teuchos::RCP< Epetra_MultiVector > get_DfDp_mv(const int l, const ModelEvaluator::OutArgs &outArgs)
InArgs createInArgs() const
Teuchos::RCP< Epetra_MultiVector > get_DgDx_mv(const int j, const ModelEvaluator::OutArgs &outArgs, const ModelEvaluator::EDerivativeMultiVectorOrientation mvOrientation)
Teuchos::RCP< const Epetra_Vector > get_p_upper_bounds(int l) const
void setModelEvalDescription(const std::string &modelEvalDescription)
void setSupportDerivs(bool supportDerivs)
Teuchos::RCP< const Epetra_Vector > get_x_upper_bounds() const
Teuchos::RCP< const Epetra_Map > get_g_map(int j) const
.
EpetraModelEval4DOpt(const double xt0=1.0, const double xt1=1.0, const double pt0=2.0, const double pt1=0.0, const double d=10.0, const double x00=1.0, const double x01=1.0, const double p00=2.0, const double p01=0.0)
void set_DgDx_properties(int j, const DerivativeProperties &properties)
Teuchos::RCP< Epetra_Operator > create_W() const
Evaluation< Epetra_Vector > get_f() const
Teuchos::RCP< const Epetra_Vector > get_x() const
Set solution vector Taylor polynomial.
Teuchos::RCP< const Epetra_Vector > get_x_lower_bounds() const
void set_Np_Ng(int Np, int Ng)