40 #include "TerminationCriterion.hpp"
41 #include "MeshSet.hpp"
42 #include "MsqVertex.hpp"
43 #include "MsqInterrupt.hpp"
44 #include "ObjectiveFunction.hpp"
45 #include "MsqError.hpp"
46 #include "MsqDebug.hpp"
64 initialVerticesMemento(0),
65 previousVerticesMemento(0),
232 PatchData global_patch;
237 PatchDataParameters global_patch_params;
240 ms.get_next_patch( global_patch, global_patch_params, err );
291 int num_vertices=pd.num_vertices();
292 mGrad.resize( num_vertices );
298 MSQ_SETERR(err)(
"Initial patch is invalid for gradient computation.",
326 MSQ_SETERR(err)(
"Error termination criteria set which uses objective "
327 "functions, but no objective function is available.",
342 if (totalFlag & (GRAD_FLAGS|OF_FLAGS))
381 mGrad.resize( pd.num_vertices() );
385 MSQ_SETERR(err)(
"Initial patch is invalid for gradient compuation.",
394 MSQ_SETERR(err)(
"Invalid patch passed to TerminationCriterion.",
444 PatchData global_patch;
449 PatchDataParameters global_params;
451 ms.get_next_patch( global_patch, global_params, err );
MSQ_ERRRTN(err);
471 MsqVertex* vert = pd.get_vertex_array(err);
472 int num_vert = pd.num_vertices();
475 for(i=0;i<num_vert;++
i)
495 bool return_flag =
false;
596 <<
" vertices out of bounds." << msq_stdio::endl;
619 ObjectiveFunction* obj_ptr,
625 bool b, cull_bool=
false;
626 double prev_m, init_m;
675 case VERTEX_MOVEMENT_RELATIVE:
686 MSQ_SETERR(err)(
"Requested culling method not yet implemented.",
693 pd.set_free_vertices_soft_fixed(err);
MSQ_ERRZERO(err);
697 pd.set_all_vertices_soft_free(err);
MSQ_ERRZERO(err);
715 ms.clear_all_soft_fixed_flags(err);
MSQ_ERRRTN(err);
double successiveImprovementsAbsoluteEps
Terminates when a the maximum distance moved by any vertex during the previous iteration is below the...
const unsigned long GRAD_FLAGS
static bool interrupt()
Check if an interrupt was seen.
#define MSQ_ERRZERO(err)
Return zero/NULL on error.
Terminates when the decrease in the objective function value since the previous iteration is below th...
double gradL2NormAbsoluteEps
double gradL2NormRelativeEps
void cleanup(MeshSet &ms, MsqError &err)
Cleans up after the TerminationCriterion is finished.
double qualityImprovementRelativeEps
double successiveImprovementsRelativeEps
Terminates when any vertex leaves the bounding box, defined by the given value, d.
double boundedVertexMovementEps
void accumulate_patch(PatchData &pd, MsqError &err)
Common code for both inner and outer termination criteria during inner iteration. ...
double currentGradInfNorm
requested functionality is not (yet) implemented
bool evaluate(PatchData &patch, double &fval, MsqError &err)
checks the gradient of objective function against a double and stops when
TerminationCriterion()
Constructor which does not take any arguements.
void reset_outer(MeshSet &ms, ObjectiveFunction *of, MsqError &err)
Clear any data accumulated during an outer iteration.
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.
bool terminate()
Check if termination criterion has been met.
terminates on the j_th iteration when That is, terminates when the norm of the gradient is small tha...
bool cull_vertices(PatchData &pd, ObjectiveFunction *obj_ptr, MsqError &err)
Function which determines whether this patch should be 'culled'.
void reset_patch(PatchData &pd, MsqError &err)
Shared inner and outer initialization during inner loop.
Terminates when the decrease in the objective function value since the previous iteration is below th...
double length(Vector3D *const v, int n)
double since_birth() const
msq_std::vector< Vector3D > mGrad
const unsigned long OF_FLAGS
invalid function argument passed
NVec< 3, double > Vector3D
double qualityImprovementAbsoluteEps
#define MSQ_CHKERR(err)
Mesquite's Error Checking macro.
double maxSquaredMovement
double gradInfNormAbsoluteEps
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.
Terminates when the objective function value is smaller than the given scalar value.
double maxSquaredInitialMovement
double initialGradInfNorm
Terminates when the algorithm exceeds an allotted time limit (given in seconds).
double vertexMovementRelativeEps
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 assoc...
void add_criterion_type_with_double(TCType tc_type, double eps, MsqError &err)
Sets the criterion by specifing the TCType and the eps value.
long unsigned int terminationCriterionFlag
Bit flag of termination crit.
PatchDataVerticesMemento * initialVerticesMemento
double Linf(Vector3D *const v, int n)
void accumulate_inner(PatchData &pd, MsqError &err)
Accumulate data during inner iteration.
long unsigned int cullingMethodFlag
Terminates when the number of iterations exceeds a given integer.
double gradInfNormRelativeEps
int vertexMovementExceedsBound
void remove_criterion_type(TCType tc_type, MsqError &err)
Removes the criterion by specifing just the TCType.
void remove_culling(MsqError &err)
Removes any previously set culling types (sets the culling type to be NONE).
PatchDataVerticesMemento * previousVerticesMemento
double vertexMovementAbsoluteEps
object is in an invalid state
void accumulate_outer(MeshSet &ms, MsqError &err)
Terminates when the objective function value is smaller than the given scalar value times the origina...
void add_criterion_type_with_int(TCType tc_type, int bound, MsqError &err)
Sets the criterion by specifing the TCType and the integer value.
terminates on the j_th iteration when
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.
ObjectiveFunction * OFPtr
#define MSQ_ERRRTN(err)
If passed error is true, return from a void function.