ipopt-hs-0.2.0.0: haskell binding to ipopt including automatic differentiation

Safe HaskellNone

Ipopt

Contents

Description

This module exports most things you should need. Also take a look at Ipopt.NLP and Ipopt.Raw and examples/

Synopsis

high-level

nlpstate0 :: NLPStateSource

the initial state to use when you actually have to get to IO with the solution

solveNLP'Source

Arguments

:: MonadIO m 
=> (IpProblem -> IO ())

set ipopt options (using functions from Ipopt.Raw)

-> NLPT m IpOptSolved 

calls createIpoptProblemAD and ipoptSolve. To be used at the end of a do-block.

variables

var'Source

Arguments

:: (Monad m, Functor m) 
=> Maybe (Double, Double)

bounds (xl,xu) to request that xl <= x <= xu. if Nothing, you get whatever is in defaultBounds

-> String

variable name (namespace from the pushEnv / popEnv can make an x you request here different from one you previously requested

-> NLPT m (AnyRF Identity, Ix)

the value, and index (into the raw vector of variables that the solver sees)

add a variable, or get a reference to the the same variable if it has already been used

var :: (Monad m, Functor m) => Maybe (Double, Double) -> String -> StateT NLPState m (AnyRF Identity)Source

var' without the usually unnecessary Ix

varFresh :: (Monad m, Functor m) => Maybe (Double, Double) -> [Char] -> StateT NLPState m (AnyRF Identity)Source

var, except this causes the solver to get a new variable, so that you can use:

 [a,b,c,d,e] <- replicateM 5 (varFresh (Just (0, 10)) "x")

and the different letters can take different values (between 0 and 10) in the optimal solution (depending on what you do with a and similar in the objective function).

data AnyRF cb Source

this wrapper holds functions that can be used for the objective (f) or for constraints (g). Many functions in the instances provided are partial: this seems to be unavoidable because the input variables haven't been decided yet, so you should not be allowed to use compare on these. But for now just use the standard Prelude classes, and unimplementable functions (which would not produce an AnyRF) are calls to error

generate these using var, or perhaps by directly using the constructor: AnyRF $ Identity . V.sum, would for example give the sum of all variables.

Constructors

AnyRF (forall a. RealFloat a => Vector a -> cb a) 

functions

addGSource

Arguments

:: Monad m 
=> Maybe String

optional description

-> (Double, Double)

bounds (gl,gu) for the single inequality gl_i <= g_i(x) <= gu_i

-> AnyRF Identity
g_i(x)
-> NLPT m () 

add a constraint

addFSource

Arguments

:: Monad m 
=> Maybe String

description

-> AnyRF Identity

`f_i(x)`

-> NLPT m () 

add a piece of the objective function, which is added in the form `f_1 + f_2 + ...`, to make it easier to understand (at some point) which components are responsible for the majority of the cost, and which are irrelevant.

low-level bits still needed

solver options

types

type Vec = IOVector IpNumberSource

Vector of numbers