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

Adds a scalar to a given ObjectiveFunction. More...

#include <CompositeOFScalarAdd.hpp>

Inheritance diagram for CompositeOFScalarAdd:
Collaboration diagram for CompositeOFScalarAdd:

Public Member Functions

 CompositeOFScalarAdd (double, ObjectiveFunction *)
 
virtual ~CompositeOFScalarAdd ()
 
virtual bool concrete_evaluate (PatchData &patch, double &fval, MsqError &err)
 
virtual msq_std::list
< QualityMetric * > 
get_quality_metric_list ()
 Returns the QualityMetric list assossiated with objFunc. More...
 
 CompositeOFScalarAdd (double, ObjectiveFunction *)
 
virtual ~CompositeOFScalarAdd ()
 
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...
 
QualityMetricget_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...
 
QualityMetricget_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

double mAlpha
 
ObjectiveFunctionobjFunc
 

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 }
 

Detailed Description

Adds a scalar to a given ObjectiveFunction.

Definition at line 53 of file includeLinks/CompositeOFScalarAdd.hpp.

Constructor & Destructor Documentation

CompositeOFScalarAdd ( double  alp,
ObjectiveFunction Obj1 
)

Sets the QualityMetric pointer to the metric associated with Obj1. The new ObjectiveFunction's negateFlag is also the same as that of Obj1. This objective function defaults to the analytical gradient which essentially just calls Obj1's gradient function.

Parameters
alp(double)
Obj1(ObjectiveFunction*)

Definition at line 50 of file ObjectiveFunction/CompositeOFScalarAdd.cpp.

References ObjectiveFunction::ANALYTICAL_GRADIENT, ObjectiveFunction::get_quality_metric(), CompositeOFScalarAdd::mAlpha, CompositeOFScalarAdd::objFunc, ObjectiveFunction::set_gradient_type(), ObjectiveFunction::set_negate_flag(), and ObjectiveFunction::set_quality_metric().

50  {
52  objFunc=Obj1;
53  mAlpha=alp;
54  set_negate_flag(1);
56 }
void set_gradient_type(GRADIENT_TYPE grad)
Set gradType to either NUMERICAL_GRADIENT or ANALYTICAL_GRADIENT.
void set_quality_metric(QualityMetric *qm)
Set the value of qMetric.
every differentiable function should have an analytical gradient implemented.
void set_negate_flag(int neg)
Set the value of ObjectiveFunction&#39;s negateFlag. Unless composite, concrete ObjectiveFunctions should...

Here is the call graph for this function:

~CompositeOFScalarAdd ( )
virtual

Definition at line 60 of file ObjectiveFunction/CompositeOFScalarAdd.cpp.

60  {
61 
62 }
CompositeOFScalarAdd ( double  ,
ObjectiveFunction  
)
virtual ~CompositeOFScalarAdd ( )
virtual

Member Function Documentation

bool compute_analytical_gradient ( PatchData patch,
Vector3D *const &  grad,
double &  OF_val,
MsqError err,
size_t  array_size 
)
protectedvirtual

Analytically computes the composite objective function's gradient by scaling the gradient returned objFunc->compute_gradient().

Parameters
patchThe PatchData object for which the objective function gradient is computed.
gradAn array of Vector3D, at least the size of the number of vertices in the patch.
array_sizeis the size of the grad Vector3D[] array and must correspond to the number of vertices in the patch.

Reimplemented from ObjectiveFunction.

Definition at line 99 of file ObjectiveFunction/CompositeOFScalarAdd.cpp.

References ObjectiveFunction::compute_gradient(), CompositeOFScalarAdd::mAlpha, MSQ_ERRZERO, MSQ_FUNCTION_TIMER, and CompositeOFScalarAdd::objFunc.

104 {
105  MSQ_FUNCTION_TIMER( "CompositeOFScalarAdd::compute_analytical_gradient" );
106  bool rval=objFunc->compute_gradient(patch, grad, OF_val,err, array_size); MSQ_ERRZERO(err);
107  OF_val+=mAlpha;
108  return rval;
109 }
#define MSQ_ERRZERO(err)
Return zero/NULL on error.
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...

Here is the call graph for this function:

bool compute_analytical_gradient ( PatchData patch,
Vector3D *const &  grad,
double &  OF_val,
MsqError err,
size_t  array_size 
)
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'.

Parameters
patchThe PatchData object for which the objective function gradient is computed.
gradAn array of Vector3D, at least the size of the number of vertices in the patch.
OF_valis set to the value of the objective function.
array_sizeis the size of the grad Vector3D[] array and must correspond to the number of vertices in the patch.

Reimplemented from ObjectiveFunction.

virtual bool concrete_evaluate ( PatchData patch,
double &  fval,
MsqError err 
)
virtual

Evaluate the objective function on a given patch.

Implements ObjectiveFunction.

bool concrete_evaluate ( PatchData patch,
double &  fval,
MsqError err 
)
virtual

Computes fval= mAlpha+objFunc->evaluate(patch,err). Note that since Obj's evaluate() function is called (as opposed to its concrete_evaluate) the returned value has been multiplied by objFunc's negateFlag (that is, if objFunc needed to be maximized then the value has been multiplied by negative one so that it may be minimized instead.) Functions returns `false' if and only if objFunc->evaluate() returns `false'.

Implements ObjectiveFunction.

Definition at line 72 of file ObjectiveFunction/CompositeOFScalarAdd.cpp.

References ObjectiveFunction::evaluate(), CompositeOFScalarAdd::mAlpha, MSQ_CHKERR, and CompositeOFScalarAdd::objFunc.

73  {
74  //if invalid return false without calculating fval.
75  bool b = objFunc->evaluate(patch, fval, err);
76  if( MSQ_CHKERR(err) || !b ){
77  fval = 0.0;
78  return false;
79  }
80 
81  fval+=mAlpha;
82  return true;
83 }
bool evaluate(PatchData &patch, double &fval, MsqError &err)
#define MSQ_CHKERR(err)
Mesquite&#39;s Error Checking macro.

Here is the call graph for this function:

msq_std::list< QualityMetric * > get_quality_metric_list ( )
virtual

Returns the QualityMetric list assossiated with objFunc.

Reimplemented from ObjectiveFunction.

Definition at line 86 of file ObjectiveFunction/CompositeOFScalarAdd.cpp.

References ObjectiveFunction::get_quality_metric_list(), and CompositeOFScalarAdd::objFunc.

86  {
88 }
virtual msq_std::list< QualityMetric * > get_quality_metric_list()

Here is the call graph for this function:

virtual msq_std::list<QualityMetric*> get_quality_metric_list ( )
virtual

returns a list of all associated metrics;

Reimplemented from ObjectiveFunction.

Member Data Documentation


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