Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TerminationCriterion Class Reference

The TerminationCriterion class contains functionality to terminate the VertexMover's optimization. More...

#include <TerminationCriterion.hpp>

Collaboration diagram for TerminationCriterion:

Public Types

enum  TCType {
  NONE = 0, GRADIENT_L2_NORM_ABSOLUTE = 1, GRADIENT_INF_NORM_ABSOLUTE = 2, GRADIENT_L2_NORM_RELATIVE = 4,
  GRADIENT_INF_NORM_RELATIVE = 8, KKT = 16, QUALITY_IMPROVEMENT_ABSOLUTE = 32, QUALITY_IMPROVEMENT_RELATIVE = 64,
  NUMBER_OF_ITERATES = 128, CPU_TIME = 256, VERTEX_MOVEMENT_ABSOLUTE = 512, VERTEX_MOVEMENT_RELATIVE = 1024,
  SUCCESSIVE_IMPROVEMENTS_ABSOLUTE = 2048, SUCCESSIVE_IMPROVEMENTS_RELATIVE = 4096, BOUNDED_VERTEX_MOVEMENT = 8192, NONE = 0,
  GRADIENT_L2_NORM_ABSOLUTE = 1, GRADIENT_INF_NORM_ABSOLUTE = 2, GRADIENT_L2_NORM_RELATIVE = 4, GRADIENT_INF_NORM_RELATIVE = 8,
  KKT = 16, QUALITY_IMPROVEMENT_ABSOLUTE = 32, QUALITY_IMPROVEMENT_RELATIVE = 64, NUMBER_OF_ITERATES = 128,
  CPU_TIME = 256, VERTEX_MOVEMENT_ABSOLUTE = 512, VERTEX_MOVEMENT_RELATIVE = 1024, SUCCESSIVE_IMPROVEMENTS_ABSOLUTE = 2048,
  SUCCESSIVE_IMPROVEMENTS_RELATIVE = 4096, BOUNDED_VERTEX_MOVEMENT = 8192
}
 
enum  TCType {
  NONE = 0, GRADIENT_L2_NORM_ABSOLUTE = 1, GRADIENT_INF_NORM_ABSOLUTE = 2, GRADIENT_L2_NORM_RELATIVE = 4,
  GRADIENT_INF_NORM_RELATIVE = 8, KKT = 16, QUALITY_IMPROVEMENT_ABSOLUTE = 32, QUALITY_IMPROVEMENT_RELATIVE = 64,
  NUMBER_OF_ITERATES = 128, CPU_TIME = 256, VERTEX_MOVEMENT_ABSOLUTE = 512, VERTEX_MOVEMENT_RELATIVE = 1024,
  SUCCESSIVE_IMPROVEMENTS_ABSOLUTE = 2048, SUCCESSIVE_IMPROVEMENTS_RELATIVE = 4096, BOUNDED_VERTEX_MOVEMENT = 8192, NONE = 0,
  GRADIENT_L2_NORM_ABSOLUTE = 1, GRADIENT_INF_NORM_ABSOLUTE = 2, GRADIENT_L2_NORM_RELATIVE = 4, GRADIENT_INF_NORM_RELATIVE = 8,
  KKT = 16, QUALITY_IMPROVEMENT_ABSOLUTE = 32, QUALITY_IMPROVEMENT_RELATIVE = 64, NUMBER_OF_ITERATES = 128,
  CPU_TIME = 256, VERTEX_MOVEMENT_ABSOLUTE = 512, VERTEX_MOVEMENT_RELATIVE = 1024, SUCCESSIVE_IMPROVEMENTS_ABSOLUTE = 2048,
  SUCCESSIVE_IMPROVEMENTS_RELATIVE = 4096, BOUNDED_VERTEX_MOVEMENT = 8192
}
 

Public Member Functions

 TerminationCriterion ()
 Constructor which does not take any arguements. More...
 
 ~TerminationCriterion ()
 Destructor. More...
 
void add_criterion_type_with_double (TCType tc_type, double eps, MsqError &err)
 Sets the criterion by specifing the TCType and the eps value. More...
 
void add_criterion_type_with_int (TCType tc_type, int bound, MsqError &err)
 Sets the criterion by specifing the TCType and the integer value. More...
 
void remove_criterion_type (TCType tc_type, MsqError &err)
 Removes the criterion by specifing just the TCType. More...
 
void set_culling_type (TCType tc_type, double eps, MsqError &err)
 Sets the type of criterion that the user would like to use for culling purposes (along with the associated tolerance. More...
 
void remove_culling (MsqError &err)
 Removes any previously set culling types (sets the culling type to be NONE). More...
 
void reset_outer (MeshSet &ms, ObjectiveFunction *of, MsqError &err)
 Clear any data accumulated during an outer iteration. More...
 
void reset_inner (PatchData &pd, ObjectiveFunction *of, MsqError &err)
 Clear any data accumulated during an inner iteration. More...
 
void reset_patch (PatchData &pd, MsqError &err)
 Shared inner and outer initialization during inner loop. More...
 
void accumulate_inner (PatchData &pd, MsqError &err)
 Accumulate data during inner iteration. More...
 
void accumulate_inner (PatchData &pd, double of_value, Vector3D *of_grads, MsqError &err)
 Accumulate data during inner iteration. More...
 
void accumulate_patch (PatchData &pd, MsqError &err)
 Common code for both inner and outer termination criteria during inner iteration. More...
 
void accumulate_outer (MeshSet &ms, MsqError &err)
 
bool terminate ()
 Check if termination criterion has been met. More...
 
bool cull_vertices (PatchData &pd, ObjectiveFunction *obj_ptr, MsqError &err)
 Function which determines whether this patch should be 'culled'. More...
 
void cleanup (MeshSet &ms, MsqError &err)
 Cleans up after the TerminationCriterion is finished. More...
 
double get_current_function_value ()
 This function returns the current function value. More...
 
void set_debug_output_level (int i)
 
 TerminationCriterion ()
 Constructor which does not take any arguements. More...
 
 ~TerminationCriterion ()
 Destructor. More...
 
void add_criterion_type_with_double (TCType tc_type, double eps, MsqError &err)
 Sets the criterion by specifing the TCType and the eps value. More...
 
void add_criterion_type_with_int (TCType tc_type, int bound, MsqError &err)
 Sets the criterion by specifing the TCType and the integer value. More...
 
void remove_criterion_type (TCType tc_type, MsqError &err)
 Removes the criterion by specifing just the TCType. More...
 
void set_culling_type (TCType tc_type, double eps, MsqError &err)
 Sets the type of criterion that the user would like to use for culling purposes (along with the associated tolerance. More...
 
void remove_culling (MsqError &err)
 Removes any previously set culling types (sets the culling type to be NONE). More...
 
void reset_outer (MeshSet &ms, ObjectiveFunction *of, MsqError &err)
 Clear any data accumulated during an outer iteration. More...
 
void reset_inner (PatchData &pd, ObjectiveFunction *of, MsqError &err)
 Clear any data accumulated during an inner iteration. More...
 
void reset_patch (PatchData &pd, MsqError &err)
 Shared inner and outer initialization during inner loop. More...
 
void accumulate_inner (PatchData &pd, MsqError &err)
 Accumulate data during inner iteration. More...
 
void accumulate_inner (PatchData &pd, double of_value, Vector3D *of_grads, MsqError &err)
 Accumulate data during inner iteration. More...
 
void accumulate_patch (PatchData &pd, MsqError &err)
 Common code for both inner and outer termination criteria during inner iteration. More...
 
void accumulate_outer (MeshSet &ms, MsqError &err)
 
bool terminate ()
 Check if termination criterion has been met. More...
 
bool cull_vertices (PatchData &pd, ObjectiveFunction *obj_ptr, MsqError &err)
 Function which determines whether this patch should be 'culled'. More...
 
void cleanup (MeshSet &ms, MsqError &err)
 Cleans up after the TerminationCriterion is finished. More...
 
double get_current_function_value ()
 This function returns the current function value. More...
 
void set_debug_output_level (int i)
 

Private Attributes

long unsigned int terminationCriterionFlag
 Bit flag of termination crit. More...
 
long unsigned int cullingMethodFlag
 
double cullingEps
 
ObjectiveFunctionOFPtr
 
double initialOFValue
 
double previousOFValue
 
double currentOFValue
 
double lowerOFBound
 
msq_std::vector< Vector3DmGrad
 
double initialGradL2Norm
 
double currentGradL2Norm
 
double gradL2NormAbsoluteEps
 
double gradL2NormRelativeEps
 
double initialGradInfNorm
 
double currentGradInfNorm
 
double gradInfNormAbsoluteEps
 
double gradInfNormRelativeEps
 
double qualityImprovementAbsoluteEps
 
double qualityImprovementRelativeEps
 
int iterationBound
 
int iterationCounter
 
Timer mTimer
 
double timeBound
 
PatchDataVerticesMementoinitialVerticesMemento
 
PatchDataVerticesMementopreviousVerticesMemento
 
double vertexMovementAbsoluteEps
 
double vertexMovementRelativeEps
 
double maxSquaredInitialMovement
 
double maxSquaredMovement
 
double successiveImprovementsAbsoluteEps
 
double successiveImprovementsRelativeEps
 
double boundedVertexMovementEps
 
int vertexMovementExceedsBound
 
int debugLevel
 

Detailed Description

The TerminationCriterion class contains functionality to terminate the VertexMover's optimization.

The TerminationCriterion class has three roles. It is used to terminate the optimization on a single patch; it is used to terminate the iterations over all patches in the mesh; and it is used to cull vertices frm the optimization processes. Thus, for each optimzation, two TerminationCriterion objects are used. The class contains five important member functions used in the VertexMover: initialize(), reset(), terminate(), cull_vertices(), and cleanup(). These functions are each explained in detail below. In general, the only one of these functions called directly from a concrete VertexMover is terminate() which allows the concrete VertexMover to determine when to stop producing new iterates on a given patch. All other functionality is handled from the base VertexMover base class.

There are several different types of termination criteria available. These types are listed in teh enumberation TCType. Multiple criteria types can be set on a given TermiantionCriterion object, and when this occurs, the optimization process will terminate whenever any of the criteria have been satisfied.

The following is a brief description of how TerminationCriterion is used within Mesquite. Functions called during QualityImprovement can be devided into three groups: reset_* - Initialize data for an iteration accumulate_* - Update TC for changed data during iteration terminate - Check if the termination criterion has been met. There are three different forms of the reset_* and accumulate_* functions which are called on the inner, outer, or both TerminationCriterion classes: _outer - Called on outer termination criterion. _inner - Called on inner termination criterion. _patch - Called on outer termination criterion for each patch and on inner termination criterion for each inner iteration.

If implementing a new TerminationCriterion, the following rules should be followed. If the value must be calculated on a global patch for the outer TC, then: o The functionality should be added to *_inner (yes, INNER) o The *_outer methods should be updated to call the *_inner with a global patch when your TC is requested. o The internal data for any such TC should be initialized in the reset_inner method. If the value for the outer criterion can be calculated from each local patch when iterating over the mesh with local patches, then: o The functionality should be added to *_patch o Any state values pertaining to the entire iteration must be initialized in reset_inner(..) and cleared in terminate() o Any patch-specific data should be initialized in reset_patch o Care should be taken that terminate() does not check uninitialized data if called before the first call to accumulate_patch()

Definition at line 119 of file includeLinks/TerminationCriterion.hpp.

Member Enumeration Documentation

enum TCType

defines the termination criterion

Enumerator
NONE 
GRADIENT_L2_NORM_ABSOLUTE 

checks the gradient $\nabla f $ of objective function $f : I\!\!R^{3N} \rightarrow I\!\!R $ against a double $d$ and stops when $\sqrt{\sum_{i=1}^{3N}\nabla f_i^2}<d$

GRADIENT_INF_NORM_ABSOLUTE 

checks the gradient $\nabla f $ of objective function $f : I\!\!R^{3N} \rightarrow I\!\!R $ against a double $d$ and stops when $ \max_{i=1}^{3N} \nabla f_i < d $

GRADIENT_L2_NORM_RELATIVE 

terminates on the j_th iteration when $\sqrt{\sum_{i=1}^{3N}\nabla f_{i,j}^2}<d\sqrt{\sum_{i=1}^{3N}\nabla f_{i,0}^2}$ That is, terminates when the norm of the gradient is small than some scaling factor times the norm of the original gradient.

GRADIENT_INF_NORM_RELATIVE 

terminates on the j_th iteration when

$\max_{i=1 \cdots 3N}\nabla f_{i,j}<d \max_{i=1 \cdots 3N}\nabla f_{i,0}$ That is, terminates when the norm of the gradient is small than some scaling factor times the norm of the original gradient. (Using the infinity norm.)

KKT 

Not yet implemented.

QUALITY_IMPROVEMENT_ABSOLUTE 

Terminates when the objective function value is smaller than the given scalar value.

QUALITY_IMPROVEMENT_RELATIVE 

Terminates when the objective function value is smaller than the given scalar value times the original objective function value.

NUMBER_OF_ITERATES 

Terminates when the number of iterations exceeds a given integer.

CPU_TIME 

Terminates when the algorithm exceeds an allotted time limit (given in seconds).

VERTEX_MOVEMENT_ABSOLUTE 

Terminates when a the maximum distance moved by any vertex during the previous iteration is below the given value.

VERTEX_MOVEMENT_RELATIVE 

Terminates when a the maximum distance moved by any vertex during the previous iteration is below the given value times the maximum distance moved by any vertex over the entire course of the optimization.

SUCCESSIVE_IMPROVEMENTS_ABSOLUTE 

Terminates when the decrease in the objective function value since the previous iteration is below the given value.

SUCCESSIVE_IMPROVEMENTS_RELATIVE 

Terminates when the decrease in the objective function value since the previous iteration is below the given value times the decrease in the objective function value since the beginning of this optimization process.

BOUNDED_VERTEX_MOVEMENT 

Terminates when any vertex leaves the bounding box, defined by the given value, d.

That is, when the absolute value of a single coordinate of vertex's position exceeds d.

NONE 
GRADIENT_L2_NORM_ABSOLUTE 

checks the gradient $\nabla f $ of objective function $f : I\!\!R^{3N} \rightarrow I\!\!R $ against a double $d$ and stops when $\sqrt{\sum_{i=1}^{3N}\nabla f_i^2}<d$

GRADIENT_INF_NORM_ABSOLUTE 

checks the gradient $\nabla f $ of objective function $f : I\!\!R^{3N} \rightarrow I\!\!R $ against a double $d$ and stops when $ \max_{i=1}^{3N} \nabla f_i < d $

GRADIENT_L2_NORM_RELATIVE 

terminates on the j_th iteration when $\sqrt{\sum_{i=1}^{3N}\nabla f_{i,j}^2}<d\sqrt{\sum_{i=1}^{3N}\nabla f_{i,0}^2}$ That is, terminates when the norm of the gradient is small than some scaling factor times the norm of the original gradient.

GRADIENT_INF_NORM_RELATIVE 

terminates on the j_th iteration when

$\max_{i=1 \cdots 3N}\nabla f_{i,j}<d \max_{i=1 \cdots 3N}\nabla f_{i,0}$ That is, terminates when the norm of the gradient is small than some scaling factor times the norm of the original gradient. (Using the infinity norm.)

KKT 

Not yet implemented.

QUALITY_IMPROVEMENT_ABSOLUTE 

Terminates when the objective function value is smaller than the given scalar value.

QUALITY_IMPROVEMENT_RELATIVE 

Terminates when the objective function value is smaller than the given scalar value times the original objective function value.

NUMBER_OF_ITERATES 

Terminates when the number of iterations exceeds a given integer.

CPU_TIME 

Terminates when the algorithm exceeds an allotted time limit (given in seconds).

VERTEX_MOVEMENT_ABSOLUTE 

Terminates when a the maximum distance moved by any vertex during the previous iteration is below the given value.

VERTEX_MOVEMENT_RELATIVE 

Terminates when a the maximum distance moved by any vertex during the previous iteration is below the given value times the maximum distance moved by any vertex over the entire course of the optimization.

SUCCESSIVE_IMPROVEMENTS_ABSOLUTE 

Terminates when the decrease in the objective function value since the previous iteration is below the given value.

SUCCESSIVE_IMPROVEMENTS_RELATIVE 

Terminates when the decrease in the objective function value since the previous iteration is below the given value times the decrease in the objective function value since the beginning of this optimization process.

BOUNDED_VERTEX_MOVEMENT 

Terminates when any vertex leaves the bounding box, defined by the given value, d.

That is, when the absolute value of a single coordinate of vertex's position exceeds d.

Definition at line 124 of file includeLinks/TerminationCriterion.hpp.

124  {
125  NONE = 0,
146  KKT = 16,
155  NUMBER_OF_ITERATES = 128,
158  CPU_TIME = 256,
179  };
Terminates when a the maximum distance moved by any vertex during the previous iteration is below the...
Terminates when the decrease in the objective function value since the previous iteration is below th...
Terminates when any vertex leaves the bounding box, defined by the given value, d.
checks the gradient of objective function against a double and stops when
Terminates when a the maximum distance moved by any vertex during the previous iteration is below the...
terminates on the j_th iteration when That is, terminates when the norm of the gradient is small tha...
Terminates when the decrease in the objective function value since the previous iteration is below th...
Terminates when the objective function value is smaller than the given scalar value.
Terminates when the algorithm exceeds an allotted time limit (given in seconds).
Terminates when the number of iterations exceeds a given integer.
Terminates when the objective function value is smaller than the given scalar value times the origina...
checks the gradient of objective function against a double and stops when
enum TCType
Enumerator
NONE 
GRADIENT_L2_NORM_ABSOLUTE 

checks the gradient $\nabla f $ of objective function $f : I\!\!R^{3N} \rightarrow I\!\!R $ against a double $d$ and stops when $\sqrt{\sum_{i=1}^{3N}\nabla f_i^2}<d$

GRADIENT_INF_NORM_ABSOLUTE 

checks the gradient $\nabla f $ of objective function $f : I\!\!R^{3N} \rightarrow I\!\!R $ against a double $d$ and stops when $ \max_{i=1}^{3N} \nabla f_i < d $

GRADIENT_L2_NORM_RELATIVE 

terminates on the j_th iteration when $\sqrt{\sum_{i=1}^{3N}\nabla f_{i,j}^2}<d\sqrt{\sum_{i=1}^{3N}\nabla f_{i,0}^2}$ That is, terminates when the norm of the gradient is small than some scaling factor times the norm of the original gradient.

GRADIENT_INF_NORM_RELATIVE 

terminates on the j_th iteration when

$\max_{i=1 \cdots 3N}\nabla f_{i,j}<d \max_{i=1 \cdots 3N}\nabla f_{i,0}$ That is, terminates when the norm of the gradient is small than some scaling factor times the norm of the original gradient. (Using the infinity norm.)

KKT 

Not yet implemented.

QUALITY_IMPROVEMENT_ABSOLUTE 

Terminates when the objective function value is smaller than the given scalar value.

QUALITY_IMPROVEMENT_RELATIVE 

Terminates when the objective function value is smaller than the given scalar value times the original objective function value.

NUMBER_OF_ITERATES 

Terminates when the number of iterations exceeds a given integer.

CPU_TIME 

Terminates when the algorithm exceeds an allotted time limit (given in seconds).

VERTEX_MOVEMENT_ABSOLUTE 

Terminates when a the maximum distance moved by any vertex during the previous iteration is below the given value.

VERTEX_MOVEMENT_RELATIVE 

Terminates when a the maximum distance moved by any vertex during the previous iteration is below the given value times the maximum distance moved by any vertex over the entire course of the optimization.

SUCCESSIVE_IMPROVEMENTS_ABSOLUTE 

Terminates when the decrease in the objective function value since the previous iteration is below the given value.

SUCCESSIVE_IMPROVEMENTS_RELATIVE 

Terminates when the decrease in the objective function value since the previous iteration is below the given value times the decrease in the objective function value since the beginning of this optimization process.

BOUNDED_VERTEX_MOVEMENT 

Terminates when any vertex leaves the bounding box, defined by the given value, d.

That is, when the absolute value of a single coordinate of vertex's position exceeds d.

NONE 
GRADIENT_L2_NORM_ABSOLUTE 

checks the gradient $\nabla f $ of objective function $f : I\!\!R^{3N} \rightarrow I\!\!R $ against a double $d$ and stops when $\sqrt{\sum_{i=1}^{3N}\nabla f_i^2}<d$

GRADIENT_INF_NORM_ABSOLUTE 

checks the gradient $\nabla f $ of objective function $f : I\!\!R^{3N} \rightarrow I\!\!R $ against a double $d$ and stops when $ \max_{i=1}^{3N} \nabla f_i < d $

GRADIENT_L2_NORM_RELATIVE 

terminates on the j_th iteration when $\sqrt{\sum_{i=1}^{3N}\nabla f_{i,j}^2}<d\sqrt{\sum_{i=1}^{3N}\nabla f_{i,0}^2}$ That is, terminates when the norm of the gradient is small than some scaling factor times the norm of the original gradient.

GRADIENT_INF_NORM_RELATIVE 

terminates on the j_th iteration when

$\max_{i=1 \cdots 3N}\nabla f_{i,j}<d \max_{i=1 \cdots 3N}\nabla f_{i,0}$ That is, terminates when the norm of the gradient is small than some scaling factor times the norm of the original gradient. (Using the infinity norm.)

KKT 

Not yet implemented.

QUALITY_IMPROVEMENT_ABSOLUTE 

Terminates when the objective function value is smaller than the given scalar value.

QUALITY_IMPROVEMENT_RELATIVE 

Terminates when the objective function value is smaller than the given scalar value times the original objective function value.

NUMBER_OF_ITERATES 

Terminates when the number of iterations exceeds a given integer.

CPU_TIME 

Terminates when the algorithm exceeds an allotted time limit (given in seconds).

VERTEX_MOVEMENT_ABSOLUTE 

Terminates when a the maximum distance moved by any vertex during the previous iteration is below the given value.

VERTEX_MOVEMENT_RELATIVE 

Terminates when a the maximum distance moved by any vertex during the previous iteration is below the given value times the maximum distance moved by any vertex over the entire course of the optimization.

SUCCESSIVE_IMPROVEMENTS_ABSOLUTE 

Terminates when the decrease in the objective function value since the previous iteration is below the given value.

SUCCESSIVE_IMPROVEMENTS_RELATIVE 

Terminates when the decrease in the objective function value since the previous iteration is below the given value times the decrease in the objective function value since the beginning of this optimization process.

BOUNDED_VERTEX_MOVEMENT 

Terminates when any vertex leaves the bounding box, defined by the given value, d.

That is, when the absolute value of a single coordinate of vertex's position exceeds d.

Definition at line 124 of file src/Control/TerminationCriterion.hpp.

124  {
125  NONE = 0,
146  KKT = 16,
155  NUMBER_OF_ITERATES = 128,
158  CPU_TIME = 256,
179  };
Terminates when a the maximum distance moved by any vertex during the previous iteration is below the...
Terminates when the decrease in the objective function value since the previous iteration is below th...
Terminates when any vertex leaves the bounding box, defined by the given value, d.
checks the gradient of objective function against a double and stops when
Terminates when a the maximum distance moved by any vertex during the previous iteration is below the...
terminates on the j_th iteration when That is, terminates when the norm of the gradient is small tha...
Terminates when the decrease in the objective function value since the previous iteration is below th...
Terminates when the objective function value is smaller than the given scalar value.
Terminates when the algorithm exceeds an allotted time limit (given in seconds).
Terminates when the number of iterations exceeds a given integer.
Terminates when the objective function value is smaller than the given scalar value times the origina...
checks the gradient of objective function against a double and stops when

Constructor & Destructor Documentation

Constructor which does not take any arguements.

Constructor initializes all of the data members which are not necessarily automatically initialized in their constructors.

Definition at line 62 of file Control/TerminationCriterion.cpp.

References TerminationCriterion::boundedVertexMovementEps, TerminationCriterion::cullingEps, TerminationCriterion::cullingMethodFlag, TerminationCriterion::currentOFValue, TerminationCriterion::gradInfNormAbsoluteEps, TerminationCriterion::gradInfNormRelativeEps, TerminationCriterion::gradL2NormAbsoluteEps, TerminationCriterion::gradL2NormRelativeEps, TerminationCriterion::initialGradInfNorm, TerminationCriterion::initialGradL2Norm, TerminationCriterion::initialOFValue, TerminationCriterion::iterationBound, TerminationCriterion::iterationCounter, TerminationCriterion::lowerOFBound, TerminationCriterion::NONE, TerminationCriterion::previousOFValue, TerminationCriterion::qualityImprovementAbsoluteEps, TerminationCriterion::qualityImprovementRelativeEps, TerminationCriterion::successiveImprovementsAbsoluteEps, TerminationCriterion::successiveImprovementsRelativeEps, TerminationCriterion::terminationCriterionFlag, TerminationCriterion::timeBound, TerminationCriterion::vertexMovementAbsoluteEps, and TerminationCriterion::vertexMovementRelativeEps.

63  : mGrad(8),
66  debugLevel(2)
67 {
70  cullingEps=0.0;
71  initialOFValue=0.0;
72  previousOFValue=0.0;
73  currentOFValue = 0.0;
74  lowerOFBound=0.0;
77  //initial size of the gradient array
86  timeBound=0.0;
92 
93 }
long unsigned int terminationCriterionFlag
Bit flag of termination crit.
~TerminationCriterion ( )
inline

Destructor.

Definition at line 185 of file includeLinks/TerminationCriterion.hpp.

185 {};

Constructor which does not take any arguements.

~TerminationCriterion ( )
inline

Destructor.

Definition at line 185 of file src/Control/TerminationCriterion.hpp.

185 {};

Member Function Documentation

void accumulate_inner ( PatchData pd,
MsqError err 
)

Accumulate data during inner iteration.

Definition at line 375 of file Control/TerminationCriterion.cpp.

References ObjectiveFunction::compute_gradient(), ObjectiveFunction::evaluate(), Mesquite::GRAD_FLAGS, MsqError::INVALID_MESH, TerminationCriterion::mGrad, MSQ_CHKERR, MSQ_ERRRTN, MSQ_SETERR, PatchData::num_vertices(), Mesquite::OF_FLAGS, TerminationCriterion::OFPtr, and TerminationCriterion::terminationCriterionFlag.

Referenced by TerminationCriterion::accumulate_outer(), ConjugateGradient::optimize_vertex_positions(), SteepestDescent::optimize_vertex_positions(), and FeasibleNewton::optimize_vertex_positions().

376 {
377  double of_value = 0;
378 
380  {
381  mGrad.resize( pd.num_vertices() );
382  bool b = OFPtr->compute_gradient(pd, &mGrad[0], of_value, err, pd.num_vertices());
383  MSQ_ERRRTN(err);
384  if (!b) {
385  MSQ_SETERR(err)("Initial patch is invalid for gradient compuation.",
387  return;
388  }
389  }
391  {
392  bool b = OFPtr->evaluate(pd, of_value, err); MSQ_ERRRTN(err);
393  if (!b) {
394  MSQ_SETERR(err)("Invalid patch passed to TerminationCriterion.",
396  return;
397  }
398  }
399 
400  accumulate_inner( pd, of_value, &mGrad[0], err ); MSQ_CHKERR(err);
401 }
const unsigned long GRAD_FLAGS
bool evaluate(PatchData &patch, double &fval, MsqError &err)
const unsigned long OF_FLAGS
#define MSQ_CHKERR(err)
Mesquite&#39;s Error Checking macro.
bool compute_gradient(PatchData &patch, Vector3D *const &grad, double &OF_val, MsqError &err, size_t array_size=0)
Calls either compute_numerical_gradient or compute_analytical_gradient depending on the value of grad...
#define MSQ_SETERR(err)
Macro to set error - use err.clear() to clear.
long unsigned int terminationCriterionFlag
Bit flag of termination crit.
void accumulate_inner(PatchData &pd, MsqError &err)
Accumulate data during inner iteration.
#define MSQ_ERRRTN(err)
If passed error is true, return from a void function.

Here is the call graph for this function:

Here is the caller graph for this function:

void accumulate_inner ( PatchData pd,
MsqError err 
)

Accumulate data during inner iteration.

void accumulate_inner ( PatchData pd,
double  of_value,
Vector3D of_grads,
MsqError err 
)

Accumulate data during inner iteration.

Definition at line 404 of file Control/TerminationCriterion.cpp.

References TerminationCriterion::currentGradInfNorm, TerminationCriterion::currentGradL2Norm, TerminationCriterion::currentOFValue, TerminationCriterion::debugLevel, PatchData::get_max_vertex_movement_squared(), TerminationCriterion::GRADIENT_INF_NORM_ABSOLUTE, TerminationCriterion::GRADIENT_INF_NORM_RELATIVE, TerminationCriterion::GRADIENT_L2_NORM_ABSOLUTE, TerminationCriterion::GRADIENT_L2_NORM_RELATIVE, TerminationCriterion::initialVerticesMemento, TerminationCriterion::iterationCounter, Mesquite::length(), TerminationCriterion::maxSquaredInitialMovement, MSQ_DBGOUT, MSQ_ERRRTN, PatchData::num_vertices(), Mesquite::OF_FLAGS, TerminationCriterion::previousOFValue, TerminationCriterion::terminationCriterionFlag, and TerminationCriterion::VERTEX_MOVEMENT_RELATIVE.

408 {
409  //if terminating on the norm of the gradient
410  currentGradL2Norm = 10e6;
412  {
413  currentGradL2Norm = length(grad_array, pd.num_vertices()); // get the L2 norm
414  MSQ_DBGOUT(debugLevel) << " o TermCrit -- gradient L2 norm: "
415  << currentGradL2Norm << msq_stdio::endl;
416  }
417  currentGradInfNorm = 10e6;
419  {
420  currentGradInfNorm = length(grad_array, pd.num_vertices()); // get the Linf norm
421  MSQ_DBGOUT(debugLevel) << " o TermCrit -- gradient Inf norm: "
422  << currentGradInfNorm << msq_stdio::endl;
423  }
424 
426  {
427  maxSquaredInitialMovement = pd.get_max_vertex_movement_squared(
428  initialVerticesMemento, err ); MSQ_ERRRTN(err);
429  }
430 
432  currentOFValue = of_value;
434  MSQ_DBGOUT(debugLevel) << " o TermCrit -- OF Value: " << of_value << msq_stdio::endl;
435  else if (grad_array)
436  MSQ_DBGOUT(debugLevel) << " o OF Value: " << of_value << msq_stdio::endl;
437 
439 }
checks the gradient of objective function against a double and stops when
Terminates when a the maximum distance moved by any vertex during the previous iteration is below the...
terminates on the j_th iteration when That is, terminates when the norm of the gradient is small tha...
double length(Vector3D *const v, int n)
const unsigned long OF_FLAGS
long unsigned int terminationCriterionFlag
Bit flag of termination crit.
checks the gradient of objective function against a double and stops when
#define MSQ_DBGOUT(flag)
Check debug flag and return ostream associated with flag.
#define MSQ_ERRRTN(err)
If passed error is true, return from a void function.

Here is the call graph for this function:

void accumulate_inner ( PatchData pd,
double  of_value,
Vector3D of_grads,
MsqError err 
)

Accumulate data during inner iteration.

void accumulate_outer ( MeshSet ms,
MsqError err 
)

Definition at line 442 of file Control/TerminationCriterion.cpp.

References TerminationCriterion::accumulate_inner(), MeshSet::get_next_patch(), PatchData::GLOBAL_PATCH, Mesquite::GRAD_FLAGS, MSQ_ERRRTN, Mesquite::OF_FLAGS, PatchDataParameters::set_patch_type(), TerminationCriterion::terminationCriterionFlag, and TerminationCriterion::VERTEX_MOVEMENT_RELATIVE.

Referenced by VertexMover::loop_over_mesh().

443 {
444  PatchData global_patch;
445 
446  //if we need to fill out the global patch data object.
448  {
449  PatchDataParameters global_params;
450  global_params.set_patch_type( PatchData::GLOBAL_PATCH, err, 0, 0 );MSQ_ERRRTN(err);
451  ms.get_next_patch( global_patch, global_params, err ); MSQ_ERRRTN(err);
452  }
453 
454  accumulate_inner( global_patch, err ); MSQ_ERRRTN(err);
455 }
const unsigned long GRAD_FLAGS
Terminates when a the maximum distance moved by any vertex during the previous iteration is below the...
const unsigned long OF_FLAGS
long unsigned int terminationCriterionFlag
Bit flag of termination crit.
void accumulate_inner(PatchData &pd, MsqError &err)
Accumulate data during inner iteration.
#define MSQ_ERRRTN(err)
If passed error is true, return from a void function.

Here is the call graph for this function:

Here is the caller graph for this function:

void accumulate_outer ( MeshSet ms,
MsqError err 
)
void accumulate_patch ( PatchData pd,
MsqError err 
)

Common code for both inner and outer termination criteria during inner iteration.

Definition at line 458 of file Control/TerminationCriterion.cpp.

References TerminationCriterion::BOUNDED_VERTEX_MOVEMENT, TerminationCriterion::boundedVertexMovementEps, PatchData::get_max_vertex_movement_squared(), PatchData::get_vertex_array(), i, TerminationCriterion::maxSquaredMovement, MSQ_ERRRTN, PatchData::num_vertices(), TerminationCriterion::previousVerticesMemento, PatchData::recreate_vertices_memento(), TerminationCriterion::terminationCriterionFlag, TerminationCriterion::VERTEX_MOVEMENT_ABSOLUTE, TerminationCriterion::VERTEX_MOVEMENT_RELATIVE, and TerminationCriterion::vertexMovementExceedsBound.

Referenced by VertexMover::loop_over_mesh(), ConjugateGradient::optimize_vertex_positions(), and FeasibleNewton::optimize_vertex_positions().

459 {
461  {
462  double patch_max_dist = pd.get_max_vertex_movement_squared( previousVerticesMemento, err );
463  if (patch_max_dist > maxSquaredMovement)
464  maxSquaredMovement = patch_max_dist;
465  pd.recreate_vertices_memento( previousVerticesMemento, err ); MSQ_ERRRTN(err);
466  }
467 
468  //if terminating on bounded vertex movement (a bounding box for the mesh)
470  {
471  MsqVertex* vert = pd.get_vertex_array(err);
472  int num_vert = pd.num_vertices();
473  int i=0;
474  //for each vertex
475  for(i=0;i<num_vert;++i)
476  {
477  //if any of the coordinates are greater than eps
478  if( (vert[i][0]>boundedVertexMovementEps) ||
479  (vert[i][1]>boundedVertexMovementEps) ||
480  (vert[i][2]>boundedVertexMovementEps) )
481  {
483  }
484  }
485  }
486 }
Terminates when a the maximum distance moved by any vertex during the previous iteration is below the...
Terminates when any vertex leaves the bounding box, defined by the given value, d.
Terminates when a the maximum distance moved by any vertex during the previous iteration is below the...
blockLoc i
Definition: read.cpp:79
long unsigned int terminationCriterionFlag
Bit flag of termination crit.
#define MSQ_ERRRTN(err)
If passed error is true, return from a void function.

Here is the call graph for this function:

Here is the caller graph for this function:

void accumulate_patch ( PatchData pd,
MsqError err 
)

Common code for both inner and outer termination criteria during inner iteration.

void add_criterion_type_with_double ( TCType  tc_type,
double  eps,
MsqError err 
)

Sets the criterion by specifing the TCType and the eps value.

void add_criterion_type_with_double ( TCType  tc_type,
double  eps,
MsqError err 
)

Sets the criterion by specifing the TCType and the eps value.

Function to add a type of termination criterion to this object. It is only valid if the specified criterion type requires a single double value.

Definition at line 100 of file Control/TerminationCriterion.cpp.

References TerminationCriterion::BOUNDED_VERTEX_MOVEMENT, TerminationCriterion::boundedVertexMovementEps, TerminationCriterion::CPU_TIME, TerminationCriterion::GRADIENT_INF_NORM_ABSOLUTE, TerminationCriterion::GRADIENT_INF_NORM_RELATIVE, TerminationCriterion::GRADIENT_L2_NORM_ABSOLUTE, TerminationCriterion::GRADIENT_L2_NORM_RELATIVE, TerminationCriterion::gradInfNormAbsoluteEps, TerminationCriterion::gradInfNormRelativeEps, TerminationCriterion::gradL2NormAbsoluteEps, TerminationCriterion::gradL2NormRelativeEps, MsqError::INVALID_ARG, MSQ_SETERR, TerminationCriterion::QUALITY_IMPROVEMENT_ABSOLUTE, TerminationCriterion::QUALITY_IMPROVEMENT_RELATIVE, TerminationCriterion::qualityImprovementAbsoluteEps, TerminationCriterion::qualityImprovementRelativeEps, TerminationCriterion::SUCCESSIVE_IMPROVEMENTS_ABSOLUTE, TerminationCriterion::SUCCESSIVE_IMPROVEMENTS_RELATIVE, TerminationCriterion::successiveImprovementsAbsoluteEps, TerminationCriterion::successiveImprovementsRelativeEps, TerminationCriterion::terminationCriterionFlag, TerminationCriterion::timeBound, TerminationCriterion::VERTEX_MOVEMENT_ABSOLUTE, TerminationCriterion::VERTEX_MOVEMENT_RELATIVE, TerminationCriterion::vertexMovementAbsoluteEps, and TerminationCriterion::vertexMovementRelativeEps.

Referenced by FeasibleNewton::FeasibleNewton().

103 {
104  switch(tc_type){
108  break;
112  break;
116  break;
120  break;
124  break;
128  break;
129  case CPU_TIME:
131  timeBound=eps;
132  break;
135  //we actually compare squared movement to squared epsilon
136  vertexMovementAbsoluteEps=(eps*eps);
137  break;
140  //we actually compare squared movement to squared epsilon
141  vertexMovementRelativeEps=(eps*eps);
142  break;
146  break;
150  break;
154  break;
155  default:
156  MSQ_SETERR(err)("TCType not valid for this function.",MsqError::INVALID_ARG);
157  };
158 }
Terminates when a the maximum distance moved by any vertex during the previous iteration is below the...
Terminates when the decrease in the objective function value since the previous iteration is below th...
Terminates when any vertex leaves the bounding box, defined by the given value, d.
checks the gradient of objective function against a double and stops when
Terminates when a the maximum distance moved by any vertex during the previous iteration is below the...
terminates on the j_th iteration when That is, terminates when the norm of the gradient is small tha...
Terminates when the decrease in the objective function value since the previous iteration is below th...
invalid function argument passed
#define MSQ_SETERR(err)
Macro to set error - use err.clear() to clear.
Terminates when the objective function value is smaller than the given scalar value.
Terminates when the algorithm exceeds an allotted time limit (given in seconds).
long unsigned int terminationCriterionFlag
Bit flag of termination crit.
Terminates when the objective function value is smaller than the given scalar value times the origina...
checks the gradient of objective function against a double and stops when

Here is the caller graph for this function:

void add_criterion_type_with_int ( TCType  tc_type,
int  bound,
MsqError err 
)

Sets the criterion by specifing the TCType and the integer value.

Function to add a type of termination criterion to this object. It is only valid if the specified criterion type requires a single integer value.

Definition at line 163 of file Control/TerminationCriterion.cpp.

References MsqError::INVALID_ARG, TerminationCriterion::iterationBound, MSQ_SETERR, TerminationCriterion::NUMBER_OF_ITERATES, and TerminationCriterion::terminationCriterionFlag.

Referenced by ConjugateGradient::ConjugateGradient(), LaplacianIQ::LaplacianIQ(), QualityImprover::QualityImprover(), and ShapeImprovementWrapper::ShapeImprovementWrapper().

166 {
167  switch(tc_type){
168  case NUMBER_OF_ITERATES:
170  iterationBound=bound;
171  break;
172  default:
173  MSQ_SETERR(err)("TCType not valid for this function.",MsqError::INVALID_ARG);
174  };
175 }
invalid function argument passed
#define MSQ_SETERR(err)
Macro to set error - use err.clear() to clear.
long unsigned int terminationCriterionFlag
Bit flag of termination crit.
Terminates when the number of iterations exceeds a given integer.

Here is the caller graph for this function:

void add_criterion_type_with_int ( TCType  tc_type,
int  bound,
MsqError err 
)

Sets the criterion by specifing the TCType and the integer value.

void cleanup ( MeshSet ms,
MsqError err 
)

Cleans up after the TerminationCriterion is finished.

void cleanup ( MeshSet ms,
MsqError err 
)

Cleans up after the TerminationCriterion is finished.

Currently this only deletes the memento of the vertex positions and the mGrad vector if neccessary. When culling, we remove the soft fixed flags from all of the vertices.

Definition at line 707 of file Control/TerminationCriterion.cpp.

References MeshSet::clear_all_soft_fixed_flags(), TerminationCriterion::cullingMethodFlag, TerminationCriterion::initialVerticesMemento, MSQ_ERRRTN, and TerminationCriterion::previousVerticesMemento.

Referenced by VertexMover::loop_over_mesh().

708 {
710  delete initialVerticesMemento;
713 
714  if(cullingMethodFlag){
715  ms.clear_all_soft_fixed_flags(err); MSQ_ERRRTN(err);
716  }
717 }
#define MSQ_ERRRTN(err)
If passed error is true, return from a void function.

Here is the call graph for this function:

Here is the caller graph for this function:

bool cull_vertices ( PatchData pd,
ObjectiveFunction obj_ptr,
MsqError err 
)

Function which determines whether this patch should be 'culled'.

bool cull_vertices ( PatchData pd,
ObjectiveFunction obj_ptr,
MsqError err 
)

Function which determines whether this patch should be 'culled'.

This function checks the culling method criterion supplied to the object by the user. If the user does not supply a culling method criterion, the default criterion is NONE, and in that case, no culling is performed. If the culling method criterion is satisfied, the interior vertices of the given patch are flagged as soft_fixed. Otherwise, the soft_fixed flag is removed from each of the vertices in the patch (interior and boundary vertices). Also, if the criterion was satisfied, then the function returns true. Otherwise, the function returns false.

Definition at line 618 of file Control/TerminationCriterion.cpp.

References TerminationCriterion::cullingEps, TerminationCriterion::cullingMethodFlag, TerminationCriterion::currentOFValue, ObjectiveFunction::evaluate(), PatchData::get_max_vertex_movement_squared(), TerminationCriterion::initialOFValue, TerminationCriterion::initialVerticesMemento, MsqError::INVALID_MESH, TerminationCriterion::lowerOFBound, MSQ_CHKERR, MSQ_ERRZERO, MSQ_SETERR, TerminationCriterion::NONE, MsqError::NOT_IMPLEMENTED, TerminationCriterion::previousVerticesMemento, TerminationCriterion::QUALITY_IMPROVEMENT_ABSOLUTE, TerminationCriterion::QUALITY_IMPROVEMENT_RELATIVE, PatchData::set_all_vertices_soft_free(), PatchData::set_free_vertices_soft_fixed(), TerminationCriterion::VERTEX_MOVEMENT_ABSOLUTE, and TerminationCriterion::VERTEX_MOVEMENT_RELATIVE.

Referenced by VertexMover::loop_over_mesh().

621 {
622  //PRINT_INFO("CULLING_METHOD FLAG = %i",cullingMethodFlag);
623 
624  //cull_bool will be changed to true if the criterion is satisfied
625  bool b, cull_bool=false;
626  double prev_m, init_m;
627  switch(cullingMethodFlag){
628  //if no culling is requested, always return false
629  case NONE:
630  return cull_bool;
631  //if culling on quality improvement absolute
633  //get objective function value
634  b = obj_ptr->evaluate(pd, currentOFValue, err);
635  if (MSQ_CHKERR(err)) return false;
636  if (!b) {
638  return false;
639  }
640  //if the improvement was enough, cull
642  {
643  cull_bool=true;
644  }
645  //PRINT_INFO("\ncurrentOFValue = %f, bool = %i\n",currentOFValue,cull_bool);
646 
647  break;
648  //if culing on quality improvement relative
650  //get objective function value
651  b = obj_ptr->evaluate(pd, currentOFValue, err);
652  if (MSQ_CHKERR(err)) return false;
653  if(!b){
655  return false;
656  }
657  //if the improvement was enough, cull
660  {
661  cull_bool=true;
662  }
663  break;
664  //if culling on vertex movement absolute
666  //if movement was enough, cull
667  prev_m = pd.get_max_vertex_movement_squared(previousVerticesMemento,err);
668  MSQ_ERRZERO(err);
669  if(prev_m <= cullingEps){
670  cull_bool=true;
671  }
672 
673  break;
674  //if culling on vertex movement relative
676  //if movement was small enough, cull
677  prev_m = pd.get_max_vertex_movement_squared(previousVerticesMemento,err);
678  MSQ_ERRZERO(err);
679  init_m = pd.get_max_vertex_movement_squared(initialVerticesMemento,err);
680  MSQ_ERRZERO(err);
681  if(prev_m <= (cullingEps * init_m)){
682  cull_bool=true;
683  }
684  break;
685  default:
686  MSQ_SETERR(err)("Requested culling method not yet implemented.",
688  return false;
689  };
690  //Now actually have patch data cull vertices
691  if(cull_bool)
692  {
693  pd.set_free_vertices_soft_fixed(err); MSQ_ERRZERO(err);
694  }
695  else
696  {
697  pd.set_all_vertices_soft_free(err); MSQ_ERRZERO(err);
698  }
699  return cull_bool;
700 }
Terminates when a the maximum distance moved by any vertex during the previous iteration is below the...
#define MSQ_ERRZERO(err)
Return zero/NULL on error.
requested functionality is not (yet) implemented
Terminates when a the maximum distance moved by any vertex during the previous iteration is below the...
#define MSQ_CHKERR(err)
Mesquite&#39;s Error Checking macro.
#define MSQ_SETERR(err)
Macro to set error - use err.clear() to clear.
Terminates when the objective function value is smaller than the given scalar value.
Terminates when the objective function value is smaller than the given scalar value times the origina...

Here is the call graph for this function:

Here is the caller graph for this function:

double get_current_function_value ( )
inline

This function returns the current function value.

Todo:
Michael: this function is not reliable. It needs to be more robust. How do we know whether currentOFValue got updated or not? We may want to make sure that all the criteria get checked.

Definition at line 240 of file includeLinks/TerminationCriterion.hpp.

References TerminationCriterion::currentOFValue.

double get_current_function_value ( )
inline

This function returns the current function value.

Todo:
Michael: this function is not reliable. It needs to be more robust. How do we know whether currentOFValue got updated or not? We may want to make sure that all the criteria get checked.

Definition at line 240 of file src/Control/TerminationCriterion.hpp.

References TerminationCriterion::currentOFValue.

void remove_criterion_type ( TCType  tc_type,
MsqError err 
)

Removes the criterion by specifing just the TCType.

void remove_criterion_type ( TCType  tc_type,
MsqError err 
)

Removes the criterion by specifing just the TCType.

Function to remove a previously set criterion type.

Definition at line 177 of file Control/TerminationCriterion.cpp.

References TerminationCriterion::terminationCriterionFlag.

179 {
180  terminationCriterionFlag&=(~tc_type);
181 }
long unsigned int terminationCriterionFlag
Bit flag of termination crit.
void remove_culling ( MsqError err)

Removes any previously set culling types (sets the culling type to be NONE).

void remove_culling ( MsqError err)

Removes any previously set culling types (sets the culling type to be NONE).

Sets the culling type to be NONE.

Definition at line 217 of file Control/TerminationCriterion.cpp.

References TerminationCriterion::cullingMethodFlag, and TerminationCriterion::NONE.

void reset_inner ( PatchData pd,
ObjectiveFunction of,
MsqError err 
)

Clear any data accumulated during an inner iteration.

void reset_inner ( PatchData pd,
ObjectiveFunction obj_ptr,
MsqError err 
)

Clear any data accumulated during an inner iteration.

Reset function using using a PatchData object. This function is called for the inner-stopping criterion directly from the loop over mesh function in VertexMover. For outer criterion, it is called from the reset function which takes a MeshSet object. This function prepares the object to be used by setting the initial values of some of the data members. As examples, if needed, it resets the cpu timer to zero, the iteration counter to zero, and the initial and previous objective function values to the current objective function value for this patch. The return value for this function is similar to that of terminate(). The function returns false if the checked criteria have not been satisfied, and true if they have been. reset() only checks the GRADIENT_INF_NORM_ABSOLUTE, GRADIENT_L2_NORM_ABSOLUTE, and the QUALITY_IMPROVEMENT_ABSOLUTE criteria. Checking these criteria allows the QualityImprover to skip the entire optimization if the initial mesh satisfies the appropriate conditions.

Definition at line 265 of file Control/TerminationCriterion.cpp.

References ObjectiveFunction::compute_gradient(), TerminationCriterion::CPU_TIME, PatchData::create_vertices_memento(), TerminationCriterion::cullingMethodFlag, TerminationCriterion::currentGradInfNorm, TerminationCriterion::currentGradL2Norm, TerminationCriterion::currentOFValue, TerminationCriterion::debugLevel, ObjectiveFunction::evaluate(), Mesquite::GRAD_FLAGS, TerminationCriterion::GRADIENT_INF_NORM_ABSOLUTE, TerminationCriterion::GRADIENT_INF_NORM_RELATIVE, TerminationCriterion::GRADIENT_L2_NORM_ABSOLUTE, TerminationCriterion::GRADIENT_L2_NORM_RELATIVE, TerminationCriterion::initialGradInfNorm, TerminationCriterion::initialGradL2Norm, TerminationCriterion::initialOFValue, TerminationCriterion::initialVerticesMemento, MsqError::INVALID_STATE, TerminationCriterion::iterationCounter, Mesquite::length(), Mesquite::Linf(), TerminationCriterion::maxSquaredInitialMovement, TerminationCriterion::maxSquaredMovement, TerminationCriterion::mGrad, MSQ_DBGOUT, MSQ_ERRRTN, MSQ_SETERR, TerminationCriterion::mTimer, PatchData::num_vertices(), Mesquite::OF_FLAGS, TerminationCriterion::OFPtr, TerminationCriterion::previousOFValue, PatchData::recreate_vertices_memento(), Timer::reset(), TerminationCriterion::terminationCriterionFlag, TerminationCriterion::VERTEX_MOVEMENT_RELATIVE, and TerminationCriterion::vertexMovementExceedsBound.

Referenced by VertexMover::loop_over_mesh(), and TerminationCriterion::reset_outer().

267 {
268  const unsigned long totalFlag = terminationCriterionFlag | cullingMethodFlag;
269  OFPtr = obj_ptr;
270 
271  // clear flag for BOUNDED_VERTEX_MOVEMENT
273 
274  // Use -1 to denote that this isn't initialized yet.
275  // As all valid values must be >= 0.0, a negative
276  // value indicates that it is uninitialized and is
277  // always less than any valid value.
278  maxSquaredMovement = -1;
279 
280  // Clear the iteration count.
281  iterationCounter = 0;
282 
283  //reset the inner timer if needed
284  if(totalFlag & CPU_TIME){
285  mTimer.reset();
286  }
287 
288  //GRADIENT
289  if(totalFlag & GRAD_FLAGS)
290  {
291  int num_vertices=pd.num_vertices();
292  mGrad.resize( num_vertices );
293 
294  //get gradient and make sure it is valid
295  bool b = obj_ptr->compute_gradient(pd, &mGrad[0] , currentOFValue,
296  err, num_vertices); MSQ_ERRRTN(err);
297  if (!b) {
298  MSQ_SETERR(err)("Initial patch is invalid for gradient computation.",
300  return;
301  }
302 
303  //get the gradient norms
305  {
306  currentGradInfNorm = initialGradInfNorm = Linf(&mGrad[0], num_vertices);
307  MSQ_DBGOUT(debugLevel) << " o Initial gradient Inf norm: "
308  << initialGradInfNorm << msq_stdio::endl;
309  }
311  {
312  currentGradL2Norm = initialGradL2Norm = length(&mGrad[0], num_vertices);
313  MSQ_DBGOUT(debugLevel) << " o Initial gradient L2 norm: "
314  << initialGradL2Norm << msq_stdio::endl;
315  }
316  //the OFvalue comes for free, so save it
319  }
320  //find the initial objective function value if needed and not already
321  //computed. If we needed the gradient, we have the OF value for free.
322  else if (totalFlag & OF_FLAGS)
323  {
324  //ensure the obj_ptr is not null
325  if(obj_ptr==NULL){
326  MSQ_SETERR(err)("Error termination criteria set which uses objective "
327  "functions, but no objective function is available.",
329  return;
330  }
331 
332  bool b = obj_ptr->evaluate(pd, currentOFValue, err); MSQ_ERRRTN(err);
333  if (!b){
334  MSQ_SETERR(err)("Initial patch is invalid for evaluation.",MsqError::INVALID_STATE);
335  return;
336  }
337  //std::cout<<"\nReseting initial of value = "<<initialOFValue;
340  }
341 
342  if (totalFlag & (GRAD_FLAGS|OF_FLAGS))
343  MSQ_DBGOUT(debugLevel) << " o Initial OF value: " << initialOFValue << msq_stdio::endl;
344 
345  // Store current vertex locations now, because we'll
346  // need them later to compare the current movement with.
347  if (totalFlag & VERTEX_MOVEMENT_RELATIVE)
348  {
350  {
351  pd.recreate_vertices_memento( initialVerticesMemento, err );
352  }
353  else
354  {
355  initialVerticesMemento = pd.create_vertices_memento( err );
356  }
357  MSQ_ERRRTN(err);
358  maxSquaredInitialMovement = DBL_MAX;
359  }
360 }
const unsigned long GRAD_FLAGS
checks the gradient of objective function against a double and stops when
Terminates when a the maximum distance moved by any vertex during the previous iteration is below the...
terminates on the j_th iteration when That is, terminates when the norm of the gradient is small tha...
double length(Vector3D *const v, int n)
const unsigned long OF_FLAGS
#define MSQ_SETERR(err)
Macro to set error - use err.clear() to clear.
Terminates when the algorithm exceeds an allotted time limit (given in seconds).
long unsigned int terminationCriterionFlag
Bit flag of termination crit.
double Linf(Vector3D *const v, int n)
object is in an invalid state
checks the gradient of objective function against a double and stops when
#define MSQ_DBGOUT(flag)
Check debug flag and return ostream associated with flag.
#define MSQ_ERRRTN(err)
If passed error is true, return from a void function.

Here is the call graph for this function:

Here is the caller graph for this function:

void reset_outer ( MeshSet ms,
ObjectiveFunction of,
MsqError err 
)

Clear any data accumulated during an outer iteration.

void reset_outer ( MeshSet ms,
ObjectiveFunction obj_ptr,
MsqError err 
)

Clear any data accumulated during an outer iteration.

This version of reset is called using a MeshSet, which implies it is only called when this criterion is used as the 'outer' termination criterion.

Definition at line 228 of file Control/TerminationCriterion.cpp.

References TerminationCriterion::cullingMethodFlag, MeshSet::get_next_patch(), PatchData::GLOBAL_PATCH, Mesquite::GRAD_FLAGS, MSQ_ERRRTN, Mesquite::OF_FLAGS, TerminationCriterion::reset_inner(), PatchDataParameters::set_patch_type(), TerminationCriterion::terminationCriterionFlag, and TerminationCriterion::VERTEX_MOVEMENT_RELATIVE.

Referenced by VertexMover::loop_over_mesh().

230 {
231  const unsigned long totalFlag = terminationCriterionFlag | cullingMethodFlag;
232  PatchData global_patch;
233 
234  //if we need to fill out the global patch data object.
235  if (totalFlag & (GRAD_FLAGS | OF_FLAGS | VERTEX_MOVEMENT_RELATIVE))
236  {
237  PatchDataParameters global_patch_params;
238  global_patch_params.set_patch_type( PatchData::GLOBAL_PATCH, err, 0, 0 );
239  MSQ_ERRRTN(err);
240  ms.get_next_patch( global_patch, global_patch_params, err );
241  MSQ_ERRRTN(err);
242  }
243 
244  //now call the other reset
245  reset_inner( global_patch, obj_ptr, err ); MSQ_ERRRTN(err);
246 }
const unsigned long GRAD_FLAGS
Terminates when a the maximum distance moved by any vertex during the previous iteration is below the...
void reset_inner(PatchData &pd, ObjectiveFunction *of, MsqError &err)
Clear any data accumulated during an inner iteration.
const unsigned long OF_FLAGS
long unsigned int terminationCriterionFlag
Bit flag of termination crit.
#define MSQ_ERRRTN(err)
If passed error is true, return from a void function.

Here is the call graph for this function:

Here is the caller graph for this function:

void reset_patch ( PatchData pd,
MsqError err 
)

Shared inner and outer initialization during inner loop.

Definition at line 362 of file Control/TerminationCriterion.cpp.

References PatchData::create_vertices_memento(), TerminationCriterion::cullingMethodFlag, MSQ_ERRRTN, TerminationCriterion::previousVerticesMemento, PatchData::recreate_vertices_memento(), TerminationCriterion::terminationCriterionFlag, TerminationCriterion::VERTEX_MOVEMENT_ABSOLUTE, and TerminationCriterion::VERTEX_MOVEMENT_RELATIVE.

Referenced by VertexMover::loop_over_mesh().

363 {
364  const unsigned long totalFlag = terminationCriterionFlag | cullingMethodFlag;
366  {
368  pd.recreate_vertices_memento(previousVerticesMemento,err);
369  else
370  previousVerticesMemento = pd.create_vertices_memento(err);
371  MSQ_ERRRTN(err);
372  }
373 }
Terminates when a the maximum distance moved by any vertex during the previous iteration is below the...
Terminates when a the maximum distance moved by any vertex during the previous iteration is below the...
long unsigned int terminationCriterionFlag
Bit flag of termination crit.
#define MSQ_ERRRTN(err)
If passed error is true, return from a void function.

Here is the call graph for this function:

Here is the caller graph for this function:

void reset_patch ( PatchData pd,
MsqError err 
)

Shared inner and outer initialization during inner loop.

void set_culling_type ( TCType  tc_type,
double  eps,
MsqError err 
)

Sets the type of criterion that the user would like to use for culling purposes (along with the associated tolerance.

Function to add a type of termination criterion to this object which will be used for culling purposes only. As part of the global termination criterion, the outer criterion will also check to make sure that there are still free vertices in the mesh.

Definition at line 188 of file Control/TerminationCriterion.cpp.

References TerminationCriterion::cullingEps, TerminationCriterion::cullingMethodFlag, MsqError::INVALID_ARG, MSQ_SETERR, TerminationCriterion::QUALITY_IMPROVEMENT_ABSOLUTE, TerminationCriterion::QUALITY_IMPROVEMENT_RELATIVE, TerminationCriterion::SUCCESSIVE_IMPROVEMENTS_ABSOLUTE, TerminationCriterion::SUCCESSIVE_IMPROVEMENTS_RELATIVE, TerminationCriterion::VERTEX_MOVEMENT_ABSOLUTE, and TerminationCriterion::VERTEX_MOVEMENT_RELATIVE.

190 {
191  switch(tc_type){
194  break;
197  break;
200  break;
203  break;
206  break;
209  break;
210  default:
211  MSQ_SETERR(err)("TCType not valid for this function.",MsqError::INVALID_ARG);
212  };
213  cullingEps=eps;
214 }
Terminates when a the maximum distance moved by any vertex during the previous iteration is below the...
Terminates when the decrease in the objective function value since the previous iteration is below th...
Terminates when a the maximum distance moved by any vertex during the previous iteration is below the...
Terminates when the decrease in the objective function value since the previous iteration is below th...
invalid function argument passed
#define MSQ_SETERR(err)
Macro to set error - use err.clear() to clear.
Terminates when the objective function value is smaller than the given scalar value.
Terminates when the objective function value is smaller than the given scalar value times the origina...
void set_culling_type ( TCType  tc_type,
double  eps,
MsqError err 
)

Sets the type of criterion that the user would like to use for culling purposes (along with the associated tolerance.

void set_debug_output_level ( int  i)
inline

Definition at line 243 of file includeLinks/TerminationCriterion.hpp.

References TerminationCriterion::debugLevel, and i.

Referenced by VertexMover::loop_over_mesh().

Here is the caller graph for this function:

void set_debug_output_level ( int  i)
inline
bool terminate ( )

Check if termination criterion has been met.

bool terminate ( )

Check if termination criterion has been met.

This function evaluates the needed information and then evaluates the termination criteria. If any of the selected criteria are satisfied, the function returns true. Otherwise, the function returns false.

Definition at line 493 of file Control/TerminationCriterion.cpp.

References TerminationCriterion::BOUNDED_VERTEX_MOVEMENT, TerminationCriterion::CPU_TIME, TerminationCriterion::currentGradInfNorm, TerminationCriterion::currentGradL2Norm, TerminationCriterion::currentOFValue, TerminationCriterion::debugLevel, TerminationCriterion::GRADIENT_INF_NORM_ABSOLUTE, TerminationCriterion::GRADIENT_INF_NORM_RELATIVE, TerminationCriterion::GRADIENT_L2_NORM_ABSOLUTE, TerminationCriterion::GRADIENT_L2_NORM_RELATIVE, TerminationCriterion::gradInfNormAbsoluteEps, TerminationCriterion::gradInfNormRelativeEps, TerminationCriterion::gradL2NormAbsoluteEps, TerminationCriterion::gradL2NormRelativeEps, TerminationCriterion::initialGradInfNorm, TerminationCriterion::initialGradL2Norm, TerminationCriterion::initialOFValue, MsqInterrupt::interrupt(), TerminationCriterion::iterationBound, TerminationCriterion::iterationCounter, TerminationCriterion::lowerOFBound, TerminationCriterion::maxSquaredInitialMovement, TerminationCriterion::maxSquaredMovement, MSQ_DBGOUT, TerminationCriterion::mTimer, TerminationCriterion::NUMBER_OF_ITERATES, TerminationCriterion::previousOFValue, TerminationCriterion::QUALITY_IMPROVEMENT_ABSOLUTE, TerminationCriterion::QUALITY_IMPROVEMENT_RELATIVE, TerminationCriterion::qualityImprovementAbsoluteEps, TerminationCriterion::qualityImprovementRelativeEps, Timer::since_birth(), sqrt(), TerminationCriterion::SUCCESSIVE_IMPROVEMENTS_ABSOLUTE, TerminationCriterion::SUCCESSIVE_IMPROVEMENTS_RELATIVE, TerminationCriterion::successiveImprovementsRelativeEps, TerminationCriterion::terminationCriterionFlag, TerminationCriterion::timeBound, TerminationCriterion::VERTEX_MOVEMENT_ABSOLUTE, TerminationCriterion::VERTEX_MOVEMENT_RELATIVE, TerminationCriterion::vertexMovementAbsoluteEps, TerminationCriterion::vertexMovementExceedsBound, and TerminationCriterion::vertexMovementRelativeEps.

Referenced by VertexMover::loop_over_mesh(), ConjugateGradient::optimize_vertex_positions(), SteepestDescent::optimize_vertex_positions(), and FeasibleNewton::optimize_vertex_positions().

494 {
495  bool return_flag = false;
496  // cout<<"\nInside terminate(pd,of,err): flag = "<<terminationCriterionFlag << endl;
497 
498  //First check for an interrupt signal
500  {
501  MSQ_DBGOUT(debugLevel) << " o TermCrit -- INTERRUPTED" << msq_stdio::endl;
502  return true;
503  }
504 
505  //if terminating on numbering of inner iterations
508  {
509  return_flag = true;
510  MSQ_DBGOUT(debugLevel) << " o TermCrit -- Reached " << iterationBound << " iterations." << msq_stdio::endl;
511  }
512 
514  {
515  return_flag=true;
516  MSQ_DBGOUT(debugLevel) << " o TermCrit -- Exceeded CPU time." << msq_stdio::endl;
517  }
518 
519 
521  && maxSquaredMovement >= 0.0)
522  {
523  MSQ_DBGOUT(debugLevel) << " o TermCrit -- Maximuim vertex movement: "
524  << sqrt(maxSquaredMovement) << msq_stdio::endl;
525 
528  {
529  return_flag = true;
530  }
531 
534  {
535  return_flag = true;
536  }
537 
538  // Clear this value at the end of each iteration.
539  maxSquaredMovement = -1.0;
540  }
541 
544  {
545  return_flag = true;
546  }
547 
550  {
551  return_flag = true;
552  }
553 
556  {
557  return_flag = true;
558  }
559 
562  {
563  return_flag = true;
564  }
565 
568  {
569  return_flag = true;
570  }
571 
575  {
576  return_flag = true;
577  }
578 
581  {
582  return_flag = true;
583  }
584 
588  {
589  return_flag = true;
590  }
591 
593  {
594  return_flag = true;
595  MSQ_DBGOUT(debugLevel) << " o TermCrit -- " << vertexMovementExceedsBound
596  << " vertices out of bounds." << msq_stdio::endl;
597  }
598 
599  // clear this value at the end of each iteration
601 
602  //if none of the criteria were satisfied
603  return return_flag;
604 }
Terminates when a the maximum distance moved by any vertex during the previous iteration is below the...
static bool interrupt()
Check if an interrupt was seen.
Terminates when the decrease in the objective function value since the previous iteration is below th...
Terminates when any vertex leaves the bounding box, defined by the given value, d.
checks the gradient of objective function against a double and stops when
double sqrt(double d)
Definition: double.h:73
Terminates when a the maximum distance moved by any vertex during the previous iteration is below the...
terminates on the j_th iteration when That is, terminates when the norm of the gradient is small tha...
Terminates when the decrease in the objective function value since the previous iteration is below th...
double since_birth() const
Terminates when the objective function value is smaller than the given scalar value.
Terminates when the algorithm exceeds an allotted time limit (given in seconds).
long unsigned int terminationCriterionFlag
Bit flag of termination crit.
Terminates when the number of iterations exceeds a given integer.
Terminates when the objective function value is smaller than the given scalar value times the origina...
checks the gradient of objective function against a double and stops when
#define MSQ_DBGOUT(flag)
Check debug flag and return ostream associated with flag.

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

msq_std::vector< Vector3D > mGrad
private
double successiveImprovementsAbsoluteEps
private

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