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

Constructor.

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

Definition at line 39 of file OFEvaluator.cpp.

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

Disallow copying.


Member Function Documentation

Do block coordinate descent algorithm.

Definition at line 193 of file OFEvaluator.hpp.

    {
        doBCD = true;
    }

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:
pdThe mesh patch
valueOutput, the value of the objective function.

Definition at line 143 of file OFEvaluator.cpp.

References b, MBMesquite::ObjectiveFunction::evaluate(), get_objective_function(), have_objective_function(), MBMesquite::MsqError::INVALID_STATE, MSQ_CHKERR, MSQ_SETERR, MBMesquite::OF_FREE_EVALS_ONLY, and tempType.

Referenced by MBMesquite::TerminationCriterion::accumulate_inner(), MBMesquite::TerminationCriterion::cull_vertices(), MBMesquite::NonGradient::evaluate(), MBMesquite::ConjugateGradient::get_step(), MBMesquite::TrustRegion::optimize_vertex_positions(), MBMesquite::QuasiNewton::optimize_vertex_positions(), MBMesquite::SteepestDescent::optimize_vertex_positions(), MBMesquite::FeasibleNewton::optimize_vertex_positions(), and MBMesquite::TerminationCriterion::reset_inner().

{
    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:
pdThe mesh patch
valueOutput, the value of the objective function.
gradOutput, the gradient of the objective function with respect to each FREE vertex in the patch.

Definition at line 154 of file OFEvaluator.cpp.

References b, MBMesquite::ObjectiveFunction::evaluate_with_gradient(), get_objective_function(), have_objective_function(), MBMesquite::MsqError::INVALID_STATE, MSQ_CHKERR, MSQ_SETERR, and tempType.

{
    if( !have_objective_function() )
    {
        MSQ_SETERR( err )( "No ObjectiveFunction", MsqError::INVALID_STATE );
        return false;
    }
    bool b = get_objective_function()->evaluate_with_gradient( tempType, pd, value, grad, err );
    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:
pdThe mesh patch
valueOutput, the value of the objective function.
gradOutput, the gradient of the objective function with respect to each FREE vertex in the patch.
Hessian_diag_blocksOutput, 3x3 submatrices along diagonal of Hessian of objective function

Definition at line 165 of file OFEvaluator.cpp.

References b, MBMesquite::ObjectiveFunction::evaluate_with_Hessian_diagonal(), get_objective_function(), have_objective_function(), MBMesquite::MsqError::INVALID_STATE, MSQ_CHKERR, MSQ_SETERR, and tempType.

{
    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:
pdThe mesh patch
valueOutput, the value of the objective function.
gradOutput, the gradient of the objective function with respect to each FREE vertex in the patch.
HessianOutput, the Hessian of the objective function.

Definition at line 180 of file OFEvaluator.cpp.

References b, MBMesquite::ObjectiveFunction::evaluate_with_Hessian(), get_objective_function(), have_objective_function(), MBMesquite::MsqError::INVALID_STATE, MSQ_CHKERR, MSQ_SETERR, and tempType.

{
    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;
}

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:
meshThe active mesh

Definition at line 41 of file OFEvaluator.cpp.

References MBMesquite::ObjectiveFunction::CALCULATE, doBCD, firstType, get_objective_function(), have_objective_function(), MBMesquite::ObjectiveFunction::initialize_block_coordinate_descent(), MBMesquite::MsqError::INVALID_STATE, MSQ_CHKERR, MSQ_SETERR, reset(), MBMesquite::ObjectiveFunction::SAVE, MBMesquite::ObjectiveFunction::TEMPORARY, tempType, MBMesquite::ObjectiveFunction::UPDATE, and updateType.

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;
}

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.

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:
pdThe mesh patch
valueOutput, the value of the objective function.

Definition at line 86 of file OFEvaluator.cpp.

References b, currUpdateType, MBMesquite::ObjectiveFunction::evaluate(), get_objective_function(), have_objective_function(), MBMesquite::MsqError::INVALID_STATE, MSQ_CHKERR, MSQ_SETERR, MBMesquite::OF_FREE_EVALS_ONLY, and updateType.

Referenced by MBMesquite::QuasiNewton::optimize_vertex_positions(), MBMesquite::TrustRegion::optimize_vertex_positions(), MBMesquite::ConjugateGradient::optimize_vertex_positions(), MBMesquite::SteepestDescent::optimize_vertex_positions(), and MBMesquite::FeasibleNewton::optimize_vertex_positions().

{
    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:
pdThe mesh patch
valueOutput, the value of the objective function.
gradOutput, the gradient of the objective function with respect to each FREE vertex in the patch.

Definition at line 98 of file OFEvaluator.cpp.

References b, currUpdateType, MBMesquite::ObjectiveFunction::evaluate_with_gradient(), get_objective_function(), have_objective_function(), MBMesquite::MsqError::INVALID_STATE, MSQ_CHKERR, MSQ_SETERR, and updateType.

{
    if( !have_objective_function() )
    {
        MSQ_SETERR( err )( "No ObjectiveFunction", MsqError::INVALID_STATE );
        return false;
    }
    bool b         = get_objective_function()->evaluate_with_gradient( currUpdateType, pd, value, grad, err );
    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:
pdThe mesh patch
valueOutput, the value of the objective function.
gradOutput, the gradient of the objective function with respect to each FREE vertex in the patch.
Hessian_diag_blocksOutput, 3x3 submatrices along diagonal of Hessian of objective function

Definition at line 110 of file OFEvaluator.cpp.

References b, currUpdateType, MBMesquite::ObjectiveFunction::evaluate_with_Hessian_diagonal(), get_objective_function(), have_objective_function(), MBMesquite::MsqError::INVALID_STATE, MSQ_CHKERR, MSQ_SETERR, and updateType.

{
    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:
pdThe mesh patch
valueOutput, the value of the objective function.
gradOutput, the gradient of the objective function with respect to each FREE vertex in the patch.
HessianOutput, the Hessian of the objective function.

Definition at line 127 of file OFEvaluator.cpp.

References b, currUpdateType, MBMesquite::ObjectiveFunction::evaluate_with_Hessian(), get_objective_function(), have_objective_function(), MBMesquite::MsqError::INVALID_STATE, MSQ_CHKERR, MSQ_SETERR, and updateType.

{
    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

Nash or BCD

Definition at line 308 of file OFEvaluator.hpp.

Referenced by initialize().

The ObjectiveFunction to evaluate

Definition at line 305 of file OFEvaluator.hpp.

Nash vs. BCD and state of BCD data

Definition at line 311 of file OFEvaluator.hpp.

Referenced by evaluate(), and initialize().

List of all members.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines