Public Member Functions | |
PDEConstrainedObjBase (const Functional &lagrangian, const Array< Expr > &stateVarVals, const Array< Expr > &adjointVarVals, const Expr &designVarVal, const RCP< IterCallbackBase > &iterCallback, int verb=0) | |
PDEConstrainedObjBase (const Functional &lagrangian, const Array< Expr > &stateVarVals, const Array< Expr > &adjointVarVals, const Expr &designVarVal, int verb=0) | |
virtual | ~PDEConstrainedObjBase () |
void | evalGrad (const Vector< double > &x, double &f, Vector< double > &grad) const |
void | eval (const Vector< double > &x, double &f) const |
Vector< double > | getInit () const |
virtual void | statePostprocCallback () const |
virtual void | iterationCallback (const Vector< double > &x, int iter) const |
const Mesh & | mesh () const |
int | numFuncEvals () const |
virtual void | solveState (const Vector< double > &x) const =0 |
virtual void | solveStateAndAdjoint (const Vector< double > &x) const =0 |
virtual void | initEquations (const Array< Expr > &stateVars, const Array< Expr > &adjointVars, const Array< Array< Expr > > &fixedVarsInStateEqns, const Array< Array< Expr > > &fixedVarsInStateEqnsVals, const Array< Array< Expr > > &fixedVarsInAdjointEqns, const Array< Array< Expr > > &fixedVarsInAdjointEqnsVals)=0 |
void | setHScale (const double &H) |
double | getInvHScale () const |
const Expr & | designVar () const |
const Array< Expr > & | stateVars () const |
const Array< Expr > & | adjointVars () const |
Protected Member Functions | |
void | init (const Array< Expr > &stateVars, const Array< Expr > &adjointVars, const Expr &designVar) |
Expr & | designVarVal () const |
Expr & | stateVarVals (int i) const |
Expr & | adjointVarVals (int i) const |
const Functional & | Lagrangian () const |
Private Attributes | |
Functional | Lagrangian_ |
Expr | designVarVal_ |
Array< Expr > | stateVarVals_ |
Array< Expr > | adjointVarVals_ |
FunctionalEvaluator | fEval_ |
int | numFuncEvals_ |
int | numGradEvals_ |
double | invHScale_ |
RCP< IterCallbackBase > | iterCallback_ |
One constructs such an objective function by giving it a Lagrangian in the form of a Sundance Functional, along with a specification of which functions are to be regarded as the adjoint, state, and design variables.
Definition at line 24 of file PDEOptPDEConstrainedObjBase.hpp.
PDEConstrainedObjBase::PDEConstrainedObjBase | ( | const Functional & | lagrangian, | |
const Array< Expr > & | stateVarVals, | |||
const Array< Expr > & | adjointVarVals, | |||
const Expr & | designVarVal, | |||
const RCP< IterCallbackBase > & | iterCallback, | |||
int | verb = 0 | |||
) |
Constructor
Definition at line 32 of file PDEOptPDEConstrainedObjBase.cpp.
PDEConstrainedObjBase::PDEConstrainedObjBase | ( | const Functional & | lagrangian, | |
const Array< Expr > & | stateVarVals, | |||
const Array< Expr > & | adjointVarVals, | |||
const Expr & | designVarVal, | |||
int | verb = 0 | |||
) |
Constructor
Definition at line 13 of file PDEOptPDEConstrainedObjBase.cpp.
virtual Sundance::PDEConstrainedObjBase::~PDEConstrainedObjBase | ( | ) | [inline, virtual] |
virtual dtor
Definition at line 46 of file PDEOptPDEConstrainedObjBase.hpp.
const Array<Expr>& Sundance::PDEConstrainedObjBase::adjointVars | ( | ) | const [inline] |
Access to the adjoint variables
Definition at line 114 of file PDEOptPDEConstrainedObjBase.hpp.
References adjointVarVals_.
Referenced by Sundance::DefaultIterCallback::call().
Expr& Sundance::PDEConstrainedObjBase::adjointVarVals | ( | int | i | ) | const [inline, protected] |
Access to the adjoint variables
Definition at line 133 of file PDEOptPDEConstrainedObjBase.hpp.
References adjointVarVals_.
Referenced by Sundance::NonlinearPDEConstrainedObj::initEquations(), and Sundance::LinearPDEConstrainedObj::initEquations().
const Expr& Sundance::PDEConstrainedObjBase::designVar | ( | ) | const [inline] |
Access to the design variable
Definition at line 106 of file PDEOptPDEConstrainedObjBase.hpp.
References designVarVal_.
Referenced by Sundance::DefaultIterCallback::call().
Expr& Sundance::PDEConstrainedObjBase::designVarVal | ( | ) | const [inline, protected] |
Access to the design variable
Definition at line 125 of file PDEOptPDEConstrainedObjBase.hpp.
References designVarVal_.
Referenced by getInit(), Sundance::NonlinearPDEConstrainedObj::solveState(), and Sundance::LinearPDEConstrainedObj::solveState().
void PDEConstrainedObjBase::eval | ( | const Vector< double > & | x, | |
double & | f | |||
) | const [virtual] |
evaluate objective function without gradient.
Implements Playa::ObjectiveBase.
Definition at line 137 of file PDEOptPDEConstrainedObjBase.cpp.
References adjointVarVals_, Sundance::FunctionalEvaluator::evaluate(), fEval_, Sundance::getDiscreteFunctionVector(), numFuncEvals_, PLAYA_MSG2, Sundance::setDiscreteFunctionVector(), solveState(), Playa::ObjectWithVerbosity::verb(), and Playa::Vector< Scalar >::zero().
void PDEConstrainedObjBase::evalGrad | ( | const Vector< double > & | x, | |
double & | f, | |||
Vector< double > & | grad | |||
) | const [virtual] |
evaluate objective function and gradient
Implements Playa::ObjectiveBase.
Definition at line 117 of file PDEOptPDEConstrainedObjBase.cpp.
References Playa::Vector< Scalar >::copy(), Sundance::FunctionalEvaluator::evalGradient(), fEval_, Sundance::getDiscreteFunctionVector(), Playa::Vector< Scalar >::norm2(), numFuncEvals_, numGradEvals_, PLAYA_MSG2, PLAYA_MSG5, solveStateAndAdjoint(), and Playa::ObjectWithVerbosity::verb().
Vector< double > PDEConstrainedObjBase::getInit | ( | ) | const [virtual] |
return an initial guess for the design vector
Implements Playa::ObjectiveBase.
Definition at line 163 of file PDEOptPDEConstrainedObjBase.cpp.
References designVarVal(), and Sundance::getDiscreteFunctionVector().
double Sundance::PDEConstrainedObjBase::getInvHScale | ( | ) | const [inline, virtual] |
return an initial approximation to the scale for the inverse of the Hessian
Reimplemented from Playa::ObjectiveBase.
Definition at line 102 of file PDEOptPDEConstrainedObjBase.hpp.
References invHScale_.
void PDEConstrainedObjBase::init | ( | const Array< Expr > & | stateVars, | |
const Array< Expr > & | adjointVars, | |||
const Expr & | designVar | |||
) | [protected] |
Definition at line 52 of file PDEOptPDEConstrainedObjBase.cpp.
References adjointVarVals_, designVarVal_, Sundance::Functional::evaluator(), fEval_, initEquations(), Lagrangian_, and stateVarVals_.
Referenced by Sundance::LinearPDEConstrainedObj::LinearPDEConstrainedObj(), and Sundance::NonlinearPDEConstrainedObj::NonlinearPDEConstrainedObj().
virtual void Sundance::PDEConstrainedObjBase::initEquations | ( | const Array< Expr > & | stateVars, | |
const Array< Expr > & | adjointVars, | |||
const Array< Array< Expr > > & | fixedVarsInStateEqns, | |||
const Array< Array< Expr > > & | fixedVarsInStateEqnsVals, | |||
const Array< Array< Expr > > & | fixedVarsInAdjointEqns, | |||
const Array< Array< Expr > > & | fixedVarsInAdjointEqnsVals | |||
) | [pure virtual] |
Set up the state and adjoint equations. This is left to the derived class, because we can't know at this level whether the equations are linear or nonlinear
Implemented in Sundance::LinearPDEConstrainedObj, and Sundance::NonlinearPDEConstrainedObj.
Referenced by init().
void PDEConstrainedObjBase::iterationCallback | ( | const Vector< double > & | x, | |
int | iter | |||
) | const [virtual] |
Reimplemented from Playa::ObjectiveBase.
Definition at line 168 of file PDEOptPDEConstrainedObjBase.cpp.
References iterCallback_.
const Functional& Sundance::PDEConstrainedObjBase::Lagrangian | ( | ) | const [inline, protected] |
Definition at line 136 of file PDEOptPDEConstrainedObjBase.hpp.
References Lagrangian_.
Referenced by Sundance::NonlinearPDEConstrainedObj::initEquations(), and Sundance::LinearPDEConstrainedObj::initEquations().
const Mesh& Sundance::PDEConstrainedObjBase::mesh | ( | ) | const [inline] |
Definition at line 69 of file PDEOptPDEConstrainedObjBase.hpp.
References Lagrangian_, and Sundance::Functional::mesh().
Referenced by Sundance::DefaultIterCallback::call().
int Sundance::PDEConstrainedObjBase::numFuncEvals | ( | ) | const [inline, virtual] |
Reimplemented from Playa::ObjectiveBase.
Definition at line 72 of file PDEOptPDEConstrainedObjBase.hpp.
References numFuncEvals_.
void Sundance::PDEConstrainedObjBase::setHScale | ( | const double & | H | ) | [inline] |
Set the scale of the Hessian
Definition at line 98 of file PDEOptPDEConstrainedObjBase.hpp.
References invHScale_.
virtual void Sundance::PDEConstrainedObjBase::solveState | ( | const Vector< double > & | x | ) | const [pure virtual] |
Solve the state equations, followed by postprocessing. At the end of this call, the system is ready for evaluation of the objective function or solution of the adjoint equations.
Implemented in Sundance::LinearPDEConstrainedObj, and Sundance::NonlinearPDEConstrainedObj.
Referenced by eval().
virtual void Sundance::PDEConstrainedObjBase::solveStateAndAdjoint | ( | const Vector< double > & | x | ) | const [pure virtual] |
Solve the state equations, then do postprocessing, then finally the adjoint equations in reverse order. At the end of this call, the system is ready for evaluation of the objective function and its gradient.
Implemented in Sundance::LinearPDEConstrainedObj, and Sundance::NonlinearPDEConstrainedObj.
Referenced by evalGrad().
virtual void Sundance::PDEConstrainedObjBase::statePostprocCallback | ( | ) | const [inline, virtual] |
Hook for anything that needs to be done between the solution of the state equations and the evaluation of the functional or solution of adjoints.
Default is a no-op.
Definition at line 63 of file PDEOptPDEConstrainedObjBase.hpp.
Referenced by Sundance::NonlinearPDEConstrainedObj::solveState(), and Sundance::LinearPDEConstrainedObj::solveState().
const Array<Expr>& Sundance::PDEConstrainedObjBase::stateVars | ( | ) | const [inline] |
Access to the state variables
Definition at line 110 of file PDEOptPDEConstrainedObjBase.hpp.
References stateVarVals_.
Referenced by Sundance::DefaultIterCallback::call().
Expr& Sundance::PDEConstrainedObjBase::stateVarVals | ( | int | i | ) | const [inline, protected] |
Access to the state variables
Definition at line 129 of file PDEOptPDEConstrainedObjBase.hpp.
References stateVarVals_.
Referenced by Sundance::NonlinearPDEConstrainedObj::initEquations(), Sundance::LinearPDEConstrainedObj::initEquations(), and Sundance::LinearPDEConstrainedObj::solveState().
Array<Expr> Sundance::PDEConstrainedObjBase::adjointVarVals_ [mutable, private] |
Definition at line 146 of file PDEOptPDEConstrainedObjBase.hpp.
Referenced by adjointVars(), adjointVarVals(), eval(), and init().
Expr Sundance::PDEConstrainedObjBase::designVarVal_ [mutable, private] |
Definition at line 142 of file PDEOptPDEConstrainedObjBase.hpp.
Referenced by designVar(), designVarVal(), and init().
Definition at line 148 of file PDEOptPDEConstrainedObjBase.hpp.
Referenced by eval(), evalGrad(), and init().
double Sundance::PDEConstrainedObjBase::invHScale_ [private] |
Definition at line 154 of file PDEOptPDEConstrainedObjBase.hpp.
Referenced by getInvHScale(), and setHScale().
RCP<IterCallbackBase> Sundance::PDEConstrainedObjBase::iterCallback_ [private] |
Definition at line 140 of file PDEOptPDEConstrainedObjBase.hpp.
Referenced by init(), Lagrangian(), and mesh().
int Sundance::PDEConstrainedObjBase::numFuncEvals_ [mutable, private] |
Definition at line 150 of file PDEOptPDEConstrainedObjBase.hpp.
Referenced by eval(), evalGrad(), and numFuncEvals().
int Sundance::PDEConstrainedObjBase::numGradEvals_ [mutable, private] |
Array<Expr> Sundance::PDEConstrainedObjBase::stateVarVals_ [mutable, private] |
Definition at line 144 of file PDEOptPDEConstrainedObjBase.hpp.
Referenced by init(), stateVars(), and stateVarVals().