pub trait BasicProblem {
// Required methods
fn num_variables(&self) -> usize;
fn bounds(&self, x_l: &mut [f64], x_u: &mut [f64]) -> bool;
fn initial_point(&self, x: &mut [f64]) -> bool;
fn objective(&self, x: &[f64], new_x: bool, obj: &mut f64) -> bool;
fn objective_grad(&self, x: &[f64], new_x: bool, grad_f: &mut [f64]) -> bool;
// Provided methods
fn indexing_style(&self) -> IndexingStyle { ... }
fn initial_bounds_multipliers(
&self,
z_l: &mut [f64],
z_u: &mut [f64],
) -> bool { ... }
fn variable_scaling(&self, _x_scaling: &mut [f64]) -> bool { ... }
fn objective_scaling(&self) -> f64 { ... }
}Expand description
The callback interface for a non-linear problem to be solved by Ipopt.
This trait specifies all the information needed to construct the unconstrained optimization
problem (although the variables are allowed to be bounded).
In the callbacks within, x is the independent variable and must be the same size
as returned by num_variables.
Each of the callbacks required during interior point iterations are allowed to fail. In case
of failure to produce values, simply return false where applicable. This feature could be
used to tell Ipopt to try smaller perturbations for x for instance. If the caller returns
true but the output data was not set, then Ipopt may produce undefined behaviour.
Required Methods§
Sourcefn num_variables(&self) -> usize
fn num_variables(&self) -> usize
Total number of variables of the non-linear problem.
Sourcefn bounds(&self, x_l: &mut [f64], x_u: &mut [f64]) -> bool
fn bounds(&self, x_l: &mut [f64], x_u: &mut [f64]) -> bool
Specify lower and upper variable bounds given by x_l and x_u respectively.
Both slices will have the same size as what num_variables returns.
Sourcefn initial_point(&self, x: &mut [f64]) -> bool
fn initial_point(&self, x: &mut [f64]) -> bool
Construct the initial guess of the primal variables for Ipopt to start with.
The given slice has the same size as num_variables.
This function should return whether the output slice x has been populated with initial
values. If this function returns false, then a zero initial guess will be used.
Provided Methods§
Sourcefn indexing_style(&self) -> IndexingStyle
fn indexing_style(&self) -> IndexingStyle
Specify the indexing style used for arrays in this problem. (Default is zero-based)
Sourcefn initial_bounds_multipliers(&self, z_l: &mut [f64], z_u: &mut [f64]) -> bool
fn initial_bounds_multipliers(&self, z_l: &mut [f64], z_u: &mut [f64]) -> bool
Construct the initial guess of the lower and upper bounds multipliers for Ipopt to start with.
The given slices has the same size as num_variables.
Note that multipliers for infinity bounds are ignored.
This function should return whether the output slices z_l and z_u have been populated
with initial values. If this function returns false, then a zero initial guess will be used.
For convenience, the default implementation initializes bounds multipliers to zero. This is a good guess for any initial point in the interior of the feasible region.
Sourcefn variable_scaling(&self, _x_scaling: &mut [f64]) -> bool
fn variable_scaling(&self, _x_scaling: &mut [f64]) -> bool
Provide custom variable scaling.
This method is called if the Ipopt option, nlp_scaling_method, is set to user-scaling.
Return true if scaling is provided and false otherwise: if false is returned, Ipopt
will not scale the variables.
The dimension of x_scaling is given by num_variables.
For convenience, this function returns false by default without modifying the x_scaling
slice.
Sourcefn objective_scaling(&self) -> f64
fn objective_scaling(&self) -> f64
Provide custom scaling for the objective function.
This method is called if the Ipopt option, nlp_scaling_method, is set to user-scaling.
For example if this function returns 10, then then Ipopt solves internally an optimization
problem that has 10 times the value of the original objective function. If this function
returns -1.0, then Ipopt will maximize the objective instead of minimizing it.
For convenience, this function returns 1.0 by default.