packages feed

casadi-bindings-1.9.0.0: Casadi/Wrappers/Classes/ControlSimulator.hs

{-# OPTIONS_GHC -Wall #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
{-# Language ForeignFunctionInterface #-}
{-# Language FlexibleInstances #-}
{-# Language MultiParamTypeClasses #-}

module Casadi.Wrappers.Classes.ControlSimulator
       (
         ControlSimulator,
         ControlSimulatorClass(..),
         controlSimulator,
         controlSimulator',
         controlSimulator'',
         controlSimulator''',
         controlSimulator'''',
         controlSimulator_checkNode,
         controlSimulator_getMajorIndex,
         controlSimulator_getMinorT,
         controlSimulator_getMinorU,
       ) where


import Prelude hiding ( Functor )

import Data.Vector ( Vector )
import Foreign.C.Types
import Foreign.Ptr ( Ptr )
import Foreign.ForeignPtr ( newForeignPtr )
import System.IO.Unsafe ( unsafePerformIO ) -- for show instances

import Casadi.Wrappers.Classes.PrintableObject
import Casadi.Wrappers.CToolsInstances ( )
import Casadi.Wrappers.Data
import Casadi.Wrappers.Enums
import Casadi.MarshalTypes ( CppVec, StdString' ) -- StdOstream'
import Casadi.Marshal ( Marshal(..), withMarshal )
import Casadi.WrapReturn ( WrapReturn(..) )

instance Show ControlSimulator where
  show = unsafePerformIO . printableObject_getDescription
-- direct wrapper
foreign import ccall unsafe "CasADi__ControlSimulator__checkNode" c_CasADi__ControlSimulator__checkNode
  :: Ptr ControlSimulator' -> IO CInt
casADi__ControlSimulator__checkNode
  :: ControlSimulator -> IO Bool
casADi__ControlSimulator__checkNode x0 =
  withMarshal x0 $ \x0' ->
  c_CasADi__ControlSimulator__checkNode x0' >>= wrapReturn

-- classy wrapper
{-|
>Check if the node is pointing to the right type of object.
-}
controlSimulator_checkNode :: ControlSimulatorClass a => a -> IO Bool
controlSimulator_checkNode x = casADi__ControlSimulator__checkNode (castControlSimulator x)


-- direct wrapper
foreign import ccall unsafe "CasADi__ControlSimulator__getMinorT" c_CasADi__ControlSimulator__getMinorT
  :: Ptr ControlSimulator' -> IO (Ptr (CppVec CDouble))
casADi__ControlSimulator__getMinorT
  :: ControlSimulator -> IO (Vector Double)
casADi__ControlSimulator__getMinorT x0 =
  withMarshal x0 $ \x0' ->
  c_CasADi__ControlSimulator__getMinorT x0' >>= wrapReturn

-- classy wrapper
{-|
>Get the (minor) time grid The length is (ns-1)*nf + 1
-}
controlSimulator_getMinorT :: ControlSimulatorClass a => a -> IO (Vector Double)
controlSimulator_getMinorT x = casADi__ControlSimulator__getMinorT (castControlSimulator x)


-- direct wrapper
foreign import ccall unsafe "CasADi__ControlSimulator__getMinorU" c_CasADi__ControlSimulator__getMinorU
  :: Ptr ControlSimulator' -> IO (Ptr DMatrix')
casADi__ControlSimulator__getMinorU
  :: ControlSimulator -> IO DMatrix
casADi__ControlSimulator__getMinorU x0 =
  withMarshal x0 $ \x0' ->
  c_CasADi__ControlSimulator__getMinorU x0' >>= wrapReturn

-- classy wrapper
{-|
>Get the controls, sampled on the minor timescale. Number of rows is
>(ns-1)*nf.
-}
controlSimulator_getMinorU :: ControlSimulatorClass a => a -> IO DMatrix
controlSimulator_getMinorU x = casADi__ControlSimulator__getMinorU (castControlSimulator x)


-- direct wrapper
foreign import ccall unsafe "CasADi__ControlSimulator__getMajorIndex" c_CasADi__ControlSimulator__getMajorIndex
  :: Ptr ControlSimulator' -> IO (Ptr (CppVec CInt))
casADi__ControlSimulator__getMajorIndex
  :: ControlSimulator -> IO (Vector Int)
casADi__ControlSimulator__getMajorIndex x0 =
  withMarshal x0 $ \x0' ->
  c_CasADi__ControlSimulator__getMajorIndex x0' >>= wrapReturn

-- classy wrapper
{-|
>Get the index i such that gridminor[i] == gridmajor.
-}
controlSimulator_getMajorIndex :: ControlSimulatorClass a => a -> IO (Vector Int)
controlSimulator_getMajorIndex x = casADi__ControlSimulator__getMajorIndex (castControlSimulator x)


-- direct wrapper
foreign import ccall unsafe "CasADi__ControlSimulator__ControlSimulator" c_CasADi__ControlSimulator__ControlSimulator
  :: IO (Ptr ControlSimulator')
casADi__ControlSimulator__ControlSimulator
  :: IO ControlSimulator
casADi__ControlSimulator__ControlSimulator  =
  c_CasADi__ControlSimulator__ControlSimulator  >>= wrapReturn

-- classy wrapper
{-|
>>  CasADi::ControlSimulator::ControlSimulator()
>------------------------------------------------------------------------
>
>Default constructor.
>
>>  CasADi::ControlSimulator::ControlSimulator(const Function &dae, const Function &output_fcn, const std::vector< double > &grid)
>------------------------------------------------------------------------
>
>Creates a piecewise simulator.
>
>Parameters:
>-----------
>
>ffcn:  Continuous time dynamics, an CasADi::Function with the folowing
>mapping:
>
>>Input scheme: CasADi::ControlledDAEInput (CONTROL_DAE_NUM_IN = 10) [controldaeIn]
>+------------------------+------------------------+------------------------+
>|       Full name        |         Short          |      Description       |
>+========================+========================+========================+
>| CONTROL_DAE_T          | t                      | Global physical time.  |
>|                        |                        | (1-by-1) .             |
>+------------------------+------------------------+------------------------+
>| CONTROL_DAE_X          | x                      | State vector           |
>|                        |                        | (dimension nx-by-1).   |
>|                        |                        | Should have same       |
>|                        |                        | amount of non-zeros as |
>|                        |                        | DAEOutput:DAE_RES .    |
>+------------------------+------------------------+------------------------+
>| CONTROL_DAE_Z          | z                      | Algebraic state vector |
>|                        |                        | (dimension np-by-1). . |
>+------------------------+------------------------+------------------------+
>| CONTROL_DAE_P          | p                      | Parameter vector       |
>|                        |                        | (dimension np-by-1). . |
>+------------------------+------------------------+------------------------+
>| CONTROL_DAE_U          | u                      | Control vector         |
>|                        |                        | (dimension nu-by-1). . |
>+------------------------+------------------------+------------------------+
>| CONTROL_DAE_U_INTERP   | u_interp               | Control vector,        |
>|                        |                        | linearly interpolated  |
>|                        |                        | (dimension nu-by-1). . |
>+------------------------+------------------------+------------------------+
>| CONTROL_DAE_X_MAJOR    | x_major                | State vector           |
>|                        |                        | (dimension nx-by-1) at |
>|                        |                        | the last major time-   |
>|                        |                        | step .                 |
>+------------------------+------------------------+------------------------+
>| CONTROL_DAE_T0         | t0                     | Time at start of       |
>|                        |                        | control interval       |
>|                        |                        | (1-by-1) .             |
>+------------------------+------------------------+------------------------+
>| CONTROL_DAE_TF         | tf                     | Time at end of control |
>|                        |                        | interval (1-by-1) .    |
>+------------------------+------------------------+------------------------+
>
>>Output scheme: CasADi::DAEOutput (DAE_NUM_OUT = 4) [daeOut]
>+-----------+-------+--------------------------------------------+
>| Full name | Short |                Description                 |
>+===========+=======+============================================+
>| DAE_ODE   | ode   | Right hand side of the implicit ODE .      |
>+-----------+-------+--------------------------------------------+
>| DAE_ALG   | alg   | Right hand side of algebraic equations .   |
>+-----------+-------+--------------------------------------------+
>| DAE_QUAD  | quad  | Right hand side of quadratures equations . |
>+-----------+-------+--------------------------------------------+
>
>Parameters:
>-----------
>
>output_fcn:  output function which maps ControlledDAEInput or DAEInput to n
>outputs.
>
>>Input scheme: CasADi::DAEInput (DAE_NUM_IN = 5) [daeIn]
>+-----------+-------+----------------------------+
>| Full name | Short |        Description         |
>+===========+=======+============================+
>| DAE_X     | x     | Differential state .       |
>+-----------+-------+----------------------------+
>| DAE_Z     | z     | Algebraic state .          |
>+-----------+-------+----------------------------+
>| DAE_P     | p     | Parameter .                |
>+-----------+-------+----------------------------+
>| DAE_T     | t     | Explicit time dependence . |
>+-----------+-------+----------------------------+
>
>>Input scheme: CasADi::ControlledDAEInput (CONTROL_DAE_NUM_IN = 10) [controldaeIn]
>+------------------------+------------------------+------------------------+
>|       Full name        |         Short          |      Description       |
>+========================+========================+========================+
>| CONTROL_DAE_T          | t                      | Global physical time.  |
>|                        |                        | (1-by-1) .             |
>+------------------------+------------------------+------------------------+
>| CONTROL_DAE_X          | x                      | State vector           |
>|                        |                        | (dimension nx-by-1).   |
>|                        |                        | Should have same       |
>|                        |                        | amount of non-zeros as |
>|                        |                        | DAEOutput:DAE_RES .    |
>+------------------------+------------------------+------------------------+
>| CONTROL_DAE_Z          | z                      | Algebraic state vector |
>|                        |                        | (dimension np-by-1). . |
>+------------------------+------------------------+------------------------+
>| CONTROL_DAE_P          | p                      | Parameter vector       |
>|                        |                        | (dimension np-by-1). . |
>+------------------------+------------------------+------------------------+
>| CONTROL_DAE_U          | u                      | Control vector         |
>|                        |                        | (dimension nu-by-1). . |
>+------------------------+------------------------+------------------------+
>| CONTROL_DAE_U_INTERP   | u_interp               | Control vector,        |
>|                        |                        | linearly interpolated  |
>|                        |                        | (dimension nu-by-1). . |
>+------------------------+------------------------+------------------------+
>| CONTROL_DAE_X_MAJOR    | x_major                | State vector           |
>|                        |                        | (dimension nx-by-1) at |
>|                        |                        | the last major time-   |
>|                        |                        | step .                 |
>+------------------------+------------------------+------------------------+
>| CONTROL_DAE_T0         | t0                     | Time at start of       |
>|                        |                        | control interval       |
>|                        |                        | (1-by-1) .             |
>+------------------------+------------------------+------------------------+
>| CONTROL_DAE_TF         | tf                     | Time at end of control |
>|                        |                        | interval (1-by-1) .    |
>+------------------------+------------------------+------------------------+
>
>Parameters:
>-----------
>
>grid:  the major time grid
>
>>  CasADi::ControlSimulator::ControlSimulator(const Function &dae, const std::vector< double > &grid)
>------------------------------------------------------------------------
>
>Output function equal to the state.
-}
controlSimulator :: IO ControlSimulator
controlSimulator = casADi__ControlSimulator__ControlSimulator


-- direct wrapper
foreign import ccall unsafe "CasADi__ControlSimulator__ControlSimulator_TIC" c_CasADi__ControlSimulator__ControlSimulator_TIC
  :: Ptr Function' -> Ptr Function' -> Ptr (CppVec CDouble) -> IO (Ptr ControlSimulator')
casADi__ControlSimulator__ControlSimulator'
  :: Function -> Function -> Vector Double -> IO ControlSimulator
casADi__ControlSimulator__ControlSimulator' x0 x1 x2 =
  withMarshal x0 $ \x0' ->
  withMarshal x1 $ \x1' ->
  withMarshal x2 $ \x2' ->
  c_CasADi__ControlSimulator__ControlSimulator_TIC x0' x1' x2' >>= wrapReturn

-- classy wrapper
controlSimulator' :: Function -> Function -> Vector Double -> IO ControlSimulator
controlSimulator' = casADi__ControlSimulator__ControlSimulator'


-- direct wrapper
foreign import ccall unsafe "CasADi__ControlSimulator__ControlSimulator_TIC_TIC" c_CasADi__ControlSimulator__ControlSimulator_TIC_TIC
  :: Ptr Function' -> Ptr Function' -> Ptr DMatrix' -> IO (Ptr ControlSimulator')
casADi__ControlSimulator__ControlSimulator''
  :: Function -> Function -> DMatrix -> IO ControlSimulator
casADi__ControlSimulator__ControlSimulator'' x0 x1 x2 =
  withMarshal x0 $ \x0' ->
  withMarshal x1 $ \x1' ->
  withMarshal x2 $ \x2' ->
  c_CasADi__ControlSimulator__ControlSimulator_TIC_TIC x0' x1' x2' >>= wrapReturn

-- classy wrapper
controlSimulator'' :: Function -> Function -> DMatrix -> IO ControlSimulator
controlSimulator'' = casADi__ControlSimulator__ControlSimulator''


-- direct wrapper
foreign import ccall unsafe "CasADi__ControlSimulator__ControlSimulator_TIC_TIC_TIC" c_CasADi__ControlSimulator__ControlSimulator_TIC_TIC_TIC
  :: Ptr Function' -> Ptr (CppVec CDouble) -> IO (Ptr ControlSimulator')
casADi__ControlSimulator__ControlSimulator'''
  :: Function -> Vector Double -> IO ControlSimulator
casADi__ControlSimulator__ControlSimulator''' x0 x1 =
  withMarshal x0 $ \x0' ->
  withMarshal x1 $ \x1' ->
  c_CasADi__ControlSimulator__ControlSimulator_TIC_TIC_TIC x0' x1' >>= wrapReturn

-- classy wrapper
controlSimulator''' :: Function -> Vector Double -> IO ControlSimulator
controlSimulator''' = casADi__ControlSimulator__ControlSimulator'''


-- direct wrapper
foreign import ccall unsafe "CasADi__ControlSimulator__ControlSimulator_TIC_TIC_TIC_TIC" c_CasADi__ControlSimulator__ControlSimulator_TIC_TIC_TIC_TIC
  :: Ptr Function' -> Ptr DMatrix' -> IO (Ptr ControlSimulator')
casADi__ControlSimulator__ControlSimulator''''
  :: Function -> DMatrix -> IO ControlSimulator
casADi__ControlSimulator__ControlSimulator'''' x0 x1 =
  withMarshal x0 $ \x0' ->
  withMarshal x1 $ \x1' ->
  c_CasADi__ControlSimulator__ControlSimulator_TIC_TIC_TIC_TIC x0' x1' >>= wrapReturn

-- classy wrapper
controlSimulator'''' :: Function -> DMatrix -> IO ControlSimulator
controlSimulator'''' = casADi__ControlSimulator__ControlSimulator''''