BasicProblem

Trait BasicProblem 

Source
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§

Source

fn num_variables(&self) -> usize

Total number of variables of the non-linear problem.

Source

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.

Source

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.

Source

fn objective(&self, x: &[f64], new_x: bool, obj: &mut f64) -> bool

Objective function. This is the function being minimized.

This function is internally called by Ipopt callback eval_f.

Source

fn objective_grad(&self, x: &[f64], new_x: bool, grad_f: &mut [f64]) -> bool

The gradient of the objective function speficies the search direction to Ipopt.

This function is internally called by Ipopt callback eval_grad_f.

Provided Methods§

Source

fn indexing_style(&self) -> IndexingStyle

Specify the indexing style used for arrays in this problem. (Default is zero-based)

Source

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.

Source

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.

Source

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.

Implementors§

Source§

impl<T: CachedADProblem<X>, const X: usize> BasicProblem for ADProblem<T, X, true>

Source§

impl<T: SimpleADProblem<X>, const X: usize> BasicProblem for ADProblem<T, X, false>