Copyright | (C) 2013 Adam Vogt |
---|---|
Maintainer | Adam Vogt <vogt.adam@gmail.com> |
Stability | unstable |
Safe Haskell | None |
Language | Haskell2010 |
Description: lowest-level parts of the binding
- createIpoptProblemAD :: Vec -> Vec -> Vec -> Vec -> (forall a. AnyRFCxt a => V.Vector a -> a) -> (forall a. AnyRFCxt a => V.Vector a -> V.Vector a) -> IO IpProblem
- createIpoptProblemADSparse :: Vec -> Vec -> Vec -> Vec -> (V.Vector (Sparse.Sparse C2HSImp.CDouble) -> Sparse.Sparse C2HSImp.CDouble) -> (V.Vector (Sparse.Sparse C2HSImp.CDouble) -> V.Vector (Sparse.Sparse C2HSImp.CDouble)) -> IO IpProblem
- ipoptSolve :: VG.Vector v Double => IpProblem -> Vec -> IO (IpOptSolved v)
- data IpOptSolved v = IpOptSolved {}
- addIpoptNumOption :: IpProblem -> String -> Double -> IO Bool
- addIpoptStrOption :: IpProblem -> String -> String -> IO Bool
- addIpoptIntOption :: IpProblem -> String -> Int -> IO Bool
- openIpoptOutputFile :: IpProblem -> String -> Int -> IO Bool
- type Vec = VM.IOVector Double
- type IpNumber = C2HSImp.CDouble
- type IpIndex = C2HSImp.CInt
- type IpInt = C2HSImp.CInt
- type IpBool = C2HSImp.CInt
- type IpF = C2HSImp.FunPtr (C2HSImp.CInt -> C2HSImp.Ptr C2HSImp.CDouble -> C2HSImp.CInt -> C2HSImp.Ptr C2HSImp.CDouble -> C2HSImp.Ptr () -> IO C2HSImp.CInt)
- type IpGradF = C2HSImp.FunPtr (C2HSImp.CInt -> C2HSImp.Ptr C2HSImp.CDouble -> C2HSImp.CInt -> C2HSImp.Ptr C2HSImp.CDouble -> C2HSImp.Ptr () -> IO C2HSImp.CInt)
- type IpG = C2HSImp.FunPtr (C2HSImp.CInt -> C2HSImp.Ptr C2HSImp.CDouble -> C2HSImp.CInt -> C2HSImp.CInt -> C2HSImp.Ptr C2HSImp.CDouble -> C2HSImp.Ptr () -> IO C2HSImp.CInt)
- type IpJacG = C2HSImp.FunPtr (C2HSImp.CInt -> C2HSImp.Ptr C2HSImp.CDouble -> C2HSImp.CInt -> C2HSImp.CInt -> C2HSImp.CInt -> C2HSImp.Ptr C2HSImp.CInt -> C2HSImp.Ptr C2HSImp.CInt -> C2HSImp.Ptr C2HSImp.CDouble -> C2HSImp.Ptr () -> IO C2HSImp.CInt)
- type IpH = C2HSImp.FunPtr (C2HSImp.CInt -> C2HSImp.Ptr C2HSImp.CDouble -> C2HSImp.CInt -> C2HSImp.CDouble -> C2HSImp.CInt -> C2HSImp.Ptr C2HSImp.CDouble -> C2HSImp.CInt -> C2HSImp.CInt -> C2HSImp.Ptr C2HSImp.CInt -> C2HSImp.Ptr C2HSImp.CInt -> C2HSImp.Ptr C2HSImp.CDouble -> C2HSImp.Ptr () -> IO C2HSImp.CInt)
- newtype IpProblem = IpProblem (C2HSImp.ForeignPtr IpProblem)
- type IntermediateCB = C2HSImp.CInt -> C2HSImp.CInt -> Double -> Double -> Double -> Double -> Double -> Double -> Double -> Double -> C2HSImp.CInt -> C2HSImp.Ptr () -> IO IpBool
- data ApplicationReturnStatus
- = InternalError
- | InsufficientMemory
- | NonipoptExceptionThrown
- | UnrecoverableException
- | InvalidNumberDetected
- | InvalidOption
- | InvalidProblemDefinition
- | NotEnoughDegreesOfFreedom
- | MaximumCputimeExceeded
- | ErrorInStepComputation
- | RestorationFailed
- | MaximumIterationsExceeded
- | SolveSucceeded
- | SolvedToAcceptableLevel
- | InfeasibleProblemDetected
- | SearchDirectionBecomesTooSmall
- | DivergingIterates
- | UserRequestedStop
- | FeasiblePointFound
- createIpoptProblem :: Vec -> Vec -> Vec -> Vec -> Int -> Int -> IpF -> IpG -> IpGradF -> IpJacG -> IpH -> IO IpProblem
- freeIpoptProblem :: C2HSImp.FunPtr (C2HSImp.Ptr () -> IO ())
- setIpoptProblemScaling :: IpProblem -> Double -> Vec -> Vec -> IO Bool
- setIntermediateCallback :: IpProblem -> IntermediateCB -> IO Bool
- wrapIpF :: (VM.MVector s C2HSImp.CDouble -> IO C2HSImp.CDouble) -> IO IpF
- wrapIpGradF :: (VM.MVector s C2HSImp.CDouble -> IO (VM.MVector RealWorld C2HSImp.CDouble)) -> IO IpGradF
- wrapIpG :: (VM.MVector s C2HSImp.CDouble -> IO (VM.MVector RealWorld C2HSImp.CDouble)) -> IO IpG
- wrapIpJacG :: (VM.MVector s C2HSImp.CInt -> VM.MVector s1 C2HSImp.CInt -> IO b) -> (VM.MVector s2 C2HSImp.CDouble -> VM.MVector s3 C2HSImp.CDouble -> IO b1) -> IO IpJacG
- wrapIpH :: (VM.MVector s3 C2HSImp.CInt -> VM.MVector s4 C2HSImp.CInt -> IO b1) -> (C2HSImp.CDouble -> VM.MVector s C2HSImp.CDouble -> VM.MVector s1 C2HSImp.CDouble -> VM.MVector s2 C2HSImp.CDouble -> IO b) -> IO IpH
- wrapIpF1 :: UnFunPtr IpF -> IO IpF
- wrapIpGradF1 :: UnFunPtr IpGradF -> IO IpGradF
- wrapIpG1 :: UnFunPtr IpG -> IO IpG
- wrapIpJacG1 :: UnFunPtr IpJacG -> IO IpJacG
- wrapIpH1 :: UnFunPtr IpH -> IO IpH
- wrapIpF2 :: (Integral a2, Storable a, Storable a1) => (VM.MVector s a1 -> IO a) -> a2 -> C2HSImp.Ptr a1 -> t -> C2HSImp.Ptr a -> t1 -> IO IpBool
- wrapIpGradF2 :: (Integral a2, Storable a, Storable a1) => (VM.MVector s a1 -> IO (VM.MVector RealWorld a)) -> a2 -> C2HSImp.Ptr a1 -> t -> C2HSImp.Ptr a -> t1 -> IO IpBool
- wrapIpG2 :: (Integral a1, Integral a3, Storable a, Storable a2) => (VM.MVector s a2 -> IO (VM.MVector RealWorld a)) -> a3 -> C2HSImp.Ptr a2 -> t -> a1 -> C2HSImp.Ptr a -> t1 -> IO IpBool
- wrapIpJacG2 :: (Integral a3, Integral a5, Storable a, Storable a1, Storable a2, Storable a4) => (VM.MVector s a -> VM.MVector s1 a1 -> IO b) -> (VM.MVector s2 a2 -> VM.MVector s3 a4 -> IO b1) -> a3 -> C2HSImp.Ptr a2 -> t -> t1 -> a5 -> C2HSImp.Ptr a -> C2HSImp.Ptr a1 -> C2HSImp.Ptr a4 -> t2 -> IO IpBool
- wrapIpH2 :: (Integral a1, Integral a3, Integral a7, Storable a, Storable a2, Storable a4, Storable a5, Storable a6) => (VM.MVector s3 a5 -> VM.MVector s4 a6 -> IO b1) -> (t3 -> VM.MVector s a -> VM.MVector s1 a2 -> VM.MVector s2 a4 -> IO b) -> a3 -> C2HSImp.Ptr a2 -> t -> t3 -> a1 -> C2HSImp.Ptr a -> t1 -> a7 -> C2HSImp.Ptr a5 -> C2HSImp.Ptr a6 -> C2HSImp.Ptr a4 -> t2 -> IO IpBool
specifying problem
:: Vec |
|
-> Vec |
|
-> Vec |
|
-> Vec |
|
-> (forall a. AnyRFCxt a => V.Vector a -> a) | objective function |
-> (forall a. AnyRFCxt a => V.Vector a -> V.Vector a) | constraint functions |
-> IO IpProblem |
Set-up an IpProblem
to be solved later. Only objective function (f
)
and constraint functions (g
) need to be specified. Derivatives needed by ipopt
are computed by Numeric.AD.
To solve the optimization problem:
min f(x) such that xL <= x <= xU gL <= g(x) <= gU
First create an opaque IpProblem
object (nlp):
nlp <- createIpOptProblemAD xL xU gL gU f g
Then pass it off to ipoptSolve
.
ipoptSolve nlp x0
Refer to examples/HS71ad.hs
for details of setting up the vectors supplied.
createIpoptProblemADSparse Source
:: Vec |
|
-> Vec |
|
-> Vec |
|
-> Vec |
|
-> (V.Vector (Sparse.Sparse C2HSImp.CDouble) -> Sparse.Sparse C2HSImp.CDouble) | objective function |
-> (V.Vector (Sparse.Sparse C2HSImp.CDouble) -> V.Vector (Sparse.Sparse C2HSImp.CDouble)) | constraint functions |
-> IO IpProblem |
this is 50% slower than createIpoptProblemAD
in one instance
http://code.haskell.org/~aavogt/ipopt-hs/examples/bench.html#williams-otto-process).
But the benefit is that no RankN types are used (so it is possible to implement
more functions without having to modify AnyRFCxt
)
solve
data IpOptSolved v Source
lenses are in Ipopt.PP
solver options
types
type Vec = VM.IOVector Double Source
Vector of numbers
type IpNumber = C2HSImp.CDouble Source
type IpIndex = C2HSImp.CInt Source
type IpInt = C2HSImp.CInt Source
type IpBool = C2HSImp.CInt Source
type IpF = C2HSImp.FunPtr (C2HSImp.CInt -> C2HSImp.Ptr C2HSImp.CDouble -> C2HSImp.CInt -> C2HSImp.Ptr C2HSImp.CDouble -> C2HSImp.Ptr () -> IO C2HSImp.CInt) Source
type IpGradF = C2HSImp.FunPtr (C2HSImp.CInt -> C2HSImp.Ptr C2HSImp.CDouble -> C2HSImp.CInt -> C2HSImp.Ptr C2HSImp.CDouble -> C2HSImp.Ptr () -> IO C2HSImp.CInt) Source
type IpG = C2HSImp.FunPtr (C2HSImp.CInt -> C2HSImp.Ptr C2HSImp.CDouble -> C2HSImp.CInt -> C2HSImp.CInt -> C2HSImp.Ptr C2HSImp.CDouble -> C2HSImp.Ptr () -> IO C2HSImp.CInt) Source
type IpJacG = C2HSImp.FunPtr (C2HSImp.CInt -> C2HSImp.Ptr C2HSImp.CDouble -> C2HSImp.CInt -> C2HSImp.CInt -> C2HSImp.CInt -> C2HSImp.Ptr C2HSImp.CInt -> C2HSImp.Ptr C2HSImp.CInt -> C2HSImp.Ptr C2HSImp.CDouble -> C2HSImp.Ptr () -> IO C2HSImp.CInt) Source
type IpH = C2HSImp.FunPtr (C2HSImp.CInt -> C2HSImp.Ptr C2HSImp.CDouble -> C2HSImp.CInt -> C2HSImp.CDouble -> C2HSImp.CInt -> C2HSImp.Ptr C2HSImp.CDouble -> C2HSImp.CInt -> C2HSImp.CInt -> C2HSImp.Ptr C2HSImp.CInt -> C2HSImp.Ptr C2HSImp.CInt -> C2HSImp.Ptr C2HSImp.CDouble -> C2HSImp.Ptr () -> IO C2HSImp.CInt) Source
type IntermediateCB Source
= C2HSImp.CInt | alg_mod (0 regular, 1 is resto) |
-> C2HSImp.CInt | iter count |
-> Double | obj value |
-> Double | inf_pr |
-> Double | inf_du |
-> Double | mu |
-> Double | d_norm |
-> Double | regularization_size |
-> Double | alpha_du |
-> Double | alpha_pr |
-> C2HSImp.CInt | ls_trials |
-> C2HSImp.Ptr () | user_data (usually null) |
-> IO IpBool |
data ApplicationReturnStatus Source
lower-level parts of the binding
createIpoptProblem :: Vec -> Vec -> Vec -> Vec -> Int -> Int -> IpF -> IpG -> IpGradF -> IpJacG -> IpH -> IO IpProblem Source
freeIpoptProblem :: C2HSImp.FunPtr (C2HSImp.Ptr () -> IO ()) Source
marshalling functions
wrapIpF :: (VM.MVector s C2HSImp.CDouble -> IO C2HSImp.CDouble) -> IO IpF Source
wrapIpGradF :: (VM.MVector s C2HSImp.CDouble -> IO (VM.MVector RealWorld C2HSImp.CDouble)) -> IO IpGradF Source
wrapIpG :: (VM.MVector s C2HSImp.CDouble -> IO (VM.MVector RealWorld C2HSImp.CDouble)) -> IO IpG Source
wrapIpJacG :: (VM.MVector s C2HSImp.CInt -> VM.MVector s1 C2HSImp.CInt -> IO b) -> (VM.MVector s2 C2HSImp.CDouble -> VM.MVector s3 C2HSImp.CDouble -> IO b1) -> IO IpJacG Source
wrapIpH :: (VM.MVector s3 C2HSImp.CInt -> VM.MVector s4 C2HSImp.CInt -> IO b1) -> (C2HSImp.CDouble -> VM.MVector s C2HSImp.CDouble -> VM.MVector s1 C2HSImp.CDouble -> VM.MVector s2 C2HSImp.CDouble -> IO b) -> IO IpH Source
wrapIpGradF1 :: UnFunPtr IpGradF -> IO IpGradF Source
wrapIpJacG1 :: UnFunPtr IpJacG -> IO IpJacG Source
wrapIpF2 :: (Integral a2, Storable a, Storable a1) => (VM.MVector s a1 -> IO a) -> a2 -> C2HSImp.Ptr a1 -> t -> C2HSImp.Ptr a -> t1 -> IO IpBool Source
wrapIpGradF2 :: (Integral a2, Storable a, Storable a1) => (VM.MVector s a1 -> IO (VM.MVector RealWorld a)) -> a2 -> C2HSImp.Ptr a1 -> t -> C2HSImp.Ptr a -> t1 -> IO IpBool Source
wrapIpG2 :: (Integral a1, Integral a3, Storable a, Storable a2) => (VM.MVector s a2 -> IO (VM.MVector RealWorld a)) -> a3 -> C2HSImp.Ptr a2 -> t -> a1 -> C2HSImp.Ptr a -> t1 -> IO IpBool Source
wrapIpJacG2 :: (Integral a3, Integral a5, Storable a, Storable a1, Storable a2, Storable a4) => (VM.MVector s a -> VM.MVector s1 a1 -> IO b) -> (VM.MVector s2 a2 -> VM.MVector s3 a4 -> IO b1) -> a3 -> C2HSImp.Ptr a2 -> t -> t1 -> a5 -> C2HSImp.Ptr a -> C2HSImp.Ptr a1 -> C2HSImp.Ptr a4 -> t2 -> IO IpBool Source
wrapIpH2 :: (Integral a1, Integral a3, Integral a7, Storable a, Storable a2, Storable a4, Storable a5, Storable a6) => (VM.MVector s3 a5 -> VM.MVector s4 a6 -> IO b1) -> (t3 -> VM.MVector s a -> VM.MVector s1 a2 -> VM.MVector s2 a4 -> IO b) -> a3 -> C2HSImp.Ptr a2 -> t -> t3 -> a1 -> C2HSImp.Ptr a -> t1 -> a7 -> C2HSImp.Ptr a5 -> C2HSImp.Ptr a6 -> C2HSImp.Ptr a4 -> t2 -> IO IpBool Source