MOAB: Mesh Oriented datABase  (version 5.4.1)
MBMesquite::OFEvaluator Class Reference

Evaluate objective function. More...

#include <OFEvaluator.hpp>

Collaboration diagram for MBMesquite::OFEvaluator:

## Public Member Functions

OFEvaluator (ObjectiveFunction *of)
Constructor.
void initialize_queue (MeshDomainAssoc *mesh_and_domain, const Settings *settings, MsqError &err)
bool initialize (MeshDomainAssoc *mesh_and_domain, const Settings *settings, PatchSet *patches, MsqError &err)
Initialize OFEvaluator.
bool update (PatchData &pd, double &value, MsqError &err)
Update accumulated values for changes to vertex positions in a patch.
bool update (PatchData &pd, double &value, std::vector< Vector3D > &grad, MsqError &err)
Update accumulated values for changes to vertex positions in a patch.
bool update (PatchData &pd, double &value, std::vector< Vector3D > &grad, std::vector< SymMatrix3D > &Hessian_diag_blocks, MsqError &err)
Update accumulated values for changes to vertex positions in a patch.
bool update (PatchData &pd, double &value, std::vector< Vector3D > &grad, MsqHessian &Hessian, MsqError &err)
Update accumulated values for changes to vertex positions in a patch.
bool is_nash_game () const
Check if doing Nash game algorithm.
void do_nash_game ()
Do Nash game algorithm.
bool is_block_coordinate_descent () const
Check if doing block coordinate descent algorithm.
void do_block_coordinate_descent ()
Do block coordinate descent algorithm.
bool evaluate (PatchData &pd, double &value, MsqError &err) const
Evaluate the objective function without changing any accumulated values.
bool evaluate (PatchData &pd, double &value, std::vector< Vector3D > &grad, MsqError &err) const
Evaluate the objective function without changing any accumulated values.
bool evaluate (PatchData &pd, double &value, std::vector< Vector3D > &grad, std::vector< SymMatrix3D > &Hessian_diag_blocks, MsqError &err) const
Evaluate the objective function without changing any accumulated values.
bool evaluate (PatchData &pd, double &value, std::vector< Vector3D > &grad, MsqHessian &Hessian, MsqError &err) const
Evaluate the objective function without changing any accumulated values.
bool reset ()
Reset for next inner iteration.
ObjectiveFunctionget_objective_function () const
Get ObjectiveFunction pointer.
bool have_objective_function () const
Check if we have an objective function.

## Private Member Functions

OFEvaluator (const OFEvaluator &)
Disallow copying.
OFEvaluatoroperator= (const OFEvaluator &)
Disallow assignment.

## Private Attributes

ObjectiveFunction *const OF
bool doBCD
ObjectiveFunction::EvalType tempType
ObjectiveFunction::EvalType firstType
ObjectiveFunction::EvalType updateType
ObjectiveFunction::EvalType currUpdateType

## Detailed Description

Evaluate objective function.

This class handles the details of the differences between Nash and block coordinate descent methods for evaluation of the objective function, such that solvers need only interact with this interface and need not be aware of the Nash vs. BCD details.

Definition at line 58 of file OFEvaluator.hpp.

## Constructor & Destructor Documentation

 MBMesquite::OFEvaluator::OFEvaluator ( ObjectiveFunction * of )

Constructor.

Parameters:
 of The objective function (may be NULL for Laplacian-type solvers) Nash True for Nash-type solutions, false for block coordinate descent.

Definition at line 39 of file OFEvaluator.cpp.

: OF( of ), doBCD( false ) {}

 MBMesquite::OFEvaluator::OFEvaluator ( const OFEvaluator & )  [private]

Disallow copying.

## Member Function Documentation

 void MBMesquite::OFEvaluator::do_block_coordinate_descent ( )  [inline]

Do block coordinate descent algorithm.

Definition at line 193 of file OFEvaluator.hpp.

    {
doBCD = true;
}

 void MBMesquite::OFEvaluator::do_nash_game ( )  [inline]

Do Nash game algorithm.

Definition at line 181 of file OFEvaluator.hpp.

    {
doBCD = false;
}

 bool MBMesquite::OFEvaluator::evaluate ( PatchData & pd, double & value, MsqError & err ) const

Evaluate the objective function without changing any accumulated values.

Evaluate the objective function for the specified patch (or for the change to the specified patch for BCD). This method does not change any internal state or accumulated values. It is provided for FeasibleNewton and other solvers that need to obtain an OF value for some intermediate or temporary set of vertex positions.

Parameters:
 pd The mesh patch value Output, the value of the objective function.

Definition at line 143 of file OFEvaluator.cpp.

{
if( !have_objective_function() )
{
MSQ_SETERR( err )( "No ObjectiveFunction", MsqError::INVALID_STATE );
return false;
}
bool b = get_objective_function()->evaluate( tempType, pd, value, OF_FREE_EVALS_ONLY, err );
return !MSQ_CHKERR( err ) && b;
}

 bool MBMesquite::OFEvaluator::evaluate ( PatchData & pd, double & value, std::vector< Vector3D > & grad, MsqError & err ) const

Evaluate the objective function without changing any accumulated values.

Evaluate the objective function for the specified patch (or for the change to the specified patch for BCD). This method does not change any internal state or accumulated values. It is provided for FeasibleNewton and other solvers that need to obtain an OF value for some intermediate or temporary set of vertex positions.

Parameters:
 pd The mesh patch value Output, the value of the objective function. grad Output, the gradient of the objective function with respect to each FREE vertex in the patch.

Definition at line 154 of file OFEvaluator.cpp.

{
if( !have_objective_function() )
{
MSQ_SETERR( err )( "No ObjectiveFunction", MsqError::INVALID_STATE );
return false;
}
return !MSQ_CHKERR( err ) && b;
}

 bool MBMesquite::OFEvaluator::evaluate ( PatchData & pd, double & value, std::vector< Vector3D > & grad, std::vector< SymMatrix3D > & Hessian_diag_blocks, MsqError & err ) const

Evaluate the objective function without changing any accumulated values.

Evaluate the objective function for the specified patch (or for the change to the specified patch for BCD). This method does not change any internal state or accumulated values. It is provided for FeasibleNewton and other solvers that need to obtain an OF value for some intermediate or temporary set of vertex positions.

Parameters:
 pd The mesh patch value Output, the value of the objective function. grad Output, the gradient of the objective function with respect to each FREE vertex in the patch. Hessian_diag_blocks Output, 3x3 submatrices along diagonal of Hessian of objective function

Definition at line 165 of file OFEvaluator.cpp.

{
if( !have_objective_function() )
{
MSQ_SETERR( err )( "No ObjectiveFunction", MsqError::INVALID_STATE );
return false;
}
bool b = get_objective_function()->evaluate_with_Hessian_diagonal( tempType, pd, value, grad, hess_diag, err );
return !MSQ_CHKERR( err ) && b;
}

 bool MBMesquite::OFEvaluator::evaluate ( PatchData & pd, double & value, std::vector< Vector3D > & grad, MsqHessian & Hessian, MsqError & err ) const

Evaluate the objective function without changing any accumulated values.

Evaluate the objective function for the specified patch (or for the change to the specified patch for BCD). This method does not change any internal state or accumulated values. It is provided for FeasibleNewton and other solvers that need to obtain an OF value for some intermediate or temporary set of vertex positions.

Parameters:
 pd The mesh patch value Output, the value of the objective function. grad Output, the gradient of the objective function with respect to each FREE vertex in the patch. Hessian Output, the Hessian of the objective function.

Definition at line 180 of file OFEvaluator.cpp.

{
if( !have_objective_function() )
{
MSQ_SETERR( err )( "No ObjectiveFunction", MsqError::INVALID_STATE );
return false;
}
bool b = get_objective_function()->evaluate_with_Hessian( tempType, pd, value, grad, Hessian, err );
return !MSQ_CHKERR( err ) && b;
}

 ObjectiveFunction* MBMesquite::OFEvaluator::get_objective_function ( ) const [inline]

Get ObjectiveFunction pointer.

Definition at line 286 of file OFEvaluator.hpp.

    {
return this->OF;
}

 bool MBMesquite::OFEvaluator::have_objective_function ( ) const [inline]

Check if we have an objective function.

Definition at line 292 of file OFEvaluator.hpp.

Referenced by evaluate(), initialize(), MBMesquite::TerminationCriterion::reset_inner(), and update().

    {
return 0 != get_objective_function();
}

 bool MBMesquite::OFEvaluator::initialize ( MeshDomainAssoc * mesh_and_domain, const Settings * settings, PatchSet * patches, MsqError & err )

Initialize OFEvaluator.

For a Nash-type algorithm, this method will initialize some member variables. For a block coordinate descent solution, this method will calculate an initial value of the objective function for the mesh.

Parameters:
 mesh The active mesh

Definition at line 41 of file OFEvaluator.cpp.

Referenced by MBMesquite::VertexMover::loop_over_mesh().

{
if( doBCD )
{
tempType   = ObjectiveFunction::TEMPORARY;
firstType  = ObjectiveFunction::SAVE;
updateType = ObjectiveFunction::UPDATE;
}
else
{
tempType = firstType = updateType = ObjectiveFunction::CALCULATE;
}
reset();

if( !doBCD )  // Nash
return true;

if( !have_objective_function() )
{
MSQ_SETERR( err )
( "Cannot perform block coordinate descent algorithm"
" without an ObjectiveFunction",
MsqError::INVALID_STATE );
return false;
}

bool result =
get_objective_function()->initialize_block_coordinate_descent( mesh_and_domain, settings, user_set, err );
return !MSQ_CHKERR( err ) && result;
}

 void MBMesquite::OFEvaluator::initialize_queue ( MeshDomainAssoc * mesh_and_domain, const Settings * settings, MsqError & err )

Definition at line 75 of file OFEvaluator.cpp.

Referenced by MBMesquite::VertexMover::initialize_queue().

{
if( get_objective_function() ) get_objective_function()->initialize_queue( mesh_and_domain, settings, err );MSQ_ERRRTN( err );
}

 bool MBMesquite::OFEvaluator::is_block_coordinate_descent ( ) const [inline]

Check if doing block coordinate descent algorithm.

Definition at line 187 of file OFEvaluator.hpp.

    {
return doBCD;
}

 bool MBMesquite::OFEvaluator::is_nash_game ( ) const [inline]

Check if doing Nash game algorithm.

Definition at line 175 of file OFEvaluator.hpp.

    {
return !doBCD;
}

 OFEvaluator& MBMesquite::OFEvaluator::operator= ( const OFEvaluator & )  [private]

Disallow assignment.

 bool MBMesquite::OFEvaluator::reset ( )

Reset for next inner iteration.

The control code for the vertex mover is responsible for calling this method before the beginning of each inner solver iteration so the necessary internal state can be updated for the correct behavior of the first call to the update() method for block coordinate descent algorithms.

Definition at line 80 of file OFEvaluator.cpp.

References currUpdateType, and firstType.

Referenced by initialize(), and MBMesquite::VertexMover::loop_over_mesh().

{
currUpdateType = firstType;
return true;
}

 bool MBMesquite::OFEvaluator::update ( PatchData & pd, double & value, MsqError & err )

Update accumulated values for changes to vertex positions in a patch.

For a block coordinate descent solution, this method calculates the updated global objective function value for any modifications to the passed patch, as made by the solver. The change to the current patch state is considered relative to that of the previous patch passed to any of the update methods, except when the reset() method has been called by the solver to indicate that a new inner iteration is starting.

For a Nash-type solution, this method simply returns the evaluation of the objective funtion for the local patch. The behavior is identical to calling the evaluate() method.

Parameters:
 pd The mesh patch value Output, the value of the objective function.

Definition at line 86 of file OFEvaluator.cpp.

{
if( !have_objective_function() )
{
MSQ_SETERR( err )( "No ObjectiveFunction", MsqError::INVALID_STATE );
return false;
}
bool b         = get_objective_function()->evaluate( currUpdateType, pd, value, OF_FREE_EVALS_ONLY, err );
currUpdateType = updateType;
return !MSQ_CHKERR( err ) && b;
}

 bool MBMesquite::OFEvaluator::update ( PatchData & pd, double & value, std::vector< Vector3D > & grad, MsqError & err )

Update accumulated values for changes to vertex positions in a patch.

For a block coordinate descent solution, this method calculates the updated global objective function value for any modifications to the passed patch, as made by the solver. The change to the current patch state is considered relative to that of the previous patch passed to any of the update methods, except when the reset() method has been called by the solver to indicate that a new inner iteration is starting.

For a Nash-type solution, this method simply returns the evaluation of the objective funtion for the local patch. The behavior is identical to calling the evaluate() method.

Parameters:
 pd The mesh patch value Output, the value of the objective function. grad Output, the gradient of the objective function with respect to each FREE vertex in the patch.

Definition at line 98 of file OFEvaluator.cpp.

{
if( !have_objective_function() )
{
MSQ_SETERR( err )( "No ObjectiveFunction", MsqError::INVALID_STATE );
return false;
}
currUpdateType = updateType;
return !MSQ_CHKERR( err ) && b;
}

 bool MBMesquite::OFEvaluator::update ( PatchData & pd, double & value, std::vector< Vector3D > & grad, std::vector< SymMatrix3D > & Hessian_diag_blocks, MsqError & err )

Update accumulated values for changes to vertex positions in a patch.

For a block coordinate descent solution, this method calculates the updated global objective function value for any modifications to the passed patch, as made by the solver. The change to the current patch state is considered relative to that of the previous patch passed to any of the update methods, except when the reset() method has been called by the solver to indicate that a new inner iteration is starting.

For a Nash-type solution, this method simply returns the evaluation of the objective funtion for the local patch. The behavior is identical to calling the evaluate() method.

Parameters:
 pd The mesh patch value Output, the value of the objective function. grad Output, the gradient of the objective function with respect to each FREE vertex in the patch. Hessian_diag_blocks Output, 3x3 submatrices along diagonal of Hessian of objective function

Definition at line 110 of file OFEvaluator.cpp.

{
if( !have_objective_function() )
{
MSQ_SETERR( err )( "No ObjectiveFunction", MsqError::INVALID_STATE );
return false;
}
bool b =
get_objective_function()->evaluate_with_Hessian_diagonal( currUpdateType, pd, value, grad, hess_diag, err );
currUpdateType = updateType;
return !MSQ_CHKERR( err ) && b;
}

 bool MBMesquite::OFEvaluator::update ( PatchData & pd, double & value, std::vector< Vector3D > & grad, MsqHessian & Hessian, MsqError & err )

Update accumulated values for changes to vertex positions in a patch.

For a block coordinate descent solution, this method calculates the updated global objective function value for any modifications to the passed patch, as made by the solver. The change to the current patch state is considered relative to that of the previous patch passed to any of the update methods, except when the reset() method has been called by the solver to indicate that a new inner iteration is starting.

For a Nash-type solution, this method simply returns the evaluation of the objective funtion for the local patch. The behavior is identical to calling the evaluate() method.

Parameters:
 pd The mesh patch value Output, the value of the objective function. grad Output, the gradient of the objective function with respect to each FREE vertex in the patch. Hessian Output, the Hessian of the objective function.

Definition at line 127 of file OFEvaluator.cpp.

{
if( !have_objective_function() )
{
MSQ_SETERR( err )( "No ObjectiveFunction", MsqError::INVALID_STATE );
return false;
}
bool b         = get_objective_function()->evaluate_with_Hessian( currUpdateType, pd, value, grad, Hessian, err );
currUpdateType = updateType;
return !MSQ_CHKERR( err ) && b;
}


## Member Data Documentation

 ObjectiveFunction::EvalType MBMesquite::OFEvaluator::currUpdateType [private]

Definition at line 311 of file OFEvaluator.hpp.

Referenced by reset(), and update().

 bool MBMesquite::OFEvaluator::doBCD [private]

Nash or BCD

Definition at line 308 of file OFEvaluator.hpp.

Referenced by initialize().

 ObjectiveFunction::EvalType MBMesquite::OFEvaluator::firstType [private]

Definition at line 311 of file OFEvaluator.hpp.

Referenced by initialize(), and reset().

 ObjectiveFunction* const MBMesquite::OFEvaluator::OF [private]

The ObjectiveFunction to evaluate

Definition at line 305 of file OFEvaluator.hpp.

 ObjectiveFunction::EvalType MBMesquite::OFEvaluator::tempType [private]

Nash vs. BCD and state of BCD data

Definition at line 311 of file OFEvaluator.hpp.

Referenced by evaluate(), and initialize().

 ObjectiveFunction::EvalType MBMesquite::OFEvaluator::updateType [private]

Definition at line 311 of file OFEvaluator.hpp.

Referenced by initialize(), and update().

List of all members.

The documentation for this class was generated from the following files: