[][src]Struct optimization_engine::continuation::HomotopyOptimizer

pub struct HomotopyOptimizer<'a, ParametricPenaltyFunctionType, ParametricGradientType, ConstraintType, ParametricCostType> where
    ParametricPenaltyFunctionType: Fn(&[f64], &[f64], &mut [f64]) -> Result<(), SolverError>,
    ParametricGradientType: Fn(&[f64], &[f64], &mut [f64]) -> Result<(), SolverError>,
    ParametricCostType: Fn(&[f64], &[f64], &mut f64) -> Result<(), SolverError>,
    ConstraintType: Constraint
{ /* fields omitted */ }

Homotopy optimizer

This struct solves a parametric optimization problem - which has been defined using HomotopyProblem - and solves it with the homotopy method.

Methods

impl<'a, ParametricPenaltyFunctionType, ParametricGradientType, ConstraintType, ParametricCostType> HomotopyOptimizer<'a, ParametricPenaltyFunctionType, ParametricGradientType, ConstraintType, ParametricCostType> where
    ParametricPenaltyFunctionType: Fn(&[f64], &[f64], &mut [f64]) -> Result<(), SolverError>,
    ParametricGradientType: Fn(&[f64], &[f64], &mut [f64]) -> Result<(), SolverError>,
    ParametricCostType: Fn(&[f64], &[f64], &mut f64) -> Result<(), SolverError>,
    ConstraintType: Constraint
[src]

pub fn new(
    homotopy_problem: &'a HomotopyProblem<ParametricPenaltyFunctionType, ParametricGradientType, ConstraintType, ParametricCostType>,
    panoc_cache: &'a mut PANOCCache
) -> HomotopyOptimizer<'a, ParametricPenaltyFunctionType, ParametricGradientType, ConstraintType, ParametricCostType>
[src]

Constructor for HomotopyOptimizer

Arguments

  • homotopy_problem: definition of homotopy problem
  • panoc_cache: re-useable instance of PANOCCache

Returns

  • New instance of HomotopyOptimizer

Panics

Does not panic

Example

use optimization_engine::{
    SolverError,
    continuation,constraints::*,
    core::panoc::PANOCCache
   };

fn main() {

    let mut cache = PANOCCache::new(std::num::NonZeroUsize::new(1).unwrap(),
        1e-5, std::num::NonZeroUsize::new(10).unwrap());

    /* cost function, f(u; q) */
    let cost_fun = |u: &[f64], q: &[f64], cost: &mut f64| -> Result<(), SolverError> {        
        // your implementation goes here
        Ok(())
    };

    /* parametric gradient, df(u, q) */
    let grad_fun = |u: &[f64], q: &[f64], grad: &mut [f64]| -> Result<(), SolverError> {
        // your implementation goes here
            Ok(())
        };
    
    /* penalty-type constraints: c(u; p) */
    let penalty_constr_fun =
    |u: &[f64], q: &[f64], constraints: &mut [f64]| -> Result<(), SolverError> {
       // your implementation goes here
       Ok(())
    };
    
    // Constraints...
    let bounds = Ball2::new(None, 1.5);
    
    // Define homotopy problem
    let  homotopy_problem = continuation::HomotopyProblem::new(
       bounds,
       grad_fun,
       cost_fun,
       penalty_constr_fun,
       1
    );
    
    let mut homotopy_optimizer =
        continuation::HomotopyOptimizer::new(&homotopy_problem, &mut cache);
}

pub fn with_constraint_tolerance(self, constraint_tolerance: f64) -> Self[src]

Specify tolerance on constraint violation

Arguments

  • constraint_tolerance: tolerance

Returns

The current mutable instance of HomotopyOptimizer

pub fn with_max_outer_iterations(self, max_outer_iterations: usize) -> Self[src]

Specify maximum number of outer iterations

Arguments

  • max_outer_iterations: maximum number of iterations of outer solvers

Returns

The current mutable instance of HomotopyOptimizer

pub fn with_max_inner_iterations(self, max_inner_iterations: usize) -> Self[src]

Specify the maximum number of iterations of each inner solver

Arguments

  • max_inner_iterations: maximum number of iterations of inner solvers

Returns

The current mutable instance of HomotopyOptimizer

pub fn with_max_duration(&mut self, max_duration: Duration) -> &Self[src]

Specify the maximum time duration for the homotopy solver

If the maximum duration of execution is exceeded, the solver will return the status code ExitStatus::NotConvergedOutOfTime; see #solve

Arguments

  • max_duration: maximum duration as an instance of std::time::Duration

Returns

  • A reference to the current mutable instance of HomotopyOptimizer

Panics

Does not panic.

pub fn solve(
    &'a mut self,
    u: &mut [f64],
    q_augmented_param: &[f64]
) -> Result<HomotopySolverStatus, SolverError>
[src]

Solve problem by homotopy method

Arguments:

  • u - on entry, this is the initial guess of the solution, on exit, it gets updated with the approximate solution that the solver computed (check also the exit status)
  • q_augmented_param - vector of parameters of the parametric problem

Returns

  • A Result, which, if successful contains an instance of HomotopySolverStatus, otherwise, it returns an appropriate error

Panic

To be updated

Auto Trait Implementations

impl<'a, ParametricPenaltyFunctionType, ParametricGradientType, ConstraintType, ParametricCostType> Send for HomotopyOptimizer<'a, ParametricPenaltyFunctionType, ParametricGradientType, ConstraintType, ParametricCostType> where
    ConstraintType: Sync,
    ParametricCostType: Sync,
    ParametricGradientType: Sync,
    ParametricPenaltyFunctionType: Sync

impl<'a, ParametricPenaltyFunctionType, ParametricGradientType, ConstraintType, ParametricCostType> Sync for HomotopyOptimizer<'a, ParametricPenaltyFunctionType, ParametricGradientType, ConstraintType, ParametricCostType> where
    ConstraintType: Sync,
    ParametricCostType: Sync,
    ParametricGradientType: Sync,
    ParametricPenaltyFunctionType: Sync

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]