|
Minotaur 0.4.1
Docs for developers
|
#include <Objective.h>
Public Member Functions | |
| Objective () | |
| Default constructor. | |
| Objective (double cb=0.0, ObjectiveType otyp=Minimize) | |
| Objective (FunctionPtr fPtr, double cb=0.0, ObjectiveType otyp=Minimize) | |
| Objective (FunctionPtr fPtr, double cb, ObjectiveType otyp, std::string name) | |
| virtual | ~Objective () |
| Destroy. | |
| double | getConstant () const |
| Return the constant term in this objective. | |
| ObjectiveType | getObjectiveType () const |
| Return the type (Maximize or Minimize) of this objective. | |
| FunctionType | getFunctionType () const |
| Return the type of the function in objective. | |
| ObjState | getState () const |
| Return the state of the objective. Fixed, removed, freed etc. | |
| virtual const std::string | getName () const |
| FunctionPtr | getFunction () const |
| Return the function in the objective. | |
| LinearFunctionPtr | getLinearFunction () const |
| QuadraticFunctionPtr | getQuadraticFunction () const |
| NonlinearFunctionPtr | getNonlinearFunction () const |
| void | write (std::ostream &out) const |
| Print the objective function to the output stream. | |
| double | eval (const double *x, int *err) const |
| void | evalGradient (const double *x, double *grad_f, int *error) |
| void | evalGradient (VariableGroup &point, double *grad_f) |
Friends | |
| class | Problem |
The Objective class is meant to implement an objective function for the problem (or formulation). There are only a few differences between Objective and Constraint. The Objective has a sense (Maximize or Minimize) associated with it. The objective may also have a constant term. Like a constraint, an objective has a function and lower and upper bounds. These bounds are optional. An objective must have the ability to be evaluated at a given point, and also to return its gradient at a given point.
Minotaur will always minimize an objective internally. So if the objective is to maximize, it will try to minimize the negative.
| Objective::Objective | ( | double | cb = 0.0, |
| ObjectiveType | otyp = Minimize |
||
| ) |
Create an objective with a specific id, constant term and sense. Does not need a function. A default name is created.
| Objective::Objective | ( | FunctionPtr | fPtr, |
| double | cb, | ||
| ObjectiveType | otyp, | ||
| std::string | name | ||
| ) |
Create an objective with a specific function, id, constant term, sense and a name.
| double Objective::eval | ( | const double * | x, |
| int * | err | ||
| ) | const |
Evaluate the objective function (along with the constant term) at the given point x.
| void Objective::evalGradient | ( | const double * | x, |
| double * | grad_f, | ||
| int * | error | ||
| ) |
Evaluate the gradient at the given point x and fill in the gradient values in the array grad_f. The array grad_f is assumed to have the required size (equal to number of variables in the problem).
| void Minotaur::Objective::evalGradient | ( | VariableGroup & | point, |
| double * | grad_f | ||
| ) |
Evaluate the gradient at the given point and fill in the gradient values in the array grad_f. The array grad_f is assumed to have the required size (equal to number of variables in the problem).
| LinearFunctionPtr Objective::getLinearFunction | ( | ) | const |
Return the linear function part of the objective function. Could be NULL.
| NonlinearFunctionPtr Objective::getNonlinearFunction | ( | ) | const |
Return the nonlinear function part of the objective function. Could be NULL.
| QuadraticFunctionPtr Objective::getQuadraticFunction | ( | ) | const |
Return the quadratic function part of the objective function. Could be NULL.
|
friend |
Only Problem class can modify an Objective. All modification methods are private.