Adds two ObjectiveFunction values together. More...
#include <CompositeOFAdd.hpp>
Public Member Functions | |
CompositeOFAdd (ObjectiveFunction *, ObjectiveFunction *) | |
virtual | ~CompositeOFAdd () |
virtual bool | concrete_evaluate (PatchData &patch, double &fval, MsqError &err) |
virtual msq_std::list < QualityMetric * > | get_quality_metric_list () |
CompositeOFAdd (ObjectiveFunction *, ObjectiveFunction *) | |
virtual | ~CompositeOFAdd () |
virtual bool | concrete_evaluate (PatchData &patch, double &fval, MsqError &err) |
virtual msq_std::list < QualityMetric * > | get_quality_metric_list () |
Public Member Functions inherited from ObjectiveFunction | |
ObjectiveFunction () | |
virtual | ~ObjectiveFunction () |
bool | evaluate (PatchData &patch, double &fval, MsqError &err) |
void | set_gradient_type (GRADIENT_TYPE grad) |
Set gradType to either NUMERICAL_GRADIENT or ANALYTICAL_GRADIENT. More... | |
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 gradType. Function returns 'false' if the patch is not within a required feasible regeion. Otherwise, it returns 'true'. More... | |
bool | compute_hessian (PatchData &patch, MsqHessian &hessian, Vector3D *const &grad, double &OF_val, MsqError &err) |
Calls compute_analytical_hessian. Function returns 'false' if the patch is not within a required feasible regeion. Otherwise, it returns 'true'. More... | |
QualityMetric * | get_quality_metric () |
void | set_quality_metric (QualityMetric *qm) |
Set the value of qMetric. More... | |
void | set_negate_flag (int neg) |
Set the value of ObjectiveFunction's negateFlag. Unless composite, concrete ObjectiveFunctions should set this flag to to the value of the associated QualityMetric's negateFLag. More... | |
int | get_negate_flag () |
Returns negateFlag. More... | |
ObjectiveFunction () | |
virtual | ~ObjectiveFunction () |
bool | evaluate (PatchData &patch, double &fval, MsqError &err) |
void | set_gradient_type (GRADIENT_TYPE grad) |
Set gradType to either NUMERICAL_GRADIENT or ANALYTICAL_GRADIENT. More... | |
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 gradType. Function returns 'false' if the patch is not within a required feasible regeion. Otherwise, it returns 'true'. More... | |
bool | compute_hessian (PatchData &patch, MsqHessian &hessian, Vector3D *const &grad, double &OF_val, MsqError &err) |
Calls compute_analytical_hessian. Function returns 'false' if the patch is not within a required feasible regeion. Otherwise, it returns 'true'. More... | |
QualityMetric * | get_quality_metric () |
void | set_quality_metric (QualityMetric *qm) |
Set the value of qMetric. More... | |
void | set_negate_flag (int neg) |
Set the value of ObjectiveFunction's negateFlag. Unless composite, concrete ObjectiveFunctions should set this flag to to the value of the associated QualityMetric's negateFLag. More... | |
int | get_negate_flag () |
Returns negateFlag. More... | |
Protected Member Functions | |
bool | compute_analytical_gradient (PatchData &patch, Vector3D *const &grad, double &OF_val, MsqError &err, size_t array_size) |
bool | compute_analytical_gradient (PatchData &patch, Vector3D *const &grad, double &OF_val, MsqError &err, size_t array_size) |
Protected Member Functions inherited from ObjectiveFunction | |
bool | compute_numerical_gradient (PatchData &patch, Vector3D *const &grad, double &OF_val, MsqError &err, size_t array_size) |
Non-virtual function which numerically computes the gradient of the Objective Function. Function returns 'false' if the patch is not within a required feasible regeion. Otherwise, it returns 'true'. More... | |
virtual bool | compute_analytical_hessian (PatchData &, MsqHessian &, Vector3D *const &, double &, MsqError &) |
double | get_eps (PatchData &pd, double &local_val, int k, MsqVertex *vertex, MsqError &err) |
Returns eps used in the numerical gradient calculation. More... | |
void | set_use_local_gradient (bool new_bool) |
Sets useLocalGradient This variable determines whether compute_numercial_gradient can use the most efficient gradient calculation. More... | |
bool | compute_numerical_gradient (PatchData &patch, Vector3D *const &grad, double &OF_val, MsqError &err, size_t array_size) |
Non-virtual function which numerically computes the gradient of the Objective Function. Function returns 'false' if the patch is not within a required feasible regeion. Otherwise, it returns 'true'. More... | |
virtual bool | compute_analytical_hessian (PatchData &, MsqHessian &, Vector3D *const &, double &, MsqError &) |
double | get_eps (PatchData &pd, double &local_val, int k, MsqVertex *vertex, MsqError &err) |
Returns eps used in the numerical gradient calculation. More... | |
void | set_use_local_gradient (bool new_bool) |
Sets useLocalGradient This variable determines whether compute_numercial_gradient can use the most efficient gradient calculation. More... | |
Private Attributes | |
ObjectiveFunction * | objFunc1 |
ObjectiveFunction * | objFunc2 |
Additional Inherited Members | |
Public Types inherited from ObjectiveFunction | |
enum | GRADIENT_TYPE { NUMERICAL_GRADIENT, ANALYTICAL_GRADIENT, NUMERICAL_GRADIENT, ANALYTICAL_GRADIENT } |
enum | GRADIENT_TYPE { NUMERICAL_GRADIENT, ANALYTICAL_GRADIENT, NUMERICAL_GRADIENT, ANALYTICAL_GRADIENT } |
Adds two ObjectiveFunction values together.
Definition at line 53 of file includeLinks/CompositeOFAdd.hpp.
CompositeOFAdd | ( | ObjectiveFunction * | Obj1, |
ObjectiveFunction * | Obj2 | ||
) |
Sets the QualityMetric pointer to the metric associated with Obj1 and Obj2 if Obj1 and Obj2 are associated with the same metric. Otherwise, it sets the QualityMetric pointer to NULL. The new ObjectiveFunction's negateFlag is always set to one, because the values produced by obj1 and obj2 have already been multiplied by negative one if it was needed. Defaults to the analytical gradient.
Obj1 | (ObjectiveFunction*) |
Obj2 | (ObjectiveFunction*) |
Definition at line 54 of file ObjectiveFunction/CompositeOFAdd.cpp.
References ObjectiveFunction::ANALYTICAL_GRADIENT, ObjectiveFunction::get_quality_metric(), CompositeOFAdd::objFunc1, CompositeOFAdd::objFunc2, ObjectiveFunction::set_gradient_type(), ObjectiveFunction::set_negate_flag(), and ObjectiveFunction::set_quality_metric().
|
virtual |
Definition at line 68 of file ObjectiveFunction/CompositeOFAdd.cpp.
CompositeOFAdd | ( | ObjectiveFunction * | , |
ObjectiveFunction * | |||
) |
|
virtual |
|
protectedvirtual |
Analytically computes the composite objective function's gradient by combining the gradients returned from objFunc2->compute_gradient() and objFunc2->compute_gradient().
patch | The PatchData object for which the objective function gradient is computed. |
grad | An array of Vector3D, at least the size of the number of vertices in the patch. |
OF_val | The objective function value. |
array_size | is the size of the grad Vector3D[] array and must correspond to the number of vertices in the patch. |
Reimplemented from ObjectiveFunction.
Definition at line 125 of file ObjectiveFunction/CompositeOFAdd.cpp.
References ObjectiveFunction::compute_gradient(), i, MSQ_ERRZERO, MSQ_FUNCTION_TIMER, PatchData::num_vertices(), CompositeOFAdd::objFunc1, and CompositeOFAdd::objFunc2.
|
protectedvirtual |
Fills an array of Vector3D, grad, with the gradient of the objective function computed using the gradient of the quality metric. If the function has not been over-riden in the concrete Objective Function, the base class implementation prints a warning and then defaults to numerical gradient. Function returns 'false' if the patch is not within a required feasible regeion. Otherwise, it returns 'true'.
patch | The PatchData object for which the objective function gradient is computed. |
grad | An array of Vector3D, at least the size of the number of vertices in the patch. |
OF_val | is set to the value of the objective function. |
array_size | is the size of the grad Vector3D[] array and must correspond to the number of vertices in the patch. |
Reimplemented from ObjectiveFunction.
Evaluate the objective function on a given patch.
Implements ObjectiveFunction.
Compute fval= objFunc1->evaluate(patch,err)+objFunc2->evaluate(patch,err). Note that since objFunc1 and objFunc2's evaluate() functions are called (as opposed to their concrete_evaluates) the returned values have already been multiplied by the respective negateFlag (that is, if objFunc1 (or objFunc2) needed to be maximized then the value has been multiplied by negative one so that it may be minimized instead.) Function returns `false' if either objFunc1->concrete_evaluate() or objFunc2->concrete_evaluate() returns `false'; otherwise, function returns `true'.
Implements ObjectiveFunction.
Definition at line 95 of file ObjectiveFunction/CompositeOFAdd.cpp.
References ObjectiveFunction::evaluate(), MSQ_CHKERR, CompositeOFAdd::objFunc1, and CompositeOFAdd::objFunc2.
|
virtual |
Returns the QualityMetric list associated with objFunc1 merged with the QualityMetric list associated with objFunc2. The entries in this merged list may not be unique.
Reimplemented from ObjectiveFunction.
Definition at line 76 of file ObjectiveFunction/CompositeOFAdd.cpp.
References ObjectiveFunction::get_quality_metric_list(), CompositeOFAdd::objFunc1, and CompositeOFAdd::objFunc2.
|
virtual |
returns a list of all associated metrics;
Reimplemented from ObjectiveFunction.
|
private |
Definition at line 67 of file includeLinks/CompositeOFAdd.hpp.
Referenced by CompositeOFAdd::CompositeOFAdd(), CompositeOFAdd::compute_analytical_gradient(), CompositeOFAdd::concrete_evaluate(), and CompositeOFAdd::get_quality_metric_list().
|
private |
Definition at line 68 of file includeLinks/CompositeOFAdd.hpp.
Referenced by CompositeOFAdd::CompositeOFAdd(), CompositeOFAdd::compute_analytical_gradient(), CompositeOFAdd::concrete_evaluate(), and CompositeOFAdd::get_quality_metric_list().