Minotaur 0.4.1
Docs for developers
Public Member Functions | Friends | List of all members
Minotaur::Objective Class Reference

#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
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ Objective() [1/2]

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() [2/2]

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.

Member Function Documentation

◆ eval()

double Objective::eval ( const double *  x,
int *  err 
) const

Evaluate the objective function (along with the constant term) at the given point x.

◆ evalGradient() [1/2]

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).

◆ evalGradient() [2/2]

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).

Todo:
XXX: replace this function by the one below.

◆ getLinearFunction()

LinearFunctionPtr Objective::getLinearFunction ( ) const

Return the linear function part of the objective function. Could be NULL.

◆ getNonlinearFunction()

NonlinearFunctionPtr Objective::getNonlinearFunction ( ) const

Return the nonlinear function part of the objective function. Could be NULL.

◆ getQuadraticFunction()

QuadraticFunctionPtr Objective::getQuadraticFunction ( ) const

Return the quadratic function part of the objective function. Could be NULL.

Friends And Related Function Documentation

◆ Problem

friend class Problem
friend

Only Problem class can modify an Objective. All modification methods are private.


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

Minotaur source code documented by Doxygen 1.9.4 on Thu Apr 24 2025