Ipopt Documentation  
IpStdCInterface.h File Reference
#include "IpoptConfig.h"
#include "IpReturnCodes.h"

Go to the source code of this file.

Macros

#define TRUE   (1)
 
#define FALSE   (0)
 

Typedefs

typedef double Number
 Type for all number. More...
 
typedef int Index
 Type for all indices. More...
 
typedef int Int
 Type for all integers. More...
 
typedef struct IpoptProblemInfo * IpoptProblem
 Pointer to an Ipopt Problem. More...
 
typedef int Bool
 define a boolean type for C More...
 
typedef void * UserDataPtr
 A pointer for anything that is to be passed between the called and individual callback function. More...
 
typedef Bool(* Eval_F_CB) (Index n, Number *x, Bool new_x, Number *obj_value, UserDataPtr user_data)
 Type defining the callback function for evaluating the value of the objective function. More...
 
typedef Bool(* Eval_Grad_F_CB) (Index n, Number *x, Bool new_x, Number *grad_f, UserDataPtr user_data)
 Type defining the callback function for evaluating the gradient of the objective function. More...
 
typedef Bool(* Eval_G_CB) (Index n, Number *x, Bool new_x, Index m, Number *g, UserDataPtr user_data)
 Type defining the callback function for evaluating the value of the constraint functions. More...
 
typedef Bool(* Eval_Jac_G_CB) (Index n, Number *x, Bool new_x, Index m, Index nele_jac, Index *iRow, Index *jCol, Number *values, UserDataPtr user_data)
 Type defining the callback function for evaluating the Jacobian of the constrant functions. More...
 
typedef Bool(* Eval_H_CB) (Index n, Number *x, Bool new_x, Number obj_factor, Index m, Number *lambda, Bool new_lambda, Index nele_hess, Index *iRow, Index *jCol, Number *values, UserDataPtr user_data)
 Type defining the callback function for evaluating the Hessian of the Lagrangian function. More...
 
typedef Bool(* Intermediate_CB) (Index alg_mod, Index iter_count, Number obj_value, Number inf_pr, Number inf_du, Number mu, Number d_norm, Number regularization_size, Number alpha_du, Number alpha_pr, Index ls_trials, UserDataPtr user_data)
 Type defining the callback function for giving intermediate execution control to the user. More...
 

Functions

IPOPTLIB_EXPORT IpoptProblem CreateIpoptProblem (Index n, Number *x_L, Number *x_U, Index m, Number *g_L, Number *g_U, Index nele_jac, Index nele_hess, Index index_style, Eval_F_CB eval_f, Eval_G_CB eval_g, Eval_Grad_F_CB eval_grad_f, Eval_Jac_G_CB eval_jac_g, Eval_H_CB eval_h)
 Function for creating a new Ipopt Problem object. More...
 
IPOPTLIB_EXPORT void FreeIpoptProblem (IpoptProblem ipopt_problem)
 Method for freeing a previously created IpoptProblem. More...
 
IPOPTLIB_EXPORT Bool AddIpoptStrOption (IpoptProblem ipopt_problem, char *keyword, char *val)
 Function for adding a string option. More...
 
IPOPTLIB_EXPORT Bool AddIpoptNumOption (IpoptProblem ipopt_problem, char *keyword, Number val)
 Function for adding a Number option. More...
 
IPOPTLIB_EXPORT Bool AddIpoptIntOption (IpoptProblem ipopt_problem, char *keyword, Int val)
 Function for adding an Int option. More...
 
IPOPTLIB_EXPORT Bool OpenIpoptOutputFile (IpoptProblem ipopt_problem, char *file_name, Int print_level)
 Function for opening an output file for a given name with given printlevel. More...
 
IPOPTLIB_EXPORT Bool SetIpoptProblemScaling (IpoptProblem ipopt_problem, Number obj_scaling, Number *x_scaling, Number *g_scaling)
 Optional function for setting scaling parameter for the NLP. More...
 
IPOPTLIB_EXPORT Bool SetIntermediateCallback (IpoptProblem ipopt_problem, Intermediate_CB intermediate_cb)
 Setting a callback function for the "intermediate callback" method in the TNLP. More...
 
IPOPTLIB_EXPORT enum ApplicationReturnStatus IpoptSolve (IpoptProblem ipopt_problem, Number *x, Number *g, Number *obj_val, Number *mult_g, Number *mult_x_L, Number *mult_x_U, UserDataPtr user_data)
 Function calling the Ipopt optimization algorithm for a problem previously defined with CreateIpoptProblem. More...
 

Macro Definition Documentation

◆ TRUE

#define TRUE   (1)

Definition at line 56 of file IpStdCInterface.h.

◆ FALSE

#define FALSE   (0)

Definition at line 59 of file IpStdCInterface.h.

Typedef Documentation

◆ Number

typedef double Number

Type for all number.

We need to make sure that this is identical with what is defined in Common/IpTypes.hpp

Definition at line 30 of file IpStdCInterface.h.

◆ Index

typedef int Index

Type for all indices.

We need to make sure that this is identical with what is defined in Common/IpTypes.hpp

Definition at line 36 of file IpStdCInterface.h.

◆ Int

typedef int Int

Type for all integers.

We need to make sure that this is identical with what is defined in Common/IpTypes.hpp

Definition at line 42 of file IpStdCInterface.h.

◆ IpoptProblem

typedef struct IpoptProblemInfo* IpoptProblem

Pointer to an Ipopt Problem.

Definition at line 51 of file IpStdCInterface.h.

◆ Bool

typedef int Bool

define a boolean type for C

Definition at line 54 of file IpStdCInterface.h.

◆ UserDataPtr

typedef void* UserDataPtr

A pointer for anything that is to be passed between the called and individual callback function.

Definition at line 63 of file IpStdCInterface.h.

◆ Eval_F_CB

typedef Bool(* Eval_F_CB) (Index n, Number *x, Bool new_x, Number *obj_value, UserDataPtr user_data)

Type defining the callback function for evaluating the value of the objective function.

Return value should be set to false if there was a problem doing the evaluation.

See also Ipopt::TNLP::eval_f.

Definition at line 71 of file IpStdCInterface.h.

◆ Eval_Grad_F_CB

typedef Bool(* Eval_Grad_F_CB) (Index n, Number *x, Bool new_x, Number *grad_f, UserDataPtr user_data)

Type defining the callback function for evaluating the gradient of the objective function.

Return value should be set to false if there was a problem doing the evaluation.

See also Ipopt::TNLP::eval_grad_f.

Definition at line 85 of file IpStdCInterface.h.

◆ Eval_G_CB

typedef Bool(* Eval_G_CB) (Index n, Number *x, Bool new_x, Index m, Number *g, UserDataPtr user_data)

Type defining the callback function for evaluating the value of the constraint functions.

Return value should be set to false if there was a problem doing the evaluation.

See also Ipopt::TNLP::eval_g.

Definition at line 99 of file IpStdCInterface.h.

◆ Eval_Jac_G_CB

typedef Bool(* Eval_Jac_G_CB) (Index n, Number *x, Bool new_x, Index m, Index nele_jac, Index *iRow, Index *jCol, Number *values, UserDataPtr user_data)

Type defining the callback function for evaluating the Jacobian of the constrant functions.

Return value should be set to false if there was a problem doing the evaluation.

See also Ipopt::TNLP::eval_jac_g.

Definition at line 114 of file IpStdCInterface.h.

◆ Eval_H_CB

typedef Bool(* Eval_H_CB) (Index n, Number *x, Bool new_x, Number obj_factor, Index m, Number *lambda, Bool new_lambda, Index nele_hess, Index *iRow, Index *jCol, Number *values, UserDataPtr user_data)

Type defining the callback function for evaluating the Hessian of the Lagrangian function.

Return value should be set to false if there was a problem doing the evaluation.

See also Ipopt::TNLP::eval_h.

Definition at line 132 of file IpStdCInterface.h.

◆ Intermediate_CB

typedef Bool(* Intermediate_CB) (Index alg_mod, Index iter_count, Number obj_value, Number inf_pr, Number inf_du, Number mu, Number d_norm, Number regularization_size, Number alpha_du, Number alpha_pr, Index ls_trials, UserDataPtr user_data)

Type defining the callback function for giving intermediate execution control to the user.

If set, it is called once per iteration, providing the user with some information on the state of the optimization. This can be used to print some user-defined output. It also gives the user a way to terminate the optimization prematurely. If this method returns false, Ipopt will terminate the optimization.

See also Ipopt::TNLP::intermediate_callback.

Parameters
alg_modalgorithm mode: 0 is regular, 1 is restoration

Definition at line 157 of file IpStdCInterface.h.

Function Documentation

◆ CreateIpoptProblem()

IPOPTLIB_EXPORT IpoptProblem CreateIpoptProblem ( Index  n,
Number x_L,
Number x_U,
Index  m,
Number g_L,
Number g_U,
Index  nele_jac,
Index  nele_hess,
Index  index_style,
Eval_F_CB  eval_f,
Eval_G_CB  eval_g,
Eval_Grad_F_CB  eval_grad_f,
Eval_Jac_G_CB  eval_jac_g,
Eval_H_CB  eval_h 
)

Function for creating a new Ipopt Problem object.

This function returns an object that can be passed to the IpoptSolve call. It contains the basic definition of the optimization problem, such as number of variables and constraints, bounds on variables and constraints, information about the derivatives, and the callback function for the computation of the optimization problem functions and derivatives. During this call, the options file PARAMS.DAT is read as well.

If NULL is returned, there was a problem with one of the inputs or reading the options file.

See also Ipopt::TNLP::get_nlp_info and Ipopt::TNLP::get_bounds_info.

Parameters
nNumber of optimization variables
x_LLower bounds on variables

This array of size n is copied internally, so that the caller can change the incoming data after return without that IpoptProblem is modified. Any value less or equal than the number specified by option 'nlp_lower_bound_inf' is interpreted to be minus infinity.

Parameters
x_UUpper bounds on variables

This array of size n is copied internally, so that the caller can change the incoming data after return without that IpoptProblem is modified. Any value greater or equal than the number specified by option 'nlp_upper_bound_inf' is interpreted to be plus infinity.

Parameters
mNumber of constraints
g_LLower bounds on constraints

This array of size m is copied internally, so that the caller can change the incoming data after return without that IpoptProblem is modified. Any value less or equal than the number specified by option 'nlp_lower_bound_inf' is interpreted to be minus infinity.

Parameters
g_UUpper bounds on constraints

This array of size m is copied internally, so that the caller can change the incoming data after return without that IpoptProblem is modified. Any value greater or equal than the number specified by option 'nlp_upper_bound_inf' is interpreted to be plus infinity.

Parameters
nele_jacNumber of non-zero elements in constraint Jacobian
nele_hessNumber of non-zero elements in Hessian of Lagrangian
index_styleIndexing style for iRow & jCol, 0 for C style, 1 for Fortran style
eval_fCallback function for evaluating objective function
eval_gCallback function for evaluating constraint functions
eval_grad_fCallback function for evaluating gradient of objective function
eval_jac_gCallback function for evaluating Jacobian of constraint functions
eval_hCallback function for evaluating Hessian of Lagrangian function

◆ FreeIpoptProblem()

IPOPTLIB_EXPORT void FreeIpoptProblem ( IpoptProblem  ipopt_problem)

Method for freeing a previously created IpoptProblem.

After freeing an IpoptProblem, it cannot be used anymore.

◆ AddIpoptStrOption()

IPOPTLIB_EXPORT Bool AddIpoptStrOption ( IpoptProblem  ipopt_problem,
char *  keyword,
char *  val 
)

Function for adding a string option.

Returns
FALSE, if the option could not be set (e.g., if keyword is unknown)

◆ AddIpoptNumOption()

IPOPTLIB_EXPORT Bool AddIpoptNumOption ( IpoptProblem  ipopt_problem,
char *  keyword,
Number  val 
)

Function for adding a Number option.

Returns
FALSE, if the option could not be set (e.g., if keyword is unknown)

◆ AddIpoptIntOption()

IPOPTLIB_EXPORT Bool AddIpoptIntOption ( IpoptProblem  ipopt_problem,
char *  keyword,
Int  val 
)

Function for adding an Int option.

Returns
FALSE, if the option could not be set (e.g., if keyword is unknown) @

◆ OpenIpoptOutputFile()

IPOPTLIB_EXPORT Bool OpenIpoptOutputFile ( IpoptProblem  ipopt_problem,
char *  file_name,
Int  print_level 
)

Function for opening an output file for a given name with given printlevel.

Returns
FALSE, if there was a problem opening the file.

◆ SetIpoptProblemScaling()

IPOPTLIB_EXPORT Bool SetIpoptProblemScaling ( IpoptProblem  ipopt_problem,
Number  obj_scaling,
Number x_scaling,
Number g_scaling 
)

Optional function for setting scaling parameter for the NLP.

This corresponds to the TNLP::get_scaling_parameters method. If the pointers x_scaling or g_scaling are NULL, then no scaling for x resp. g is done.

◆ SetIntermediateCallback()

IPOPTLIB_EXPORT Bool SetIntermediateCallback ( IpoptProblem  ipopt_problem,
Intermediate_CB  intermediate_cb 
)

Setting a callback function for the "intermediate callback" method in the TNLP.

This gives control back to the user once per iteration. If set, it provides the user with some information on the state of the optimization. This can be used to print some user-defined output. It also gives the user a way to terminate the optimization prematurely. If the callback method returns false, Ipopt will terminate the optimization. Calling this set method to set the CB pointer to NULL disables the intermediate callback functionality.

◆ IpoptSolve()

IPOPTLIB_EXPORT enum ApplicationReturnStatus IpoptSolve ( IpoptProblem  ipopt_problem,
Number x,
Number g,
Number obj_val,
Number mult_g,
Number mult_x_L,
Number mult_x_U,
UserDataPtr  user_data 
)

Function calling the Ipopt optimization algorithm for a problem previously defined with CreateIpoptProblem.

Returns
outcome of the optimization procedure (e.g., success, failure etc).
Parameters
ipopt_problemProblem that is to be optimized.

Ipopt will use the options previously specified with AddIpoptOption (etc) for this problem.

Parameters
xInput: Starting point; Output: Optimal solution
gValues of constraint at final point (output only; ignored if set to NULL)
obj_valFinal value of objective function (output only; ignored if set to NULL)
mult_gInput: Initial values for the constraint multipliers (only if warm start option is chosen); Output: Final multipliers for constraints (ignored if set to NULL)
mult_x_LInput: Initial values for the multipliers for lower variable bounds (only if warm start option is chosen); Output: Final multipliers for lower variable bounds (ignored if set to NULL)
mult_x_UInput: Initial values for the multipliers for upper variable bounds (only if warm start option is chosen); Output: Final multipliers for upper variable bounds (ignored if set to NULL)
user_dataPointer to user data.

This will be passed unmodified to the callback functions.