MAiNGO
maingo::ubp::KnitroProblem Class Reference

Class for representing problems to be solved by Knitro, providing an interface to the problem definition in problem.h. More...

#include <knitroProblem.h>

Inheritance diagram for maingo::ubp::KnitroProblem:

Public Member Functions

 KnitroProblem (unsigned nvarIn, unsigned neqIn, unsigned nineqIn, const unsigned nineqSquashIn, const std::vector< babBase::OptimizationVariable > &variables, UbpStructure *structureIn, std::vector< Constraint > *constraintPropertiesIn, std::shared_ptr< DagObj > dagObj)
 Constructor actually used in ubp.cpp. Initializes the corresponding members. More...
 
virtual ~KnitroProblem ()
 Destructor. More...
 
double evaluateFC (const double *const x, double *const c, double *const objGrad, double *const jac)
 Function called by Knitro to get values of the objective and constraints at a point x. More...
 
int evaluateGA (const double *const x, double *const objGrad, double *const jac)
 Function called by Knitro to get derivatives of the objective and constraints at point x. More...
 
int evaluateHess (const double *const x, double objScaler, const double *const lambda, double *const hess)
 Function called by Knitro to get the hessian of the lagrangian at point x. More...
 

Private Member Functions

void _setObjectiveProperties ()
 Set properties of objective function, i.e., type (linear, quadratic, general) More...
 
void _setVariableProperties ()
 Set properties of variables, i.e., type (continuous, binary, integer) More...
 
void _setConstraintProperties ()
 Set properties of constraints, i.e., bounds and type (linear, quadratic, general) More...
 
void _setDerivativeProperties ()
 Set properties of derivatives, i.e., correct indices for non zeros in Jacobian. More...
 
 KnitroProblem (const KnitroProblem &)
 
KnitroProblemoperator= (const KnitroProblem &)
 

Private Attributes

Internal Knitro variables
unsigned _nvar
 
unsigned _nineq
 
unsigned _nineqSquash
 
unsigned _neq
 
UbpStructure_structure
 
std::vector< Constraint > * _constraintProperties
 
std::vector< babBase::OptimizationVariable_optimizationVariables
 

Detailed Description

Class for representing problems to be solved by Knitro, providing an interface to the problem definition in problem.h.

This class provides an interface between Knitro and the problem definition in problem.h. by evaluating the Model equations and preparing the information required by Knitro. An instance of this class is handed to Knitro as an argument of its KN_solve routine in ubpKnitro.cpp. For more information on the basic interface see https://www.artelys.com/tools/knitro_doc/3_referenceManual/callableLibraryAPI.html#basic-problem-construction .

Constructor & Destructor Documentation

◆ KnitroProblem() [1/2]

maingo::ubp::KnitroProblem::KnitroProblem ( unsigned  nvarIn,
unsigned  neqIn,
unsigned  nineqIn,
const unsigned  nineqSquashIn,
const std::vector< babBase::OptimizationVariable > &  variables,
UbpStructure structureIn,
std::vector< Constraint > *  constraintPropertiesIn,
std::shared_ptr< DagObj dagObj 
)

Constructor actually used in ubp.cpp. Initializes the corresponding members.

Parameters
[in]nvarInis the number of optimization variables
[in]neqInis the number of equality constraints
[in]nineqInis the number of inequality constraints
[in]nineqSquashInis the number of squash inequality constraints which are to be used only if the squash node has been used
[in]variablesare the original problem variables
[in]structureInis a struct containing information on sparsity patterns of the Lagrangian and Hessian
[in]constraintPropertiesInis a pointer to the constraint properties determined by MAiNGO
[in]dagObjis a pointer to the struct holding the DAG to be evaluated

◆ ~KnitroProblem()

virtual maingo::ubp::KnitroProblem::~KnitroProblem ( )
virtual

Destructor.

◆ KnitroProblem() [2/2]

maingo::ubp::KnitroProblem::KnitroProblem ( const KnitroProblem )
private

default copy constructor declared private to prevent use

Member Function Documentation

◆ _setConstraintProperties()

void maingo::ubp::KnitroProblem::_setConstraintProperties ( )
private

Set properties of constraints, i.e., bounds and type (linear, quadratic, general)

◆ _setDerivativeProperties()

void maingo::ubp::KnitroProblem::_setDerivativeProperties ( )
private

Set properties of derivatives, i.e., correct indices for non zeros in Jacobian.

◆ _setObjectiveProperties()

void maingo::ubp::KnitroProblem::_setObjectiveProperties ( )
private

Set properties of objective function, i.e., type (linear, quadratic, general)

◆ _setVariableProperties()

void maingo::ubp::KnitroProblem::_setVariableProperties ( )
private

Set properties of variables, i.e., type (continuous, binary, integer)

◆ evaluateFC()

double maingo::ubp::KnitroProblem::evaluateFC ( const double *const  x,
double *const  c,
double *const  objGrad,
double *const  jac 
)

Function called by Knitro to get values of the objective and constraints at a point x.

Parameters
[in]xis the current point
[out]cis the value of constraints
[out]objGradis the gradient of the objective at x (not set in this function)
[out]jacholds the Jacobian values at x (not set in this function)
Returns
Returns the value of the objective function at x

◆ evaluateGA()

int maingo::ubp::KnitroProblem::evaluateGA ( const double *const  x,
double *const  objGrad,
double *const  jac 
)

Function called by Knitro to get derivatives of the objective and constraints at point x.

Parameters
[in]xis the current point
[out]objGradis the gradient of the objective at x
[out]jacholds the Jacobian values at x
Returns
Returns the value of the gradients of the objective function at x

◆ evaluateHess()

int maingo::ubp::KnitroProblem::evaluateHess ( const double *const  x,
double  objScaler,
const double *const  lambda,
double *const  hess 
)

Function called by Knitro to get the hessian of the lagrangian at point x.

Parameters
[in]xis the current point
[in]objScaleris value to scale objective component of the Hessian.
[in]lambdacontains the values of the dual variables to evaluate.
[out]hessholds the values of non-zero elements of the Hessian to be evaluated at x.
Returns
KTR_RC_CALLBACK_ERR, a KNITRO error code indicating an error in evaluating the second derivatives.

◆ operator=()

KnitroProblem& maingo::ubp::KnitroProblem::operator= ( const KnitroProblem )
private

default assignment operator declared private to prevent use

Member Data Documentation

◆ _constraintProperties

std::vector<Constraint>* maingo::ubp::KnitroProblem::_constraintProperties
private

pointer to constraint properties determined by MAiNGO

◆ _neq

unsigned maingo::ubp::KnitroProblem::_neq
private

number of equalities

◆ _nineq

unsigned maingo::ubp::KnitroProblem::_nineq
private

number of inequalities

◆ _nineqSquash

unsigned maingo::ubp::KnitroProblem::_nineqSquash
private

number of squash inequalities

◆ _nvar

unsigned maingo::ubp::KnitroProblem::_nvar
private

number of variables

◆ _optimizationVariables

std::vector<babBase::OptimizationVariable> maingo::ubp::KnitroProblem::_optimizationVariables
private

optimization variables - needed to set if continuous, integer, binary

◆ _structure

UbpStructure* maingo::ubp::KnitroProblem::_structure
private

struct storing information on the problem structure


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