packages feed

casadi-bindings-control (empty) → 2.0.0.1

raw patch · 9 files changed

+1190/−0 lines, 9 filesdep +basedep +casadi-bindings-coredep +casadi-bindings-internalsetup-changed

Dependencies added: base, casadi-bindings-core, casadi-bindings-internal, vector

Files

+ Casadi/Control/Classes/DpleSolver.hs view
@@ -0,0 +1,160 @@+{-# OPTIONS_GHC -Wall #-}+{-# OPTIONS_GHC -fno-warn-unused-imports #-}+{-# OPTIONS_GHC -fno-warn-orphans #-}+{-# Language ForeignFunctionInterface #-}+{-# Language FlexibleInstances #-}+{-# Language MultiParamTypeClasses #-}++module Casadi.Control.Classes.DpleSolver+       (+         DpleSolver,+         DpleSolverClass(..),+         dpleSolver__0,+         dpleSolver__1,+         dpleSolver_clone,+         dpleSolver_doc,+         dpleSolver_loadPlugin,+         dpleSolver_printStats,+       ) where+++import Prelude hiding ( Functor )++import Data.Vector ( Vector )+import Foreign.C.Types+import Foreign.Marshal ( new, free )+import Foreign.Storable ( peek )+import Foreign.Ptr ( Ptr, nullPtr )+import Foreign.ForeignPtr ( newForeignPtr )+import System.IO.Unsafe ( unsafePerformIO ) -- for show instances++import Casadi.Internal.CToolsInstances ( )+import Casadi.Internal.FormatException ( formatException )+import Casadi.Internal.MarshalTypes ( StdVec, StdString) -- StdPair StdOstream'+import Casadi.Internal.Marshal ( Marshal(..), withMarshal )+import Casadi.Internal.WrapReturn ( WrapReturn(..) )+import Casadi.Control.Data+import Casadi.Control.Enums+import Casadi.Core.Data++-- direct wrapper+foreign import ccall unsafe "casadi__DpleSolver__CONSTRUCTOR__0" c_casadi__DpleSolver__CONSTRUCTOR__0+  :: Ptr (Ptr StdString) -> Ptr StdString -> Ptr (StdVec (Ptr Sparsity')) -> Ptr (StdVec (Ptr Sparsity')) -> IO (Ptr DpleSolver')+casadi__DpleSolver__CONSTRUCTOR__0+  :: String -> Vector Sparsity -> Vector Sparsity -> IO DpleSolver+casadi__DpleSolver__CONSTRUCTOR__0 x0 x1 x2 =+  withMarshal x0 $ \x0' ->+  withMarshal x1 $ \x1' ->+  withMarshal x2 $ \x2' ->+  do+    errStrPtrP <- new nullPtr+    ret <- c_casadi__DpleSolver__CONSTRUCTOR__0 errStrPtrP x0' x1' x2'+    errStrPtr <- peek errStrPtrP+    free errStrPtrP+    if errStrPtr == nullPtr then wrapReturn ret else wrapReturn errStrPtr >>= (error . formatException)+++-- classy wrapper+dpleSolver__0 :: String -> Vector Sparsity -> Vector Sparsity -> IO DpleSolver+dpleSolver__0 = casadi__DpleSolver__CONSTRUCTOR__0+++-- direct wrapper+foreign import ccall unsafe "casadi__DpleSolver__CONSTRUCTOR__1" c_casadi__DpleSolver__CONSTRUCTOR__1+  :: Ptr (Ptr StdString) -> IO (Ptr DpleSolver')+casadi__DpleSolver__CONSTRUCTOR__1+  :: IO DpleSolver+casadi__DpleSolver__CONSTRUCTOR__1  =++  do+    errStrPtrP <- new nullPtr+    ret <- c_casadi__DpleSolver__CONSTRUCTOR__1 errStrPtrP +    errStrPtr <- peek errStrPtrP+    free errStrPtrP+    if errStrPtr == nullPtr then wrapReturn ret else wrapReturn errStrPtr >>= (error . formatException)+++-- classy wrapper+dpleSolver__1 :: IO DpleSolver+dpleSolver__1 = casadi__DpleSolver__CONSTRUCTOR__1+++-- direct wrapper+foreign import ccall unsafe "casadi__DpleSolver__clone" c_casadi__DpleSolver__clone+  :: Ptr (Ptr StdString) -> Ptr DpleSolver' -> IO (Ptr DpleSolver')+casadi__DpleSolver__clone+  :: DpleSolver -> IO DpleSolver+casadi__DpleSolver__clone x0 =+  withMarshal x0 $ \x0' ->+  do+    errStrPtrP <- new nullPtr+    ret <- c_casadi__DpleSolver__clone errStrPtrP x0'+    errStrPtr <- peek errStrPtrP+    free errStrPtrP+    if errStrPtr == nullPtr then wrapReturn ret else wrapReturn errStrPtr >>= (error . formatException)+++-- classy wrapper+dpleSolver_clone :: DpleSolverClass a => a -> IO DpleSolver+dpleSolver_clone x = casadi__DpleSolver__clone (castDpleSolver x)+++-- direct wrapper+foreign import ccall unsafe "casadi__DpleSolver__doc" c_casadi__DpleSolver__doc+  :: Ptr (Ptr StdString) -> Ptr StdString -> IO (Ptr StdString)+casadi__DpleSolver__doc+  :: String -> IO String+casadi__DpleSolver__doc x0 =+  withMarshal x0 $ \x0' ->+  do+    errStrPtrP <- new nullPtr+    ret <- c_casadi__DpleSolver__doc errStrPtrP x0'+    errStrPtr <- peek errStrPtrP+    free errStrPtrP+    if errStrPtr == nullPtr then wrapReturn ret else wrapReturn errStrPtr >>= (error . formatException)+++-- classy wrapper+dpleSolver_doc :: String -> IO String+dpleSolver_doc = casadi__DpleSolver__doc+++-- direct wrapper+foreign import ccall unsafe "casadi__DpleSolver__loadPlugin" c_casadi__DpleSolver__loadPlugin+  :: Ptr (Ptr StdString) -> Ptr StdString -> IO ()+casadi__DpleSolver__loadPlugin+  :: String -> IO ()+casadi__DpleSolver__loadPlugin x0 =+  withMarshal x0 $ \x0' ->+  do+    errStrPtrP <- new nullPtr+    ret <- c_casadi__DpleSolver__loadPlugin errStrPtrP x0'+    errStrPtr <- peek errStrPtrP+    free errStrPtrP+    if errStrPtr == nullPtr then wrapReturn ret else wrapReturn errStrPtr >>= (error . formatException)+++-- classy wrapper+dpleSolver_loadPlugin :: String -> IO ()+dpleSolver_loadPlugin = casadi__DpleSolver__loadPlugin+++-- direct wrapper+foreign import ccall unsafe "casadi__DpleSolver__printStats" c_casadi__DpleSolver__printStats+  :: Ptr (Ptr StdString) -> Ptr DpleSolver' -> IO ()+casadi__DpleSolver__printStats+  :: DpleSolver -> IO ()+casadi__DpleSolver__printStats x0 =+  withMarshal x0 $ \x0' ->+  do+    errStrPtrP <- new nullPtr+    ret <- c_casadi__DpleSolver__printStats errStrPtrP x0'+    errStrPtr <- peek errStrPtrP+    free errStrPtrP+    if errStrPtr == nullPtr then wrapReturn ret else wrapReturn errStrPtr >>= (error . formatException)+++-- classy wrapper+dpleSolver_printStats :: DpleSolverClass a => a -> IO ()+dpleSolver_printStats x = casadi__DpleSolver__printStats (castDpleSolver x)+
+ Casadi/Control/Data.hs view
@@ -0,0 +1,323 @@+{-# OPTIONS_GHC -Wall #-}+{-# Language FlexibleInstances #-}+{-# Language MultiParamTypeClasses #-}++module Casadi.Control.Data where++import Prelude hiding ( Functor )++import Foreign.Ptr ( Ptr, FunPtr )+import Foreign.ForeignPtr ( ForeignPtr, castForeignPtr, newForeignPtr, touchForeignPtr )+import Foreign.ForeignPtr.Unsafe ( unsafeForeignPtrToPtr )++import Casadi.Internal.Marshal (  Marshal(..) )+import Casadi.Internal.WrapReturn ( WrapReturn(..) )+import Casadi.Core.Data++-- raw decl+data DpleSolver'+-- data decl+{-|+>Base class for Discrete Periodic Lyapunov Equation Solvers.+>+>Given matrices $A_k$ and symmetric $V_k, k = 0..K-1$+>+>+>+>::+>+>  A_k in R^(n x n)+>  V_k in R^n+>  +>+>+>+>provides all of $P_k$ that satisfy:+>+>+>+>::+>+>  P_0 = A_(K-1)*P_(K-1)*A_(K-1)' + V_k+>  P_k+1 = A_k*P_k*A_k' + V_k  for k = 1..K-1+>  +>+>+>+>General information+>===================+>+>+>+>>Input scheme: casadi::DPLEInput (DPLE_NUM_IN = 2) [dpleIn]+>+>+------------------------+------------------------+------------------------++>|       Full name        |         Short          |      Description       |+>+========================+========================+========================++>| DPLE_A                 | a                      | A matrices (horzcat    |+>|                        |                        | when const_dim,        |+>|                        |                        | blkdiag otherwise) .   |+>+------------------------+------------------------+------------------------++>| DPLE_V                 | v                      | V matrices (horzcat    |+>|                        |                        | when const_dim,        |+>|                        |                        | blkdiag otherwise) .   |+>+------------------------+------------------------+------------------------++>+>>Output scheme: casadi::DPLEOutput (DPLE_NUM_OUT = 1) [dpleOut]+>+>+------------------------+------------------------+------------------------++>|       Full name        |         Short          |      Description       |+>+========================+========================+========================++>| DPLE_P                 | p                      | Lyapunov matrix        |+>|                        |                        | (horzcat when          |+>|                        |                        | const_dim, blkdiag     |+>|                        |                        | otherwise) (Cholesky   |+>|                        |                        | of P if pos_def) .     |+>+------------------------+------------------------+------------------------++>+>>List of available options+>+>+--------------+--------------+--------------+--------------+--------------++>|      Id      |     Type     |   Default    | Description  |   Used in    |+>+==============+==============+==============+==============+==============++>| ad_mode      | OT_STRING    | "automatic"  | How to       | casadi::Func |+>|              |              |              | calculate    | tionInternal |+>|              |              |              | the          |              |+>|              |              |              | Jacobians.   |              |+>|              |              |              | (forward:    |              |+>|              |              |              | only forward |              |+>|              |              |              | mode|reverse |              |+>|              |              |              | : only       |              |+>|              |              |              | adjoint mode |              |+>|              |              |              | |automatic:  |              |+>|              |              |              | a heuristic  |              |+>|              |              |              | decides      |              |+>|              |              |              | which is     |              |+>|              |              |              | more         |              |+>|              |              |              | appropriate) |              |+>+--------------+--------------+--------------+--------------+--------------++>| const_dim    | OT_BOOLEAN   | true         | Assume       | casadi::Dple |+>|              |              |              | constant     | Internal     |+>|              |              |              | dimension of |              |+>|              |              |              | P            |              |+>+--------------+--------------+--------------+--------------+--------------++>| derivative_g | OT_DERIVATIV | GenericType( | Function     | casadi::Func |+>| enerator     | EGENERATOR   | )            | that returns | tionInternal |+>|              |              |              | a derivative |              |+>|              |              |              | function     |              |+>|              |              |              | given a      |              |+>|              |              |              | number of    |              |+>|              |              |              | forward and  |              |+>|              |              |              | reverse      |              |+>|              |              |              | directional  |              |+>|              |              |              | derivative,  |              |+>|              |              |              | overrides    |              |+>|              |              |              | internal     |              |+>|              |              |              | routines.    |              |+>|              |              |              | Check docume |              |+>|              |              |              | ntation of D |              |+>|              |              |              | erivativeGen |              |+>|              |              |              | erator .     |              |+>+--------------+--------------+--------------+--------------+--------------++>| eps_unstable | OT_REAL      | 0.000        | A margin for | casadi::Dple |+>|              |              |              | unstability  | Internal     |+>|              |              |              | detection    |              |+>+--------------+--------------+--------------+--------------+--------------++>| error_unstab | OT_BOOLEAN   | false        | Throw an     | casadi::Dple |+>| le           |              |              | exception    | Internal     |+>|              |              |              | when it is   |              |+>|              |              |              | detected     |              |+>|              |              |              | that         |              |+>|              |              |              | Product(A_i, |              |+>|              |              |              | i=N..1) has  |              |+>|              |              |              | eigenvalues  |              |+>|              |              |              | greater than |              |+>|              |              |              | 1-eps_unstab |              |+>|              |              |              | le           |              |+>+--------------+--------------+--------------+--------------+--------------++>| gather_stats | OT_BOOLEAN   | false        | Flag to      | casadi::Func |+>|              |              |              | indicate     | tionInternal |+>|              |              |              | whether      |              |+>|              |              |              | statistics   |              |+>|              |              |              | must be      |              |+>|              |              |              | gathered     |              |+>+--------------+--------------+--------------+--------------+--------------++>| inputs_check | OT_BOOLEAN   | true         | Throw        | casadi::Func |+>|              |              |              | exceptions   | tionInternal |+>|              |              |              | when the     |              |+>|              |              |              | numerical    |              |+>|              |              |              | values of    |              |+>|              |              |              | the inputs   |              |+>|              |              |              | don't make   |              |+>|              |              |              | sense        |              |+>+--------------+--------------+--------------+--------------+--------------++>| monitor      | OT_STRINGVEC | GenericType( | Monitors to  | casadi::Func |+>|              | TOR          | )            | be activated | tionInternal |+>|              |              |              | (inputs|outp |              |+>|              |              |              | uts)         |              |+>+--------------+--------------+--------------+--------------+--------------++>| name         | OT_STRING    | "unnamed_sha | name of the  | casadi::Opti |+>|              |              | red_object"  | object       | onsFunctiona |+>|              |              |              |              | lityNode     |+>+--------------+--------------+--------------+--------------+--------------++>| pos_def      | OT_BOOLEAN   | false        | Assume P     | casadi::Dple |+>|              |              |              | positive     | Internal     |+>|              |              |              | definite     |              |+>+--------------+--------------+--------------+--------------+--------------++>| regularity_c | OT_BOOLEAN   | true         | Throw        | casadi::Func |+>| heck         |              |              | exceptions   | tionInternal |+>|              |              |              | when NaN or  |              |+>|              |              |              | Inf appears  |              |+>|              |              |              | during       |              |+>|              |              |              | evaluation   |              |+>+--------------+--------------+--------------+--------------+--------------++>| user_data    | OT_VOIDPTR   | GenericType( | A user-      | casadi::Func |+>|              |              | )            | defined      | tionInternal |+>|              |              |              | field that   |              |+>|              |              |              | can be used  |              |+>|              |              |              | to identify  |              |+>|              |              |              | the function |              |+>|              |              |              | or pass      |              |+>|              |              |              | additional   |              |+>|              |              |              | information  |              |+>+--------------+--------------+--------------+--------------+--------------++>| verbose      | OT_BOOLEAN   | false        | Verbose      | casadi::Func |+>|              |              |              | evaluation   | tionInternal |+>|              |              |              | for          |              |+>|              |              |              | debugging    |              |+>+--------------+--------------+--------------+--------------+--------------++>+>List of plugins+>===============+>+>+>+>- <a href='#plugin_DpleSolver_simple'>simple</a>+>+>- <a href='#plugin_DpleSolver_slicot'>slicot</a>+>+>Note: some of the plugins in this list might not be available on your+>system. Also, there might be extra plugins available to you that are not+>listed here. You can obtain their documentation with+>DpleSolver.doc("myextraplugin")+>+>+>+>--------------------------------------------------------------------------------+>+>simple+>------+>+>+>+>Solving the Discrete Periodic Lyapunov Equations with a regular LinearSolver+>+>>List of available options+>+>+-----------------+-----------------+-----------------+-----------------++>|       Id        |      Type       |     Default     |   Description   |+>+=================+=================+=================+=================++>| linear_solver   | OT_STRING       | GenericType()   | User-defined    |+>|                 |                 |                 | linear solver   |+>|                 |                 |                 | class. Needed   |+>|                 |                 |                 | for             |+>|                 |                 |                 | sensitivities.  |+>+-----------------+-----------------+-----------------+-----------------++>| linear_solver_o | OT_DICTIONARY   | GenericType()   | Options to be   |+>| ptions          |                 |                 | passed to the   |+>|                 |                 |                 | linear solver.  |+>+-----------------+-----------------+-----------------+-----------------++>+>--------------------------------------------------------------------------------+>+>+>+>--------------------------------------------------------------------------------+>+>slicot+>------+>+>+>+>An efficient solver for Discrete Periodic Lyapunov Equations using SLICOT+>+>Uses Periodic Schur Decomposition ('psd') and does not assume positive+>definiteness. Based on Periodic Lyapunov equations: some applications and+>new algorithms. Int. J. Control, vol. 67, pp. 69-87, 1997.+>+>>List of available options+>+>+-----------------+-----------------+-----------------+-----------------++>|       Id        |      Type       |     Default     |   Description   |+>+=================+=================+=================+=================++>| linear_solver   | OT_STRING       | GenericType()   | User-defined    |+>|                 |                 |                 | linear solver   |+>|                 |                 |                 | class. Needed   |+>|                 |                 |                 | for             |+>|                 |                 |                 | sensitivities.  |+>+-----------------+-----------------+-----------------+-----------------++>| linear_solver_o | OT_DICTIONARY   | GenericType()   | Options to be   |+>| ptions          |                 |                 | passed to the   |+>|                 |                 |                 | linear solver.  |+>+-----------------+-----------------+-----------------+-----------------++>| psd_num_zero    | OT_REAL         | 0.000           | Numerical zero  |+>|                 |                 |                 | used in         |+>|                 |                 |                 | Periodic Schur  |+>|                 |                 |                 | decomposition   |+>|                 |                 |                 | with            |+>|                 |                 |                 | slicot.This     |+>|                 |                 |                 | option is       |+>|                 |                 |                 | needed when     |+>|                 |                 |                 | your systems    |+>|                 |                 |                 | has Floquet     |+>|                 |                 |                 | multiplierszero |+>|                 |                 |                 | or close to     |+>|                 |                 |                 | zero            |+>+-----------------+-----------------+-----------------+-----------------++>+>>List of available stats+>+>+----------------++>|       Id       |+>+================++>| t_linear_solve |+>+----------------++>| t_psd          |+>+----------------++>| t_total        |+>+----------------++>+>--------------------------------------------------------------------------------+>+>+>+>Joris Gillis+>Diagrams+>--------+>+>+>+>C++ includes: dple_solver.hpp +-}+newtype DpleSolver = DpleSolver (ForeignPtr DpleSolver')+-- typeclass decl+class DpleSolverClass a where+  castDpleSolver :: a -> DpleSolver+instance DpleSolverClass DpleSolver where+  castDpleSolver = id++-- baseclass instances+instance FunctionClass DpleSolver where+  castFunction (DpleSolver x) = Function (castForeignPtr x)+++-- helper instances+instance Marshal DpleSolver (Ptr DpleSolver') where+  marshal (DpleSolver x) = return (unsafeForeignPtrToPtr x)+  marshalFree (DpleSolver x) _ = touchForeignPtr x+foreign import ccall unsafe "&delete_casadi__DpleSolver" +  c_delete_casadi__DpleSolver :: FunPtr (Ptr DpleSolver' -> IO ())+instance WrapReturn (Ptr DpleSolver') DpleSolver where+  wrapReturn = (fmap DpleSolver) . (newForeignPtr c_delete_casadi__DpleSolver)++
+ Casadi/Control/Enums.hs view
@@ -0,0 +1,50 @@+{-# OPTIONS_GHC -Wall #-}+{-# OPTIONS_GHC -fno-warn-unused-imports #-}+{-# LANGUAGE MultiParamTypeClasses #-}++module Casadi.Control.Enums+       (+         DPLEInput(..),+         DPLEOutput(..),+       ) where+++import Foreign.C.Types ( CInt(..) )+import Casadi.Internal.Marshal ( Marshal(..) )+import Casadi.Internal.WrapReturn ( WrapReturn(..) )++-- EnumDecl: DPLEInput+data DPLEInput = DPLE_A+               | DPLE_NUM_IN+               | DPLE_V+               deriving (Show, Eq)+instance Enum DPLEInput where+        fromEnum (DPLE_A) = 0+        fromEnum (DPLE_NUM_IN) = 2+        fromEnum (DPLE_V) = 1+        toEnum (0) = DPLE_A+        toEnum (2) = DPLE_NUM_IN+        toEnum (1) = DPLE_V+        toEnum k+          = error $ "DPLEInput: toEnum: got unhandled number: " ++ show k+instance Marshal DPLEInput CInt where+        marshal = return . fromIntegral . fromEnum+instance WrapReturn CInt DPLEInput where+        wrapReturn = return . toEnum . fromIntegral++-- EnumDecl: DPLEOutput+data DPLEOutput = DPLE_NUM_OUT+                | DPLE_P+                deriving (Show, Eq)+instance Enum DPLEOutput where+        fromEnum (DPLE_NUM_OUT) = 1+        fromEnum (DPLE_P) = 0+        toEnum (1) = DPLE_NUM_OUT+        toEnum (0) = DPLE_P+        toEnum k+          = error $ "DPLEOutput: toEnum: got unhandled number: " ++ show k+instance Marshal DPLEOutput CInt where+        marshal = return . fromIntegral . fromEnum+instance WrapReturn CInt DPLEOutput where+        wrapReturn = return . toEnum . fromIntegral+
+ LICENSE view
@@ -0,0 +1,165 @@+                  GNU LESSER GENERAL PUBLIC LICENSE+                       Version 3, 29 June 2007++ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>+ Everyone is permitted to copy and distribute verbatim copies+ of this license document, but changing it is not allowed.+++  This version of the GNU Lesser General Public License incorporates+the terms and conditions of version 3 of the GNU General Public+License, supplemented by the additional permissions listed below.++  0. Additional Definitions. ++  As used herein, "this License" refers to version 3 of the GNU Lesser+General Public License, and the "GNU GPL" refers to version 3 of the GNU+General Public License.++  "The Library" refers to a covered work governed by this License,+other than an Application or a Combined Work as defined below.++  An "Application" is any work that makes use of an interface provided+by the Library, but which is not otherwise based on the Library.+Defining a subclass of a class defined by the Library is deemed a mode+of using an interface provided by the Library.++  A "Combined Work" is a work produced by combining or linking an+Application with the Library.  The particular version of the Library+with which the Combined Work was made is also called the "Linked+Version".++  The "Minimal Corresponding Source" for a Combined Work means the+Corresponding Source for the Combined Work, excluding any source code+for portions of the Combined Work that, considered in isolation, are+based on the Application, and not on the Linked Version.++  The "Corresponding Application Code" for a Combined Work means the+object code and/or source code for the Application, including any data+and utility programs needed for reproducing the Combined Work from the+Application, but excluding the System Libraries of the Combined Work.++  1. Exception to Section 3 of the GNU GPL.++  You may convey a covered work under sections 3 and 4 of this License+without being bound by section 3 of the GNU GPL.++  2. Conveying Modified Versions.++  If you modify a copy of the Library, and, in your modifications, a+facility refers to a function or data to be supplied by an Application+that uses the facility (other than as an argument passed when the+facility is invoked), then you may convey a copy of the modified+version:++   a) under this License, provided that you make a good faith effort to+   ensure that, in the event an Application does not supply the+   function or data, the facility still operates, and performs+   whatever part of its purpose remains meaningful, or++   b) under the GNU GPL, with none of the additional permissions of+   this License applicable to that copy.++  3. Object Code Incorporating Material from Library Header Files.++  The object code form of an Application may incorporate material from+a header file that is part of the Library.  You may convey such object+code under terms of your choice, provided that, if the incorporated+material is not limited to numerical parameters, data structure+layouts and accessors, or small macros, inline functions and templates+(ten or fewer lines in length), you do both of the following:++   a) Give prominent notice with each copy of the object code that the+   Library is used in it and that the Library and its use are+   covered by this License.++   b) Accompany the object code with a copy of the GNU GPL and this license+   document.++  4. Combined Works.++  You may convey a Combined Work under terms of your choice that,+taken together, effectively do not restrict modification of the+portions of the Library contained in the Combined Work and reverse+engineering for debugging such modifications, if you also do each of+the following:++   a) Give prominent notice with each copy of the Combined Work that+   the Library is used in it and that the Library and its use are+   covered by this License.++   b) Accompany the Combined Work with a copy of the GNU GPL and this license+   document.++   c) For a Combined Work that displays copyright notices during+   execution, include the copyright notice for the Library among+   these notices, as well as a reference directing the user to the+   copies of the GNU GPL and this license document.++   d) Do one of the following:++       0) Convey the Minimal Corresponding Source under the terms of this+       License, and the Corresponding Application Code in a form+       suitable for, and under terms that permit, the user to+       recombine or relink the Application with a modified version of+       the Linked Version to produce a modified Combined Work, in the+       manner specified by section 6 of the GNU GPL for conveying+       Corresponding Source.++       1) Use a suitable shared library mechanism for linking with the+       Library.  A suitable mechanism is one that (a) uses at run time+       a copy of the Library already present on the user's computer+       system, and (b) will operate properly with a modified version+       of the Library that is interface-compatible with the Linked+       Version. ++   e) Provide Installation Information, but only if you would otherwise+   be required to provide such information under section 6 of the+   GNU GPL, and only to the extent that such information is+   necessary to install and execute a modified version of the+   Combined Work produced by recombining or relinking the+   Application with a modified version of the Linked Version. (If+   you use option 4d0, the Installation Information must accompany+   the Minimal Corresponding Source and Corresponding Application+   Code. If you use option 4d1, you must provide the Installation+   Information in the manner specified by section 6 of the GNU GPL+   for conveying Corresponding Source.)++  5. Combined Libraries.++  You may place library facilities that are a work based on the+Library side by side in a single library together with other library+facilities that are not Applications and are not covered by this+License, and convey such a combined library under terms of your+choice, if you do both of the following:++   a) Accompany the combined library with a copy of the same work based+   on the Library, uncombined with any other library facilities,+   conveyed under the terms of this License.++   b) Give prominent notice with the combined library that part of it+   is a work based on the Library, and explaining where to find the+   accompanying uncombined form of the same work.++  6. Revised Versions of the GNU Lesser General Public License.++  The Free Software Foundation may publish revised and/or new versions+of the GNU Lesser General Public License from time to time. Such new+versions will be similar in spirit to the present version, but may+differ in detail to address new problems or concerns.++  Each version is given a distinguishing version number. If the+Library as you received it specifies that a certain numbered version+of the GNU Lesser General Public License "or any later version"+applies to it, you have the option of following the terms and+conditions either of that published version or of any later version+published by the Free Software Foundation. If the Library as you+received it does not specify a version number of the GNU Lesser+General Public License, you may choose any version of the GNU Lesser+General Public License ever published by the Free Software Foundation.++  If the Library as you received it specifies that a proxy can decide+whether future versions of the GNU Lesser General Public License shall+apply, that proxy's public statement of acceptance of any version is+permanent authorization for you to choose that version for the+Library.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMainWithHooks simpleUserHooks
+ casadi-bindings-control.cabal view
@@ -0,0 +1,38 @@+name:                casadi-bindings-control+version:             2.0.0.1+license:             LGPL-3+license-file:        LICENSE+category:            Numerical, Math+copyright:           (c) 2013-2014 Greg Horn+author:              Greg Horn+maintainer:          gregmainland@gmail.com+build-type:          Simple+cabal-version:       >=1.10+synopsis:            low level bindings to casadi-control+description:         see <http://hackage.haskell.org/package/casadi-bindings http://hackage.haskell.org/package/casadi-bindings> for all instructions+extra-source-files:  cbits/marshal.hpp+extra-tmp-files:     Casadi/Callback_stub.h++library+  build-depends:       base >=4.6 && <5,+                       vector >=0.10,+                       casadi-bindings-core,+                       casadi-bindings-internal == 0.1.1++  default-language:    Haskell2010+++  extra-libraries:  stdc++++  pkgconfig-depends: casadi_control++  ghc-prof-options: -prof -fprof-auto -fprof-cafs -rtsopts+  ghc-options: +  cc-options: -Wall -Wno-delete-non-virtual-dtor++  C-sources:        cbits/autogen/control_classes.cpp+                    cbits/autogen/control_functions.cpp++  exposed-modules:  Casadi.Control.Data+                    Casadi.Control.Enums+                    Casadi.Control.Classes.DpleSolver
+ cbits/autogen/control_classes.cpp view
@@ -0,0 +1,216 @@+#include "casadi/control/dple_solver.hpp"+#include "casadi/core/casadi_calculus.hpp"+#include "casadi/core/casadi_exception.hpp"+#include "casadi/core/casadi_meta.hpp"+#include "casadi/core/casadi_options.hpp"+#include "casadi/core/casadi_types.hpp"+#include "casadi/core/function/control_simulator.hpp"+#include "casadi/core/function/custom_function.hpp"+#include "casadi/core/function/external_function.hpp"+#include "casadi/core/function/function.hpp"+#include "casadi/core/function/homotopy_nlp_solver.hpp"+#include "casadi/core/function/implicit_function.hpp"+#include "casadi/core/function/integrator.hpp"+#include "casadi/core/function/io_interface.hpp"+#include "casadi/core/function/linear_solver.hpp"+#include "casadi/core/function/lp_solver.hpp"+#include "casadi/core/function/mx_function.hpp"+#include "casadi/core/function/nlp_solver.hpp"+#include "casadi/core/function/nullspace.hpp"+#include "casadi/core/function/ocp_solver.hpp"+#include "casadi/core/function/parallelizer.hpp"+#include "casadi/core/function/qcqp_solver.hpp"+#include "casadi/core/function/qp_solver.hpp"+#include "casadi/core/function/sdp_solver.hpp"+#include "casadi/core/function/sdqp_solver.hpp"+#include "casadi/core/function/simulator.hpp"+#include "casadi/core/function/socp_solver.hpp"+#include "casadi/core/function/stabilized_qp_solver.hpp"+#include "casadi/core/function/sx_function.hpp"+#include "casadi/core/functor.hpp"+#include "casadi/core/generic_type.hpp"+#include "casadi/core/matrix/generic_expression.hpp"+#include "casadi/core/matrix/generic_matrix.hpp"+#include "casadi/core/matrix/matrix.hpp"+#include "casadi/core/matrix/matrix_tools.hpp"+#include "casadi/core/matrix/slice.hpp"+#include "casadi/core/matrix/sparsity.hpp"+#include "casadi/core/matrix/sparsity_tools.hpp"+#include "casadi/core/misc/integration_tools.hpp"+#include "casadi/core/misc/symbolic_nlp.hpp"+#include "casadi/core/mx/mx.hpp"+#include "casadi/core/mx/mx_tools.hpp"+#include "casadi/core/options_functionality.hpp"+#include "casadi/core/printable_object.hpp"+#include "casadi/core/shared_object.hpp"+#include "casadi/core/std_vector_tools.hpp"+#include "casadi/core/sx/sx_element.hpp"+#include "casadi/core/sx/sx_tools.hpp"+#include "casadi/core/weak_ref.hpp"+#include <cmath>+#include <sstream>+#include <stdexcept>+#include "../marshal.hpp"++// ================== delete UserType (Namespace ["casadi"]) (Name "DpleSolver")===============+// classType: UserType (Namespace ["casadi"]) (Name "DpleSolver")+extern "C"+    void delete_casadi__DpleSolver(casadi::DpleSolver* obj);+void delete_casadi__DpleSolver(casadi::DpleSolver* obj){+    delete obj;+}++// ================== Constructor method: "CONSTRUCTOR" ===============+// class: "casadi::DpleSolver"+// cppName: "casadi::DpleSolver"+// cWrapperName: "casadi__DpleSolver__CONSTRUCTOR__0"+// protoArgs: "(std::string ** err_msg, std::string* x0, std::vector< casadi::Sparsity* >* x1, std::vector< casadi::Sparsity* >* x2)"+// args: "(x0_, x1_, x2_)"+// rettype: UserType (Namespace ["casadi"]) (Name "DpleSolver")+// cWrapperRetType: "casadi::DpleSolver*"+// proto: "casadi::DpleSolver* casadi__DpleSolver__CONSTRUCTOR__0(std::string ** err_msg, std::string* x0, std::vector< casadi::Sparsity* >* x1, std::vector< casadi::Sparsity* >* x2)"+// call: "casadi::DpleSolver(x0_, x1_, x2_)"+// params: [Ref (Const StdString),Ref (Const (StdVec (UserType (Namespace ["casadi"]) (Name "Sparsity")))),Ref (Const (StdVec (UserType (Namespace ["casadi"]) (Name "Sparsity"))))]+extern "C"+    casadi::DpleSolver* casadi__DpleSolver__CONSTRUCTOR__0(std::string ** err_msg, std::string* x0, std::vector< casadi::Sparsity* >* x1, std::vector< casadi::Sparsity* >* x2);+casadi::DpleSolver* casadi__DpleSolver__CONSTRUCTOR__0(std::string ** err_msg, std::string* x0, std::vector< casadi::Sparsity* >* x1, std::vector< casadi::Sparsity* >* x2){+    try {+        std::string x0_ = Marshaling<std::string,std::string*>::marshal(x0);+        std::vector< casadi::Sparsity > x1_ = Marshaling<std::vector< casadi::Sparsity >,std::vector< casadi::Sparsity* >*>::marshal(x1);+        std::vector< casadi::Sparsity > x2_ = Marshaling<std::vector< casadi::Sparsity >,std::vector< casadi::Sparsity* >*>::marshal(x2);++        casadi::DpleSolver ret = casadi::DpleSolver(x0_, x1_, x2_);+        return WrapReturn< casadi::DpleSolver*, casadi::DpleSolver >::wrapReturn( ret );+    } catch (std::exception& ex) {+         *err_msg = new std::string(ex.what());+         return 0;+    }+}+++// ================== Constructor method: "CONSTRUCTOR" ===============+// class: "casadi::DpleSolver"+// cppName: "casadi::DpleSolver"+// cWrapperName: "casadi__DpleSolver__CONSTRUCTOR__1"+// protoArgs: "(std::string ** err_msg)"+// args: "()"+// rettype: UserType (Namespace ["casadi"]) (Name "DpleSolver")+// cWrapperRetType: "casadi::DpleSolver*"+// proto: "casadi::DpleSolver* casadi__DpleSolver__CONSTRUCTOR__1(std::string ** err_msg)"+// call: "casadi::DpleSolver()"+// params: []+extern "C"+    casadi::DpleSolver* casadi__DpleSolver__CONSTRUCTOR__1(std::string ** err_msg);+casadi::DpleSolver* casadi__DpleSolver__CONSTRUCTOR__1(std::string ** err_msg){+    try {++        casadi::DpleSolver ret = casadi::DpleSolver();+        return WrapReturn< casadi::DpleSolver*, casadi::DpleSolver >::wrapReturn( ret );+    } catch (std::exception& ex) {+         *err_msg = new std::string(ex.what());+         return 0;+    }+}+++// ================== Normal method: "clone" ===============+// class: "casadi::DpleSolver"+// cppName: "casadi::DpleSolver::clone"+// cWrapperName: "casadi__DpleSolver__clone"+// protoArgs: "(std::string ** err_msg, casadi::DpleSolver* obj)"+// args: "()"+// rettype: UserType (Namespace ["casadi"]) (Name "DpleSolver")+// cWrapperRetType: "casadi::DpleSolver*"+// proto: "casadi::DpleSolver* casadi__DpleSolver__clone(std::string ** err_msg, casadi::DpleSolver* obj)"+// call: "obj->clone()"+// params: []+extern "C"+    casadi::DpleSolver* casadi__DpleSolver__clone(std::string ** err_msg, casadi::DpleSolver* obj);+casadi::DpleSolver* casadi__DpleSolver__clone(std::string ** err_msg, casadi::DpleSolver* obj){+    try {++        casadi::DpleSolver ret = obj->clone();+        return WrapReturn< casadi::DpleSolver*, casadi::DpleSolver >::wrapReturn( ret );+    } catch (std::exception& ex) {+         *err_msg = new std::string(ex.what());+         return 0;+    }+}+++// ================== Static method: "doc" ===============+// class: "casadi::DpleSolver"+// cppName: "casadi::DpleSolver::doc"+// cWrapperName: "casadi__DpleSolver__doc"+// protoArgs: "(std::string ** err_msg, std::string* x0)"+// args: "(x0_)"+// rettype: StdString+// cWrapperRetType: "std::string*"+// proto: "std::string* casadi__DpleSolver__doc(std::string ** err_msg, std::string* x0)"+// call: "casadi::DpleSolver::doc(x0_)"+// params: [Ref (Const StdString)]+extern "C"+    std::string* casadi__DpleSolver__doc(std::string ** err_msg, std::string* x0);+std::string* casadi__DpleSolver__doc(std::string ** err_msg, std::string* x0){+    try {+        std::string x0_ = Marshaling<std::string,std::string*>::marshal(x0);++        std::string ret = casadi::DpleSolver::doc(x0_);+        return WrapReturn< std::string*, std::string >::wrapReturn( ret );+    } catch (std::exception& ex) {+         *err_msg = new std::string(ex.what());+         return 0;+    }+}+++// ================== Static method: "loadPlugin" ===============+// class: "casadi::DpleSolver"+// cppName: "casadi::DpleSolver::loadPlugin"+// cWrapperName: "casadi__DpleSolver__loadPlugin"+// protoArgs: "(std::string ** err_msg, std::string* x0)"+// args: "(x0_)"+// rettype: CVoid+// cWrapperRetType: "void"+// proto: "void casadi__DpleSolver__loadPlugin(std::string ** err_msg, std::string* x0)"+// call: "casadi::DpleSolver::loadPlugin(x0_)"+// params: [Ref (Const StdString)]+extern "C"+    void casadi__DpleSolver__loadPlugin(std::string ** err_msg, std::string* x0);+void casadi__DpleSolver__loadPlugin(std::string ** err_msg, std::string* x0){+    try {+        std::string x0_ = Marshaling<std::string,std::string*>::marshal(x0);++    casadi::DpleSolver::loadPlugin(x0_);+    } catch (std::exception& ex) {+         *err_msg = new std::string(ex.what());+         return;+    }+}+++// ================== Normal method: "printStats" ===============+// class: "casadi::DpleSolver"+// cppName: "casadi::DpleSolver::printStats"+// cWrapperName: "casadi__DpleSolver__printStats"+// protoArgs: "(std::string ** err_msg, casadi::DpleSolver* obj)"+// args: "()"+// rettype: CVoid+// cWrapperRetType: "void"+// proto: "void casadi__DpleSolver__printStats(std::string ** err_msg, casadi::DpleSolver* obj)"+// call: "obj->printStats()"+// params: []+extern "C"+    void casadi__DpleSolver__printStats(std::string ** err_msg, casadi::DpleSolver* obj);+void casadi__DpleSolver__printStats(std::string ** err_msg, casadi::DpleSolver* obj){+    try {++    obj->printStats();+    } catch (std::exception& ex) {+         *err_msg = new std::string(ex.what());+         return;+    }+}+++
+ cbits/autogen/control_functions.cpp view
@@ -0,0 +1,54 @@+#include "casadi/control/dple_solver.hpp"+#include "casadi/core/casadi_calculus.hpp"+#include "casadi/core/casadi_exception.hpp"+#include "casadi/core/casadi_meta.hpp"+#include "casadi/core/casadi_options.hpp"+#include "casadi/core/casadi_types.hpp"+#include "casadi/core/function/control_simulator.hpp"+#include "casadi/core/function/custom_function.hpp"+#include "casadi/core/function/external_function.hpp"+#include "casadi/core/function/function.hpp"+#include "casadi/core/function/homotopy_nlp_solver.hpp"+#include "casadi/core/function/implicit_function.hpp"+#include "casadi/core/function/integrator.hpp"+#include "casadi/core/function/io_interface.hpp"+#include "casadi/core/function/linear_solver.hpp"+#include "casadi/core/function/lp_solver.hpp"+#include "casadi/core/function/mx_function.hpp"+#include "casadi/core/function/nlp_solver.hpp"+#include "casadi/core/function/nullspace.hpp"+#include "casadi/core/function/ocp_solver.hpp"+#include "casadi/core/function/parallelizer.hpp"+#include "casadi/core/function/qcqp_solver.hpp"+#include "casadi/core/function/qp_solver.hpp"+#include "casadi/core/function/sdp_solver.hpp"+#include "casadi/core/function/sdqp_solver.hpp"+#include "casadi/core/function/simulator.hpp"+#include "casadi/core/function/socp_solver.hpp"+#include "casadi/core/function/stabilized_qp_solver.hpp"+#include "casadi/core/function/sx_function.hpp"+#include "casadi/core/functor.hpp"+#include "casadi/core/generic_type.hpp"+#include "casadi/core/matrix/generic_expression.hpp"+#include "casadi/core/matrix/generic_matrix.hpp"+#include "casadi/core/matrix/matrix.hpp"+#include "casadi/core/matrix/matrix_tools.hpp"+#include "casadi/core/matrix/slice.hpp"+#include "casadi/core/matrix/sparsity.hpp"+#include "casadi/core/matrix/sparsity_tools.hpp"+#include "casadi/core/misc/integration_tools.hpp"+#include "casadi/core/misc/symbolic_nlp.hpp"+#include "casadi/core/mx/mx.hpp"+#include "casadi/core/mx/mx_tools.hpp"+#include "casadi/core/options_functionality.hpp"+#include "casadi/core/printable_object.hpp"+#include "casadi/core/shared_object.hpp"+#include "casadi/core/std_vector_tools.hpp"+#include "casadi/core/sx/sx_element.hpp"+#include "casadi/core/sx/sx_tools.hpp"+#include "casadi/core/weak_ref.hpp"+#include <cmath>+#include <sstream>+#include <stdexcept>+#include "../marshal.hpp"+
+ cbits/marshal.hpp view
@@ -0,0 +1,182 @@+#ifndef __MARSHAL_THEM_BINDINGS_H__+#define __MARSHAL_THEM_BINDINGS_H__++#include <iostream>++template<class T1, class T2>+class Marshaling {+public:+    static T1 marshal(T2 x){ return static_cast<T1>(x); }+};++template<class T>+class Marshaling< T, T* > {+public:+    static T marshal(T* x){ return *x; }+};++template<class T>+class Marshaling< T&, T* > {+public:+    static T& marshal(T* x){ return *x; }+};++template<class T>+class Marshaling< T const &, T* > {+public:+    static T const & marshal(T* x){ return *x; }+};++template<class T1, class T2>+class Marshaling< std::vector< T1 >, std::vector< T2 > > {+  public:+  static std::vector< T1 > marshal(const std::vector< T2 > inputs){+    std::vector< T1 > vec;+    for (unsigned int k=0; k<inputs.size(); k++){+        vec.push_back( Marshaling< T1, T2 >::marshal(inputs[k]) );+    }+    return vec;+  }+};+++template<class T1, class T2>+class Marshaling< T1, T2* > {+  public:+  static T1 marshal(T2* x){+      return Marshaling<T1, T2>::marshal( *x );+  }+};+++/* ---------------------------------------------------------- */+/* call "new" on a bunch of stuff  */+template<class T1, class T2>+class WrapReturn {+ public:+    static T1 wrapReturn(T2 x){ return x; }+};++template<class T1, class T2>+class WrapReturn< std::vector< T1 >, std::vector< T2 > > {+  public:+  static std::vector< T1 > wrapReturn(std::vector< T2 > inputs){+    std::vector< T1 > vec;+    for (unsigned int k=0; k<inputs.size(); k++){+        vec.push_back( WrapReturn< T1, T2 >::wrapReturn(inputs[k]) );+    }+    return vec;+  }+};++template<class T1, class T2>+class WrapReturn< T1*, T2 > {+  public:+  static T1* wrapReturn(T2 x){+      return new T1( WrapReturn<T1,T2>::wrapReturn(x) );+  }+};+++// some examples:++//#include <vector>+//#include <string>+//class A{};+//+//void testWrapReturn(){+//    // make a bunch of dummy inputs+//    A a = A();+//    std::vector< A > v_a = std::vector< A >();+//    std::vector< A > const v_c_a = std::vector< A >();+//    std::vector< std::vector< A > > v_v_a = std::vector< std::vector< A > >();+//    std::vector< std::vector< int > > v_v_int = std::vector< std::vector< int > >();+//    //std::vector< A >* pv_a = new std::vector< A >();+//    //std::vector< A* > v_pa = std::vector< A* >();+//    //std::vector< std::vector< A* >* >* pv_pv_pa = new std::vector< std::vector< A* >* >();+//+//    // try to use wrapReturn on the dummy inputs+//    A* o0 __attribute__((unused)) = WrapReturn< A*, A>::wrapReturn(a);+//+//+//    std::vector< A* >* o4 __attribute__((unused)) =+//        WrapReturn< std::vector< A* >*, std::vector< A > >::wrapReturn(v_a);+//+//    std::vector< A* >* o7 __attribute__((unused)) =+//        WrapReturn< std::vector< A* >*, std::vector< A > >::wrapReturn(v_c_a);+//+//+//    std::vector< std::vector< A* >* >* o5 __attribute__((unused)) =+//        WrapReturn< std::vector< std::vector< A* >* >*,+//                    std::vector< std::vector< A > >+//                    >::wrapReturn(v_v_a);+//+//+//    std::vector< std::vector< int >* >* o6 __attribute__((unused)) =+//        WrapReturn< std::vector< std::vector< int >* >*,+//                    std::vector< std::vector< int > >+//                    >::wrapReturn(v_v_int);+//    //std::vector< A > o5 = WrapReturn< std::vector< A >, std::vector< A* > >::wrapReturn(v_pa);+//    //+//    //std::vector< A > o6 = WrapReturn< std::vector< A >, std::vector< A* >* >::wrapReturn(pv_pa);+//    //std::vector< std::vector< A > > o7 =+//    //    WrapReturn< std::vector< std::vector< A > >,+//    //                std::vector< std::vector< A* >* >*+//    //                >::wrapReturn(pv_pv_pa);+//}+//+//void testMarshal(){+//    // make a bunch of dummy inputs+//    A* pa = new A();+//    std::vector< A* >* pv_pa = new std::vector< A* >();+//    std::vector< A >* pv_a = new std::vector< A >();+//    std::vector< A* > v_pa = std::vector< A* >();+//    std::vector< std::vector< A* >* >* pv_pv_pa = new std::vector< std::vector< A* >* >();+//+//    // try to use marshal on the dummy inputs+//    A o0 __attribute__((unused)) = Marshaling< A, A*>::marshal(pa);+//    A& o1 __attribute__((unused)) = Marshaling< A&, A*>::marshal(pa);+//    A const & o2 __attribute__((unused)) = Marshaling< A const &, A*>::marshal(pa);+//+//    std::vector< A > o3 = Marshaling< std::vector< A >, std::vector< A >* >::marshal(pv_a);+//    std::vector< A* > o4 = Marshaling< std::vector< A* >, std::vector< A* >* >::marshal(pv_pa);+//    std::vector< A > o5 = Marshaling< std::vector< A >, std::vector< A* > >::marshal(v_pa);+//+//    std::vector< A > o6 = Marshaling< std::vector< A >, std::vector< A* >* >::marshal(pv_pa);+//    std::vector< std::vector< A > > o7 =+//        Marshaling< std::vector< std::vector< A > >,+//                    std::vector< std::vector< A* >* >*+//                    >::marshal(pv_pv_pa);+//}+++//+//+//using namespace CasADi;+//using namespace std;+//+//// test program+//int main(){+//    string name = string("x");+//    cout << "calling ssym\n";+//    Matrix< SX >* x = CasADi__ssym_TIC(&name, 1);+//    cout << "ssym results: " << *x << "\n\n";+//+//    cout << "calling .data()\n";+//    vector< SX* >* vecsx =+//        CasADi__Matrix_CasADi__SX___data(x);+//    cout << "data results: " << *vecsx << "\n";+//    cout << "data results: " << *((*vecsx)[0]) << "\n";+//    cout << "size of data: " << vecsx->size() << "\n\n";+//+//    cout << "calling SXMatrix(vector<SX*>)\n";+//    Matrix< SX >* sxmat =+//        CasADi__Matrix_CasADi__SX___SXMatrix_TIC_TIC_TIC_TIC_TIC_TIC_TIC_TIC_TIC_TIC_TIC( vecsx );+//    cout << "calling SXMatrix.getDescription()\n";+//    cout << sxmat->getDescription() << "\n";+//    cout << "\n\n===== horray =====\n";+//    return 0;+//}+++#endif // __MARSHAL_THEM_BINDINGS_H__