Ipopt Documentation  
 
Loading...
Searching...
No Matches
org.coinor.Ipopt Class Referenceabstract

A Java Native Interface for the Ipopt optimization solver. More...

Public Member Functions

 Ipopt ()
 Creates a new NLP Solver using a default as the DLL name.
 
 Ipopt (String DLL)
 Creates a NLP Solver for the given DLL file.
 
 Ipopt (String path, String DLL)
 Creates a NLP Solver for the given DLL file and path.
 
void dispose ()
 Dispose of the natively allocated memory.
 
boolean create (int n, int m, int nele_jac, int nele_hess, int index_style)
 Create a new problem.
 
boolean setIntegerOption (String keyword, int val)
 Function for setting an integer option.
 
boolean setNumericOption (String keyword, double val)
 Function for setting a number option.
 
boolean setStringOption (String keyword, String val)
 Function for setting a string option.
 
int OptimizeNLP ()
 This function actually solve the problem.
 
boolean get_curr_iterate (long ip_data, long ip_cq, boolean scaled, int n, double x[], double z_L[], double z_U[], int m, double g[], double lambda[])
 Get primal and dual variable values of the current iterate.
 
boolean get_curr_violations (long ip_data, long ip_cq, boolean scaled, int n, double x_L_violation[], double x_U_violation[], double compl_x_L[], double compl_x_U[], double grad_lag_x[], int m, double nlp_constraint_violation[], double compl_g[])
 Get primal and dual infeasibility of the current iterate.
 
double[] getVariableValues ()
 Gives primal variable values at final point.
 
double getObjectiveValue ()
 Gives objective function value at final point.
 
int getStatus ()
 Gives Ipopt status of last OptimizeNLP call.
 
double[] getConstraintValues ()
 Gives constraint function values at final point.
 
double[] getConstraintMultipliers ()
 Gives constraint dual multipliers in final point.
 
double[] getLowerBoundMultipliers ()
 Gives dual multipliers for variable lower bounds in final point.
 
double[] getUpperBoundMultipliers ()
 Gives dual multipliers for variable upper bounds in final point.
 
boolean intermediate_callback (int algorithmmode, int iter, double obj_value, double inf_pr, double inf_du, double mu, double d_norm, double regularization_size, double alpha_du, double alpha_pr, int ls_trials, long ip_data, long ip_cq)
 Intermediate Callback method for the user.
 
boolean get_scaling_parameters (double[] obj_scaling, int n, double[] x_scaling, int m, double[] g_scaling, boolean[] use_x_g_scaling)
 If you using_scaling_parameters = true, this method should be overloaded.
 
int get_number_of_nonlinear_variables ()
 When LBFGS hessian approximation is used, this method should be overloaded.
 
boolean get_list_of_nonlinear_variables (int num_nonlin_vars, int[] pos_nonlin_vars)
 When LBFGS hessian approximation is used, this method should be overloaded.
 

Static Public Attributes

static final int C_STYLE = 0
 Use C index style for iRow and jCol vectors.
 
static final int FORTRAN_STYLE = 1
 Use FORTRAN index style for iRow and jCol vectors.
 
static final int SOLVE_SUCCEEDED = 0
 
static final int ACCEPTABLE_LEVEL = 1
 
static final int INFEASIBLE_PROBLEM = 2
 
static final int SEARCH_DIRECTION_TOO_SMALL = 3
 
static final int DIVERGING_ITERATES = 4
 
static final int USER_REQUESTED_STOP = 5
 
static final int ITERATION_EXCEEDED = -1
 
static final int RESTORATION_FAILED = -2
 
static final int ERROR_IN_STEP_COMPUTATION = -3
 
static final int CPUTIME_EXCEEDED = -4
 
static final int WALLTIME_EXCEEDED = -5
 
static final int NOT_ENOUGH_DEGREES_OF_FRE = -10
 
static final int INVALID_PROBLEM_DEFINITION = -11
 
static final int INVALID_OPTION = -12
 
static final int INVALID_NUMBER_DETECTED = -13
 
static final int UNRECOVERABLE_EXCEPTION = -100
 
static final int NON_IPOPT_EXCEPTION = -101
 
static final int INSUFFICIENT_MEMORY = -102
 
static final int INTERNAL_ERROR = -199
 
static final int REGULARMODE = 0
 
static final int RESTORATIONPHASEMODE = 1
 

Protected Member Functions

abstract boolean get_bounds_info (int n, double[] x_l, double[] x_u, int m, double[] g_l, double[] g_u)
 Method to request bounds on the variables and constraints.
 
abstract boolean get_starting_point (int n, boolean init_x, double[] x, boolean init_z, double[] z_L, double[] z_U, int m, boolean init_lambda, double[] lambda)
 Method to request the starting point before iterating.
 
abstract boolean eval_f (int n, double[] x, boolean new_x, double[] obj_value)
 Method to request the value of the objective function.
 
abstract boolean eval_grad_f (int n, double[] x, boolean new_x, double[] grad_f)
 Method to request the gradient of the objective function.
 
abstract boolean eval_g (int n, double[] x, boolean new_x, int m, double[] g)
 Method to request the constraint values.
 
abstract boolean eval_jac_g (int n, double[] x, boolean new_x, int m, int nele_jac, int[] iRow, int[] jCol, double[] values)
 Method to request either the sparsity structure or the values of the Jacobian of the constraints.
 
abstract boolean eval_h (int n, double[] x, boolean new_x, double obj_factor, int m, double[] lambda, boolean new_lambda, int nele_hess, int[] iRow, int[] jCol, double[] values)
 Method to request either the sparsity structure or the values of the Hessian of the Lagrangian.
 
void finalize () throws Throwable
 

Private Member Functions

native boolean AddIpoptIntOption (long ipopt, String keyword, int val)
 
native boolean AddIpoptNumOption (long ipopt, String keyword, double val)
 
native boolean AddIpoptStrOption (long ipopt, String keyword, String val)
 
native long CreateIpoptProblem (int n, int m, int nele_jac, int nele_hess, int index_style)
 
native void FreeIpoptProblem (long ipopt)
 
native int OptimizeTNLP (long ipopt, double x[], double g[], double obj_val[], double mult_g[], double mult_x_L[], double mult_x_U[], double callback_grad_f[], double callback_jac_g[], double callback_hess[])
 
native boolean GetCurrIterate (long ipopt, long ip_data, long ip_cq, boolean scaled, int n, double x[], double z_L[], double z_U[], int m, double g[], double lambda[])
 
native boolean GetCurrViolations (long ipopt, long ip_data, long ip_cq, boolean scaled, int n, double x_L_violation[], double x_U_violation[], double compl_x_L[], double compl_x_U[], double grad_lag_x[], int m, double nlp_constraint_violation[], double compl_g[])
 

Private Attributes

long ipopt
 Pointer to the native optimization object.
 
double callback_grad_f []
 Callback arguments.
 
double callback_jac_g []
 
double callback_hess []
 
double x []
 Final value of variable values.
 
double obj_val [] = {0}
 Final value of objective function.
 
double g []
 Values of constraint at final point.
 
double mult_x_L []
 Final multipliers for lower variable bounds.
 
double mult_x_U []
 Final multipliers for upper variable bounds.
 
double mult_g []
 Final multipliers for constraints.
 
int status = INVALID_PROBLEM_DEFINITION
 Status returned by the solver.
 

Detailed Description

A Java Native Interface for the Ipopt optimization solver.

Ipopt is a solver for large scale nonlinear optimization problems (NLP).

The Java Native Interface (JNI) is a programming framework that allows Java code running in the Java Virtual Machine (JVM) to call and be called by native applications (programs specific to a hardware and operating system platform) and libraries written in other languages, such as C and C++.

This class is a JNI hook around the C++ interface of Ipopt, as a consequence it will need a nativelly compiled DLL to run. For more details about Ipopt click here.

The user should subclass this class and implement the abstract methods. At some point before solving the problem the create(int, int, int, int, int) function should be called. For simple cases you can call this function in the constructor of your class.

Once the problem was created, OptimizeNLP() will solve the problem. Objects of this class can be reused to solve different problems, in other words, create(int, int, int, int, int) and OptimizeNLP() can be called multiple times.

Programmers must call dispose() when finished using a Ipopt object, otherwise the nativelly allocated memory will be disposed of only when the JVM call finalize() on it.

Author
Rafael de Pelegrini Soares
Edson C. do Valle
Tong Kewei, BeiHang University

Definition at line 44 of file Ipopt.java.

Constructor & Destructor Documentation

◆ Ipopt() [1/3]

org.coinor.Ipopt.Ipopt ( )
inline

Creates a new NLP Solver using a default as the DLL name.

This expects the the Ipopt DLL can somehow be found and that it has the canoncial name "ipopt" (on Unix, et.al.) or "ipopt-3" or "ipopt-0" (on Windows).

Definition at line 193 of file Ipopt.java.

◆ Ipopt() [2/3]

org.coinor.Ipopt.Ipopt ( String  DLL)
inline

Creates a NLP Solver for the given DLL file.

The given file must implement the native interface required by this class. The given file must be located in some library search path.

Parameters
DLLthe name of the DLL (without the extension or any platform dependent prefix).

Definition at line 239 of file Ipopt.java.

◆ Ipopt() [3/3]

org.coinor.Ipopt.Ipopt ( String  path,
String  DLL 
)
inline

Creates a NLP Solver for the given DLL file and path.

The given file must implement the native interface required by this class.

Parameters
paththe path where the DLL is found.
DLLthe name of the DLL (without the extension or any platform dependent prefix).

Definition at line 252 of file Ipopt.java.

Member Function Documentation

◆ AddIpoptIntOption()

native boolean org.coinor.Ipopt.AddIpoptIntOption ( long  ipopt,
String  keyword,
int  val 
)
private

◆ AddIpoptNumOption()

native boolean org.coinor.Ipopt.AddIpoptNumOption ( long  ipopt,
String  keyword,
double  val 
)
private

◆ AddIpoptStrOption()

native boolean org.coinor.Ipopt.AddIpoptStrOption ( long  ipopt,
String  keyword,
String  val 
)
private

◆ CreateIpoptProblem()

native long org.coinor.Ipopt.CreateIpoptProblem ( int  n,
int  m,
int  nele_jac,
int  nele_hess,
int  index_style 
)
private

◆ FreeIpoptProblem()

native void org.coinor.Ipopt.FreeIpoptProblem ( long  ipopt)
private

◆ OptimizeTNLP()

native int org.coinor.Ipopt.OptimizeTNLP ( long  ipopt,
double  x[],
double  g[],
double  obj_val[],
double  mult_g[],
double  mult_x_L[],
double  mult_x_U[],
double  callback_grad_f[],
double  callback_jac_g[],
double  callback_hess[] 
)
private

◆ GetCurrIterate()

native boolean org.coinor.Ipopt.GetCurrIterate ( long  ipopt,
long  ip_data,
long  ip_cq,
boolean  scaled,
int  n,
double  x[],
double  z_L[],
double  z_U[],
int  m,
double  g[],
double  lambda[] 
)
private

◆ GetCurrViolations()

native boolean org.coinor.Ipopt.GetCurrViolations ( long  ipopt,
long  ip_data,
long  ip_cq,
boolean  scaled,
int  n,
double  x_L_violation[],
double  x_U_violation[],
double  compl_x_L[],
double  compl_x_U[],
double  grad_lag_x[],
int  m,
double  nlp_constraint_violation[],
double  compl_g[] 
)
private

◆ get_bounds_info()

abstract boolean org.coinor.Ipopt.get_bounds_info ( int  n,
double[]  x_l,
double[]  x_u,
int  m,
double[]  g_l,
double[]  g_u 
)
abstractprotected

Method to request bounds on the variables and constraints.

The values of n and m that were specified in create() and are passed here for debug checking. Setting a lower bound to a value less than or equal to the value of the option "nlp_lower_bound_inf" will cause Ipopt to assume no lower bound. Likewise, specifying the upper bound above or equal to the value of the option nlp_upper_bound_inf will cause Ipopt to assume no upper bound. These options are set to -1019 and 1019, respectively, by default, but may be modified by changing these options.

Parameters
n(in) the number of variablesin the problem
x_l(out) the lower bounds for the variables
x_u(out) the upper bounds for the variables
m(in) the number of constraints in the problem
g_l(out) the lower bounds for the constraints
g_u(out) the upper bounds for the constraints
Returns
true on success, otherwise false

◆ get_starting_point()

abstract boolean org.coinor.Ipopt.get_starting_point ( int  n,
boolean  init_x,
double[]  x,
boolean  init_z,
double[]  z_L,
double[]  z_U,
int  m,
boolean  init_lambda,
double[]  lambda 
)
abstractprotected

Method to request the starting point before iterating.

The boolean variables indicate whether the algorithm requires to have x, z_L/z_u, and lambda initialized, respectively. If, for some reason, the algorithm requires initializations that cannot be provided, false should be returned and Ipopt will stop. The default options only require initial values for the primal variables.

Note, that the initial values for bound multiplier components for absent bounds are ignored.

Parameters
n(in) the number of variables in the problem; it will have the same value that was specified in create()
init_x(in) if true, this method must provide an initial value for the primal variables
x(out) the initial values for the primal variables
init_z(in) if true, this method must provide an initial value for the bound multipliers
z_L(out) the initial values for the lower bound multipliers
z_U(out) the initial values for the upper bound multipliers
m(in) the number of constraints in the problem; it will have the same value that was specified in create()
init_lambda(in) if true, this method must provide an initial value for the constraint multipliers
lambda(out) the initial values for the constraint multipliers
Returns
true on success, otherwise false

◆ eval_f()

abstract boolean org.coinor.Ipopt.eval_f ( int  n,
double[]  x,
boolean  new_x,
double[]  obj_value 
)
abstractprotected

Method to request the value of the objective function.

Parameters
n(in) the number of variables in the problem; it will have the same value that was specified in create()
x(in) the values for the primal variables at which the objective function is to be evaluated
new_x(in) false if any evaluation method (eval_*) was previously called with the same values in x, true otherwise. This can be helpful when users have efficient implementations that calculate multiple outputs at once. Ipopt internally caches results from the TNLP and generally, this flag can be ignored.
obj_value(out) storage for the value of the objective function
Returns
true on success, otherwise false

◆ eval_grad_f()

abstract boolean org.coinor.Ipopt.eval_grad_f ( int  n,
double[]  x,
boolean  new_x,
double[]  grad_f 
)
abstractprotected

Method to request the gradient of the objective function.

Parameters
n(in) the number of variables in the problem; it will have the same value that was specified in create()
x(in) the values for the primal variables at which the gradient is to be evaluated
new_x(in) false if any evaluation method (eval_*) was previously called with the same values in x, true otherwise; see also eval_f()
grad_f(out) array to store values of the gradient of the objective function. The gradient array is in the same order as the variables (i.e., the gradient of the objective with respect to x[2] should be put in grad_f[2]).
Returns
true on success, otherwise false

◆ eval_g()

abstract boolean org.coinor.Ipopt.eval_g ( int  n,
double[]  x,
boolean  new_x,
int  m,
double[]  g 
)
abstractprotected

Method to request the constraint values.

Parameters
n(in) the number of variables in the problem; it will have the same value that was specified in create()
x(in) the values for the primal variables at which the constraint functions are to be evaluated
new_x(in) false if any evaluation method (eval_*) was previously called with the same values in x, true otherwise; see also eval_f()
m(in) the number of constraints in the problem; it will have the same value that was specified in create()
g(out) array to store constraint function values, do not add or subtract the bound values.
Returns
true on success, otherwise false

◆ eval_jac_g()

abstract boolean org.coinor.Ipopt.eval_jac_g ( int  n,
double[]  x,
boolean  new_x,
int  m,
int  nele_jac,
int[]  iRow,
int[]  jCol,
double[]  values 
)
abstractprotected

Method to request either the sparsity structure or the values of the Jacobian of the constraints.

The Jacobian is the matrix of derivatives where the derivative of the i-th constraint function with respect to the j-th variable is placed in row i and column j.

The arrays iRow and jCol only need to be filled once. If the iRow and jCol arguments are not NULL (first call to this function), then Ipopt expects that the sparsity structure of the Jacobian (the row and column indices only) are written into iRow and jCol. At this call, the arguments x and values will be NULL. If the arguments x and values are not NULL, then Ipopt expects that the value of the Jacobian as calculated from array x is stored in array values (using the same order as used when specifying the sparsity structure). At this call, the arguments iRow and jCol will be NULL.

Parameters
n(in) the number of variables in the problem; it will have the same value that was specified in create()
x(in) first call: NULL; later calls: the values for the primal variables at which the constraint Jacobian is to be evaluated
new_x(in) false if any evaluation method (eval_*) was previously called with the same values in x, true otherwise; see also eval_f()
m(in) the number of constraints in the problem; it will have the same value that was specified in create()
nele_jac(in) the number of nonzero elements in the Jacobian; it will have the same value that was specified in create()
iRow(out) first call: array of length nele_jac to store the row indices of entries in the Jacobian of the constraints; later calls: NULL
jCol(out) first call: array of length nele_jac to store the column indices of entries in the Jacobian of the constraints; later calls: NULL
values(out) first call: NULL; later calls: array of length nele_jac to store the values of the entries in the Jacobian of the constraints
Returns
true on success, otherwise false

◆ eval_h()

abstract boolean org.coinor.Ipopt.eval_h ( int  n,
double[]  x,
boolean  new_x,
double  obj_factor,
int  m,
double[]  lambda,
boolean  new_lambda,
int  nele_hess,
int[]  iRow,
int[]  jCol,
double[]  values 
)
abstractprotected

Method to request either the sparsity structure or the values of the Hessian of the Lagrangian.

The Hessian matrix that Ipopt uses is the sum of the Hessian matrices of objective function (multiplied by obj_factor) and each constraint function (multiplied by lambda).

The arrays iRow and jCol only need to be filled once. If the iRow and jCol arguments are not NULL (first call to this function), then Ipopt expects that the sparsity structure of the Hessian (the row and column indices only) are written into iRow and jCol. At this call, the arguments x, lambda, and values will be NULL. If the arguments x, lambda, and values are not NULL, then Ipopt expects that the value of the Hessian as calculated from arrays x and lambda are stored in array values (using the same order as used when specifying the sparsity structure). At this call, the arguments iRow and jCol will be NULL.

As this matrix is symmetric, Ipopt expects that only the lower diagonal entries are specified.

Parameters
n(in) the number of variables in the problem; it will have the same value that was specified in create()
x(in) first call: NULL; later calls: the values for the primal variables at which the Hessian is to be evaluated
new_x(in) false if any evaluation method (eval_*) was previously called with the same values in x, true otherwise; see also eval_f()
obj_factor(in) factor in front of the objective term in the Hessian
m(in) the number of constraints in the problem; it will have the same value that was specified in create()
lambda(in) the values for the constraint multipliers at which the Hessian is to be evaluated
new_lambda(in) false if any evaluation method was previously called with the same values in lambda, true otherwise
nele_hess(in) the number of nonzero elements in the Hessian; it will have the same value that was specified in create()
iRow(out) first call: array of length nele_hess to store the row indices of entries in the Hessian; later calls: NULL
jCol(out) first call: array of length nele_hess to store the column indices of entries in the Hessian; later calls: NULL
values(out) first call: NULL; later calls: array of length nele_hess to store the values of the entries in the Hessian
Returns
true on success, otherwise false

◆ dispose()

void org.coinor.Ipopt.dispose ( )
inline

Dispose of the natively allocated memory.

Programmers must call the dispose method when finished using a Ipopt object.

An JIpopt object can be reused to solve different problems by calling again create(int, int, int, int, int). In this case, you should call the dispose method only when you finished with the object and it is not needed anymore.

Definition at line 475 of file Ipopt.java.

◆ finalize()

void org.coinor.Ipopt.finalize ( ) throws Throwable
inlineprotected

Definition at line 486 of file Ipopt.java.

◆ create()

boolean org.coinor.Ipopt.create ( int  n,
int  m,
int  nele_jac,
int  nele_hess,
int  index_style 
)
inline

Create a new problem.

This is get_nlp_info in the C++ interface.

Parameters
nthe number of variables in the problem.
mthe number of constraints in the problem.
nele_jacthe number of nonzero entries in the Jacobian.
nele_hessthe number of nonzero entries in the Hessian.
index_stylethe numbering style used for row/col entries in the sparse matrix format (C_STYLE or FORTRAN_STYLE).
Returns
true on success, otherwise false

Definition at line 503 of file Ipopt.java.

◆ setIntegerOption()

boolean org.coinor.Ipopt.setIntegerOption ( String  keyword,
int  val 
)
inline

Function for setting an integer option.

For a list of valid keywords check the Ipopt documentation.

Parameters
keywordthe option keyword
valthe value
Returns
false if the option could not be set (e.g., if keyword is unknown)

Definition at line 541 of file Ipopt.java.

◆ setNumericOption()

boolean org.coinor.Ipopt.setNumericOption ( String  keyword,
double  val 
)
inline

Function for setting a number option.

For a list of valid keywords check the Ipopt documentation.

Parameters
keywordthe option keyword
valthe value
Returns
false if the option could not be set (e.g., if keyword is unknown)

Definition at line 561 of file Ipopt.java.

◆ setStringOption()

boolean org.coinor.Ipopt.setStringOption ( String  keyword,
String  val 
)
inline

Function for setting a string option.

For a list of valid keywords check the Ipopt documentation.

Parameters
keywordthe option keyword
valthe value
Returns
false if the option could not be set (e.g., if keyword is unknown)

Definition at line 581 of file Ipopt.java.

◆ OptimizeNLP()

int org.coinor.Ipopt.OptimizeNLP ( )
inline

This function actually solve the problem.

The solve status returned is one of the constant fields of this class, e.g. SOLVE_SUCCEEDED. For more details about the valid solve status check the Ipopt documentation.

Returns
the solve status
See also
getStatus()

Definition at line 603 of file Ipopt.java.

◆ get_curr_iterate()

boolean org.coinor.Ipopt.get_curr_iterate ( long  ip_data,
long  ip_cq,
boolean  scaled,
int  n,
double  x[],
double  z_L[],
double  z_U[],
int  m,
double  g[],
double  lambda[] 
)
inline

Get primal and dual variable values of the current iterate.

This method can be used to get the values of the current iterate during intermediate_callback(). The method expects the number of variables (dimension of x), number of constraints (dimension of g(x)), and allocated arrays of appropriate lengths as input.

The method translates the x(), c(), d(), y_c(), y_d(), z_L(), and z_U() vectors from Ipopt::IpoptData::curr() of the internal NLP representation into the form used by the TNLP. For the correspondence between scaled and unscaled solutions, see the detailed description of Ipopt::OrigIpoptNLP. If Ipopt is in restoration mode, it maps the current iterate of restoration NLP (see Ipopt::RestoIpoptNLP) back to the original TNLP.

If there are fixed variables and fixed_variable_treatment=make_parameter, then requesting z_L and z_U can trigger a reevaluation of the Gradient of the objective function and the Jacobian of the constraint functions.

Parameters
ip_data(in) Ipopt Data (pass on value given to intermediate_callback)
ip_cq(in) Ipopt Calculated Quantities (pass on value given to intermediate_callback)
scaled(in) whether to retrieve scaled or unscaled iterate
n(in) the number of variables \(x\) in the problem; can be arbitrary if skipping x, z_L, and z_U
x(out) buffer to store value of primal variables \(x\), must have length at least n; pass null to skip retrieving x
z_L(out) buffer to store the lower bound multipliers \(z_L\), must have length at least n; pass null to skip retrieving z_L and z_U
z_U(out) buffer to store the upper bound multipliers \(z_U\), must have length at least n; pass null to skip retrieving z_L and z_U
m(in) the number of constraints \(g(x)\); can be arbitrary if skipping g and lambda
g(out) buffer to store the constraint values \(g(x)\), must have length at least m; pass null to skip retrieving g
lambda(out) buffer to store the constraint multipliers \(\lambda\), must have length at least m; pass null to skip retrieving lambda
Returns
Whether Ipopt has successfully filled the given arrays
Since
3.14.0

Definition at line 640 of file Ipopt.java.

◆ get_curr_violations()

boolean org.coinor.Ipopt.get_curr_violations ( long  ip_data,
long  ip_cq,
boolean  scaled,
int  n,
double  x_L_violation[],
double  x_U_violation[],
double  compl_x_L[],
double  compl_x_U[],
double  grad_lag_x[],
int  m,
double  nlp_constraint_violation[],
double  compl_g[] 
)
inline

Get primal and dual infeasibility of the current iterate.

This method can be used to get the violations of constraints and optimality conditions at the current iterate, e.g., during intermediate_callback(). The method expects the number of variables (dimension of x), number of constraints (dimension of g(x)), and allocated arrays of appropriate lengths as input.

The method makes the vectors behind (unscaled_)curr_nlp_constraint_violation(), (unscaled_)curr_dual_infeasibility(), (unscaled_)curr_complementarity() from Ipopt::IpoptCalculatedQuantities of the internal NLP representation available into the form used by the TNLP. If Ipopt is in restoration mode, it maps the current iterate of restoration NLP (see Ipopt::RestoIpoptNLP) back to the original TNLP.

Note
If in restoration phase, then requesting grad_lag_x can trigger a call to eval_grad_f().
Ipopt by default relaxes variable bounds (option bound_relax_factor > 0.0). x_L_violation and x_U_violation report the violation of a solution w.r.t. the original unrelaxed bounds. However, compl_x_L and compl_x_U use the relaxed variable bounds to calculate the complementarity.
Parameters
ip_data(in) Ipopt Data (pass on value given to intermediate_callback)
ip_cq(in) Ipopt Calculated Quantities (pass on value given to intermediate_callback)
scaled(in) whether to retrieve scaled or unscaled violations
n(in) the number of variables \(x\) in the problem; can be arbitrary if skipping compl_x_L, compl_x_U, and grad_lag_x
x_L_violation(out) buffer to store violation of original lower bounds on variables (max(orig_x_L-x,0)), must have length at least n; pass NULL to skip retrieving orig_x_L
x_U_violation(out) buffer to store violation of original upper bounds on variables (max(x-orig_x_U,0)), must have length at least n; pass NULL to skip retrieving orig_x_U
compl_x_L(out) buffer to store violation of complementarity for lower bounds on variables ( \((x-x_L)z_L\)), must have length at least n; pass null to skip retrieving compl_x_L
compl_x_U(out) buffer to store violation of complementarity for upper bounds on variables ( \((x_U-x)z_U\)), must have length at least n; pass null to skip retrieving compl_x_U
grad_lag_x(out) buffer to store gradient of Lagrangian w.r.t. variables \(x\), must have length at least n; pass null to skip retrieving grad_lag_x
m(in) the number of constraints \(g(x)\); can be arbitrary if skipping lambda
nlp_constraint_violation(out) buffer to store violation of constraints \(max(g_l-g(x),g(x)-g_u,0)\), must have length at least m; pass null to skip retrieving constraint_violation
compl_g(out) buffer to store violation of complementarity of constraint ( \((g(x)-g_l)*\lambda^+ + (g_l-g(x))*\lambda^-\), where \(\lambda^+=max(0,\lambda)\) and \(\lambda^-=max(0,-\lambda)\) (componentwise)), must have length at least m; pass null to skip retrieving compl_g
Returns
Whether Ipopt has successfully filled the given arrays
Since
3.14.0

Definition at line 689 of file Ipopt.java.

◆ getVariableValues()

double[] org.coinor.Ipopt.getVariableValues ( )
inline

Gives primal variable values at final point.

Returns
the primal variable values at the final point.

Definition at line 710 of file Ipopt.java.

◆ getObjectiveValue()

double org.coinor.Ipopt.getObjectiveValue ( )
inline

Gives objective function value at final point.

Returns
the final value of the objective function.

Definition at line 718 of file Ipopt.java.

◆ getStatus()

int org.coinor.Ipopt.getStatus ( )
inline

Gives Ipopt status of last OptimizeNLP call.

Returns
the status of the solver.
See also
OptimizeNLP()

Definition at line 728 of file Ipopt.java.

◆ getConstraintValues()

double[] org.coinor.Ipopt.getConstraintValues ( )
inline

Gives constraint function values at final point.

Returns
Returns the final values for the constraints functions.

Definition at line 736 of file Ipopt.java.

◆ getConstraintMultipliers()

double[] org.coinor.Ipopt.getConstraintMultipliers ( )
inline

Gives constraint dual multipliers in final point.

Returns
Returns the final multipliers for the constraints.

Definition at line 744 of file Ipopt.java.

◆ getLowerBoundMultipliers()

double[] org.coinor.Ipopt.getLowerBoundMultipliers ( )
inline

Gives dual multipliers for variable lower bounds in final point.

Returns
Returns the final multipliers for the variable lower bounds.

Definition at line 752 of file Ipopt.java.

◆ getUpperBoundMultipliers()

double[] org.coinor.Ipopt.getUpperBoundMultipliers ( )
inline

Gives dual multipliers for variable upper bounds in final point.

Returns
Returns the final multipliers for the variable upper bounds.

Definition at line 760 of file Ipopt.java.

◆ intermediate_callback()

boolean org.coinor.Ipopt.intermediate_callback ( int  algorithmmode,
int  iter,
double  obj_value,
double  inf_pr,
double  inf_du,
double  mu,
double  d_norm,
double  regularization_size,
double  alpha_du,
double  alpha_pr,
int  ls_trials,
long  ip_data,
long  ip_cq 
)
inline

Intermediate Callback method for the user.

This method is called once per iteration (during the convergence check), and can be used to obtain information about the optimization status while Ipopt solves the problem, and also to request a premature termination.

The information provided by the entities in the argument list correspond to what Ipopt prints in the iteration summary (see also Ipopt Output), except for inf_pr, which by default corresponds to the original problem in the log but to the scaled internal problem in this callback. The value of algorithmmode is either REGULARMODE or RESTORATIONPHASEMODE.

The current iterate and violations of feasibility and optimality can be accessed via the methods get_curr_iterate() and get_curr_violations(). These methods translate values for the internal representation of the problem from ip_data and ip_cq objects.

Returns
If this method returns false, Ipopt will terminate with the User_Requested_Stop status.

It is not required to implement (overload) this method. The default implementation always returns true.

Since
3.14.0

Definition at line 789 of file Ipopt.java.

◆ get_scaling_parameters()

boolean org.coinor.Ipopt.get_scaling_parameters ( double[]  obj_scaling,
int  n,
double[]  x_scaling,
int  m,
double[]  g_scaling,
boolean[]  use_x_g_scaling 
)
inline

If you using_scaling_parameters = true, this method should be overloaded.

To instruct IPOPT to use scaling values for variables, the first element of use_x_g_scaling should be set. To instruct IPOPT to use scaling values for constraints, the second element of use_x_g_scaling should be set.

Parameters
obj_scalingdouble[1] to store a scaling factor for the objective (negative value leads to maximizing the objective function)
nthe number of variables in the problem
x_scalingarray to store the scaling factors for the variables
mthe number of constraints in the problem
g_scalingarray to store the scaling factors for the constraints
use_x_g_scalingboolean[2] to store whether scaling factors for variables (1st entry) and constraints (2nd entry) should be used
Returns
true on success, otherwise false

Definition at line 821 of file Ipopt.java.

◆ get_number_of_nonlinear_variables()

int org.coinor.Ipopt.get_number_of_nonlinear_variables ( )
inline

When LBFGS hessian approximation is used, this method should be overloaded.

Returns
number of nonlinear variables, a negative value indicates that all variables are negative

Definition at line 836 of file Ipopt.java.

◆ get_list_of_nonlinear_variables()

boolean org.coinor.Ipopt.get_list_of_nonlinear_variables ( int  num_nonlin_vars,
int[]  pos_nonlin_vars 
)
inline

When LBFGS hessian approximation is used, this method should be overloaded.

Parameters
num_nonlin_varsnumber of nonlinear variables and length of pos_nonlin_vars array
pos_nonlin_varsthe indices of all nonlinear variables
Returns
true on success, otherwise false

Definition at line 848 of file Ipopt.java.

Member Data Documentation

◆ C_STYLE

final int org.coinor.Ipopt.C_STYLE = 0
static

Use C index style for iRow and jCol vectors.

Definition at line 128 of file Ipopt.java.

◆ FORTRAN_STYLE

final int org.coinor.Ipopt.FORTRAN_STYLE = 1
static

Use FORTRAN index style for iRow and jCol vectors.

Definition at line 131 of file Ipopt.java.

◆ SOLVE_SUCCEEDED

final int org.coinor.Ipopt.SOLVE_SUCCEEDED = 0
static

Definition at line 134 of file Ipopt.java.

◆ ACCEPTABLE_LEVEL

final int org.coinor.Ipopt.ACCEPTABLE_LEVEL = 1
static

Definition at line 135 of file Ipopt.java.

◆ INFEASIBLE_PROBLEM

final int org.coinor.Ipopt.INFEASIBLE_PROBLEM = 2
static

Definition at line 136 of file Ipopt.java.

◆ SEARCH_DIRECTION_TOO_SMALL

final int org.coinor.Ipopt.SEARCH_DIRECTION_TOO_SMALL = 3
static

Definition at line 137 of file Ipopt.java.

◆ DIVERGING_ITERATES

final int org.coinor.Ipopt.DIVERGING_ITERATES = 4
static

Definition at line 138 of file Ipopt.java.

◆ USER_REQUESTED_STOP

final int org.coinor.Ipopt.USER_REQUESTED_STOP = 5
static

Definition at line 139 of file Ipopt.java.

◆ ITERATION_EXCEEDED

final int org.coinor.Ipopt.ITERATION_EXCEEDED = -1
static

Definition at line 140 of file Ipopt.java.

◆ RESTORATION_FAILED

final int org.coinor.Ipopt.RESTORATION_FAILED = -2
static

Definition at line 141 of file Ipopt.java.

◆ ERROR_IN_STEP_COMPUTATION

final int org.coinor.Ipopt.ERROR_IN_STEP_COMPUTATION = -3
static

Definition at line 142 of file Ipopt.java.

◆ CPUTIME_EXCEEDED

final int org.coinor.Ipopt.CPUTIME_EXCEEDED = -4
static

Definition at line 143 of file Ipopt.java.

◆ WALLTIME_EXCEEDED

final int org.coinor.Ipopt.WALLTIME_EXCEEDED = -5
static
Since
3.14.0

Definition at line 144 of file Ipopt.java.

◆ NOT_ENOUGH_DEGREES_OF_FRE

final int org.coinor.Ipopt.NOT_ENOUGH_DEGREES_OF_FRE = -10
static

Definition at line 145 of file Ipopt.java.

◆ INVALID_PROBLEM_DEFINITION

final int org.coinor.Ipopt.INVALID_PROBLEM_DEFINITION = -11
static

Definition at line 146 of file Ipopt.java.

◆ INVALID_OPTION

final int org.coinor.Ipopt.INVALID_OPTION = -12
static

Definition at line 147 of file Ipopt.java.

◆ INVALID_NUMBER_DETECTED

final int org.coinor.Ipopt.INVALID_NUMBER_DETECTED = -13
static

Definition at line 148 of file Ipopt.java.

◆ UNRECOVERABLE_EXCEPTION

final int org.coinor.Ipopt.UNRECOVERABLE_EXCEPTION = -100
static

Definition at line 149 of file Ipopt.java.

◆ NON_IPOPT_EXCEPTION

final int org.coinor.Ipopt.NON_IPOPT_EXCEPTION = -101
static

Definition at line 150 of file Ipopt.java.

◆ INSUFFICIENT_MEMORY

final int org.coinor.Ipopt.INSUFFICIENT_MEMORY = -102
static

Definition at line 151 of file Ipopt.java.

◆ INTERNAL_ERROR

final int org.coinor.Ipopt.INTERNAL_ERROR = -199
static

Definition at line 152 of file Ipopt.java.

◆ REGULARMODE

final int org.coinor.Ipopt.REGULARMODE = 0
static
Since
3.14.0

Definition at line 155 of file Ipopt.java.

◆ RESTORATIONPHASEMODE

final int org.coinor.Ipopt.RESTORATIONPHASEMODE = 1
static
Since
3.14.0

Definition at line 156 of file Ipopt.java.

◆ ipopt

long org.coinor.Ipopt.ipopt
private

Pointer to the native optimization object.

Definition at line 159 of file Ipopt.java.

◆ callback_grad_f

double org.coinor.Ipopt.callback_grad_f[]
private

Callback arguments.

Definition at line 162 of file Ipopt.java.

◆ callback_jac_g

double org.coinor.Ipopt.callback_jac_g[]
private

Definition at line 163 of file Ipopt.java.

◆ callback_hess

double org.coinor.Ipopt.callback_hess[]
private

Definition at line 164 of file Ipopt.java.

◆ x

double org.coinor.Ipopt.x[]
private

Final value of variable values.

Definition at line 167 of file Ipopt.java.

◆ obj_val

double org.coinor.Ipopt.obj_val[] = {0}
private

Final value of objective function.

Definition at line 170 of file Ipopt.java.

◆ g

double org.coinor.Ipopt.g[]
private

Values of constraint at final point.

Definition at line 173 of file Ipopt.java.

◆ mult_x_L

double org.coinor.Ipopt.mult_x_L[]
private

Final multipliers for lower variable bounds.

Definition at line 176 of file Ipopt.java.

◆ mult_x_U

double org.coinor.Ipopt.mult_x_U[]
private

Final multipliers for upper variable bounds.

Definition at line 179 of file Ipopt.java.

◆ mult_g

double org.coinor.Ipopt.mult_g[]
private

Final multipliers for constraints.

Definition at line 182 of file Ipopt.java.

◆ status

int org.coinor.Ipopt.status = INVALID_PROBLEM_DEFINITION
private

Status returned by the solver.

Definition at line 185 of file Ipopt.java.


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