packages feed

casadi-bindings-snopt-interface (empty) → 1.9.0.2

raw patch · 9 files changed

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

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

Files

+ Casadi/SnoptInterface/Classes/SnoptSolver.hs view
@@ -0,0 +1,117 @@+{-# OPTIONS_GHC -Wall #-}+{-# OPTIONS_GHC -fno-warn-unused-imports #-}+{-# OPTIONS_GHC -fno-warn-orphans #-}+{-# Language ForeignFunctionInterface #-}+{-# Language FlexibleInstances #-}+{-# Language MultiParamTypeClasses #-}++module Casadi.SnoptInterface.Classes.SnoptSolver+       (+         SnoptSolver,+         SnoptSolverClass(..),+         snoptSolver__0,+         snoptSolver__1,+         snoptSolver_creator,+         snoptSolver_setOptionsFromFile,+       ) 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.SnoptInterface.Data+import Casadi.SnoptInterface.Enums+import Casadi.Core.Data++-- direct wrapper+foreign import ccall unsafe "casadi__SnoptSolver__CONSTRUCTOR__0" c_casadi__SnoptSolver__CONSTRUCTOR__0+  :: Ptr (Ptr StdString) -> Ptr Function' -> IO (Ptr SnoptSolver')+casadi__SnoptSolver__CONSTRUCTOR__0+  :: Function -> IO SnoptSolver+casadi__SnoptSolver__CONSTRUCTOR__0 x0 =+  withMarshal x0 $ \x0' ->+  do+    errStrPtrP <- new nullPtr+    ret <- c_casadi__SnoptSolver__CONSTRUCTOR__0 errStrPtrP x0'+    errStrPtr <- peek errStrPtrP+    free errStrPtrP+    if errStrPtr == nullPtr then wrapReturn ret else wrapReturn errStrPtr >>= (error . formatException)+++-- classy wrapper+snoptSolver__0 :: Function -> IO SnoptSolver+snoptSolver__0 = casadi__SnoptSolver__CONSTRUCTOR__0+++-- direct wrapper+foreign import ccall unsafe "casadi__SnoptSolver__CONSTRUCTOR__1" c_casadi__SnoptSolver__CONSTRUCTOR__1+  :: Ptr (Ptr StdString) -> IO (Ptr SnoptSolver')+casadi__SnoptSolver__CONSTRUCTOR__1+  :: IO SnoptSolver+casadi__SnoptSolver__CONSTRUCTOR__1  =++  do+    errStrPtrP <- new nullPtr+    ret <- c_casadi__SnoptSolver__CONSTRUCTOR__1 errStrPtrP +    errStrPtr <- peek errStrPtrP+    free errStrPtrP+    if errStrPtr == nullPtr then wrapReturn ret else wrapReturn errStrPtr >>= (error . formatException)+++-- classy wrapper+snoptSolver__1 :: IO SnoptSolver+snoptSolver__1 = casadi__SnoptSolver__CONSTRUCTOR__1+++-- direct wrapper+foreign import ccall unsafe "casadi__SnoptSolver__creator" c_casadi__SnoptSolver__creator+  :: Ptr (Ptr StdString) -> Ptr Function' -> IO (Ptr NLPSolver')+casadi__SnoptSolver__creator+  :: Function -> IO NLPSolver+casadi__SnoptSolver__creator x0 =+  withMarshal x0 $ \x0' ->+  do+    errStrPtrP <- new nullPtr+    ret <- c_casadi__SnoptSolver__creator errStrPtrP x0'+    errStrPtr <- peek errStrPtrP+    free errStrPtrP+    if errStrPtr == nullPtr then wrapReturn ret else wrapReturn errStrPtr >>= (error . formatException)+++-- classy wrapper+snoptSolver_creator :: Function -> IO NLPSolver+snoptSolver_creator = casadi__SnoptSolver__creator+++-- direct wrapper+foreign import ccall unsafe "casadi__SnoptSolver__setOptionsFromFile" c_casadi__SnoptSolver__setOptionsFromFile+  :: Ptr (Ptr StdString) -> Ptr SnoptSolver' -> Ptr StdString -> IO ()+casadi__SnoptSolver__setOptionsFromFile+  :: SnoptSolver -> String -> IO ()+casadi__SnoptSolver__setOptionsFromFile x0 x1 =+  withMarshal x0 $ \x0' ->+  withMarshal x1 $ \x1' ->+  do+    errStrPtrP <- new nullPtr+    ret <- c_casadi__SnoptSolver__setOptionsFromFile errStrPtrP x0' x1'+    errStrPtr <- peek errStrPtrP+    free errStrPtrP+    if errStrPtr == nullPtr then wrapReturn ret else wrapReturn errStrPtr >>= (error . formatException)+++-- classy wrapper+snoptSolver_setOptionsFromFile :: SnoptSolverClass a => a -> String -> IO ()+snoptSolver_setOptionsFromFile x = casadi__SnoptSolver__setOptionsFromFile (castSnoptSolver x)+
+ Casadi/SnoptInterface/Data.hs view
@@ -0,0 +1,356 @@+{-# OPTIONS_GHC -Wall #-}+{-# Language FlexibleInstances #-}+{-# Language MultiParamTypeClasses #-}++module Casadi.SnoptInterface.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 SnoptSolver'+-- data decl+{-|+>interface to SNOPT NLP solver+>+>Solves the following parametric nonlinear program (NLP):min          F(x, p)+>x  subject to             LBX <=   x    <= UBX LBG <= G(x, p) <= UBG+>p  == P      nx: number of decision variables     ng: number of constraints+>np: number of parameters+>+>>Input scheme: casadi::NLPSolverInput (NLP_SOLVER_NUM_IN = 9) [nlpSolverIn]+>+------------------------+------------------------+------------------------++>|       Full name        |         Short          |      Description       |+>+========================+========================+========================++>| NLP_SOLVER_X0          | x0                     | Decision variables,    |+>|                        |                        | initial guess (nx x 1) |+>|                        |                        | .                      |+>+------------------------+------------------------+------------------------++>| NLP_SOLVER_P           | p                      | Value of fixed         |+>|                        |                        | parameters (np x 1) .  |+>+------------------------+------------------------+------------------------++>| NLP_SOLVER_LBX         | lbx                    | Decision variables     |+>|                        |                        | lower bound (nx x 1),  |+>|                        |                        | default -inf .         |+>+------------------------+------------------------+------------------------++>| NLP_SOLVER_UBX         | ubx                    | Decision variables     |+>|                        |                        | upper bound (nx x 1),  |+>|                        |                        | default +inf .         |+>+------------------------+------------------------+------------------------++>| NLP_SOLVER_LBG         | lbg                    | Constraints lower      |+>|                        |                        | bound (ng x 1),        |+>|                        |                        | default -inf .         |+>+------------------------+------------------------+------------------------++>| NLP_SOLVER_UBG         | ubg                    | Constraints upper      |+>|                        |                        | bound (ng x 1),        |+>|                        |                        | default +inf .         |+>+------------------------+------------------------+------------------------++>| NLP_SOLVER_LAM_X0      | lam_x0                 | Lagrange multipliers   |+>|                        |                        | for bounds on X,       |+>|                        |                        | initial guess (nx x 1) |+>|                        |                        | .                      |+>+------------------------+------------------------+------------------------++>| NLP_SOLVER_LAM_G0      | lam_g0                 | Lagrange multipliers   |+>|                        |                        | for bounds on G,       |+>|                        |                        | initial guess (ng x 1) |+>|                        |                        | .                      |+>+------------------------+------------------------+------------------------++>+>>Output scheme: casadi::NLPSolverOutput (NLP_SOLVER_NUM_OUT = 7) [nlpSolverOut]+>+------------------------+------------------------+------------------------++>|       Full name        |         Short          |      Description       |+>+========================+========================+========================++>| NLP_SOLVER_X           | x                      | Decision variables at  |+>|                        |                        | the optimal solution   |+>|                        |                        | (nx x 1) .             |+>+------------------------+------------------------+------------------------++>| NLP_SOLVER_F           | f                      | Cost function value at |+>|                        |                        | the optimal solution   |+>|                        |                        | (1 x 1) .              |+>+------------------------+------------------------+------------------------++>| NLP_SOLVER_G           | g                      | Constraints function   |+>|                        |                        | at the optimal         |+>|                        |                        | solution (ng x 1) .    |+>+------------------------+------------------------+------------------------++>| NLP_SOLVER_LAM_X       | lam_x                  | Lagrange multipliers   |+>|                        |                        | for bounds on X at the |+>|                        |                        | solution (nx x 1) .    |+>+------------------------+------------------------+------------------------++>| NLP_SOLVER_LAM_G       | lam_g                  | Lagrange multipliers   |+>|                        |                        | for bounds on G at the |+>|                        |                        | solution (ng x 1) .    |+>+------------------------+------------------------+------------------------++>| NLP_SOLVER_LAM_P       | lam_p                  | Lagrange multipliers   |+>|                        |                        | for bounds on P at the |+>|                        |                        | solution (np x 1) .    |+>+------------------------+------------------------+------------------------++>+>>List of available options+>+--------------+--------------+--------------+--------------+--------------++>|      Id      |     Type     |   Default    | Description  |   Used in    |+>+==============+==============+==============+==============+==============++>| _iprint      | OT_INTEGER   | 0            |              | casadi::Snop |+>|              |              |              |              | tInternal    |+>+--------------+--------------+--------------+--------------+--------------++>| _isumm       | OT_INTEGER   | 6            |              | casadi::Snop |+>|              |              |              |              | tInternal    |+>+--------------+--------------+--------------+--------------+--------------++>| _start       | OT_STRING    | "Cold"       | (Cold|Warm)  | casadi::Snop |+>|              |              |              |              | tInternal    |+>+--------------+--------------+--------------+--------------+--------------++>| 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) |              |+>+--------------+--------------+--------------+--------------+--------------++>| 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 .     |              |+>+--------------+--------------+--------------+--------------+--------------++>| detect_linea | OT_BOOLEAN   | true         | Make an      | casadi::Snop |+>| r            |              |              | effort to    | tInternal    |+>|              |              |              | treat linear |              |+>|              |              |              | constraints  |              |+>|              |              |              | and linear   |              |+>|              |              |              | variables    |              |+>|              |              |              | specially.   |              |+>+--------------+--------------+--------------+--------------+--------------++>| expand       | OT_BOOLEAN   | false        | Expand the   | casadi::NLPS |+>|              |              |              | NLP function | olverInterna |+>|              |              |              | in terms of  | l            |+>|              |              |              | scalar       |              |+>|              |              |              | operations,  |              |+>|              |              |              | i.e. MX->SX  |              |+>+--------------+--------------+--------------+--------------+--------------++>| gather_stats | OT_BOOLEAN   | false        | Flag to      | casadi::Func |+>|              |              |              | indicate     | tionInternal |+>|              |              |              | whether      |              |+>|              |              |              | statistics   |              |+>|              |              |              | must be      |              |+>|              |              |              | gathered     |              |+>+--------------+--------------+--------------+--------------+--------------++>| grad_f       | OT_FUNCTION  | GenericType( | Function for | casadi::NLPS |+>|              |              | )            | calculating  | olverInterna |+>|              |              |              | the gradient | l            |+>|              |              |              | of the       |              |+>|              |              |              | objective    |              |+>|              |              |              | (column, aut |              |+>|              |              |              | ogenerated   |              |+>|              |              |              | by default)  |              |+>+--------------+--------------+--------------+--------------+--------------++>| grad_lag     | OT_FUNCTION  | GenericType( | Function for | casadi::NLPS |+>|              |              | )            | calculating  | olverInterna |+>|              |              |              | the gradient | l            |+>|              |              |              | of the       |              |+>|              |              |              | Lagrangian ( |              |+>|              |              |              | autogenerate |              |+>|              |              |              | d by         |              |+>|              |              |              | default)     |              |+>+--------------+--------------+--------------+--------------+--------------++>| hess_lag     | OT_FUNCTION  | GenericType( | Function for | casadi::NLPS |+>|              |              | )            | calculating  | olverInterna |+>|              |              |              | the Hessian  | l            |+>|              |              |              | of the       |              |+>|              |              |              | Lagrangian ( |              |+>|              |              |              | autogenerate |              |+>|              |              |              | d by         |              |+>|              |              |              | default)     |              |+>+--------------+--------------+--------------+--------------+--------------++>| ignore_check | OT_BOOLEAN   | false        | If set to    | casadi::NLPS |+>| _vec         |              |              | true, the    | olverInterna |+>|              |              |              | input shape  | l            |+>|              |              |              | of F will    |              |+>|              |              |              | not be       |              |+>|              |              |              | checked.     |              |+>+--------------+--------------+--------------+--------------+--------------++>| inputs_check | OT_BOOLEAN   | true         | Throw        | casadi::Func |+>|              |              |              | exceptions   | tionInternal |+>|              |              |              | when the     |              |+>|              |              |              | numerical    |              |+>|              |              |              | values of    |              |+>|              |              |              | the inputs   |              |+>|              |              |              | don't make   |              |+>|              |              |              | sense        |              |+>+--------------+--------------+--------------+--------------+--------------++>| iteration_ca | OT_CALLBACK  | GenericType( | A function   | casadi::NLPS |+>| llback       |              | )            | that will be | olverInterna |+>|              |              |              | called at    | l            |+>|              |              |              | each         |              |+>|              |              |              | iteration    |              |+>|              |              |              | with the     |              |+>|              |              |              | solver as    |              |+>|              |              |              | input. Check |              |+>|              |              |              | documentatio |              |+>|              |              |              | n of         |              |+>|              |              |              | Callback .   |              |+>+--------------+--------------+--------------+--------------+--------------++>| iteration_ca | OT_BOOLEAN   | false        | If set to    | casadi::NLPS |+>| llback_ignor |              |              | true, errors | olverInterna |+>| e_errors     |              |              | thrown by it | l            |+>|              |              |              | eration_call |              |+>|              |              |              | back will be |              |+>|              |              |              | ignored.     |              |+>+--------------+--------------+--------------+--------------+--------------++>| iteration_ca | OT_INTEGER   | 1            | Only call    | casadi::NLPS |+>| llback_step  |              |              | the callback | olverInterna |+>|              |              |              | function     | l            |+>|              |              |              | every few    |              |+>|              |              |              | iterations.  |              |+>+--------------+--------------+--------------+--------------+--------------++>| jac_f        | OT_FUNCTION  | GenericType( | Function for | casadi::NLPS |+>|              |              | )            | calculating  | olverInterna |+>|              |              |              | the jacobian | l            |+>|              |              |              | of the       |              |+>|              |              |              | objective    |              |+>|              |              |              | (sparse row, |              |+>|              |              |              | autogenerate |              |+>|              |              |              | d by         |              |+>|              |              |              | default)     |              |+>+--------------+--------------+--------------+--------------+--------------++>| jac_g        | OT_FUNCTION  | GenericType( | Function for | casadi::NLPS |+>|              |              | )            | calculating  | olverInterna |+>|              |              |              | the Jacobian | l            |+>|              |              |              | of the       |              |+>|              |              |              | constraints  |              |+>|              |              |              | (autogenerat |              |+>|              |              |              | ed by        |              |+>|              |              |              | default)     |              |+>+--------------+--------------+--------------+--------------+--------------++>| monitor      | OT_STRINGVEC | GenericType( | Monitors to  | casadi::Func |+>|              | TOR          | )            | be activated | tionInternal |+>|              |              |              | (inputs|outp | casadi::Snop |+>|              |              |              | uts)  (eval_ | tInternal    |+>|              |              |              | nlp|setup_nl |              |+>|              |              |              | p)           |              |+>+--------------+--------------+--------------+--------------+--------------++>| name         | OT_STRING    | "unnamed_sha | name of the  | casadi::Opti |+>|              |              | red_object"  | object       | onsFunctiona |+>|              |              |              |              | lityNode     |+>+--------------+--------------+--------------+--------------+--------------++>| print_time   | OT_BOOLEAN   | true         | print        | casadi::Snop |+>|              |              |              | information  | tInternal    |+>|              |              |              | about        |              |+>|              |              |              | execution    |              |+>|              |              |              | time         |              |+>+--------------+--------------+--------------+--------------+--------------++>| 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    |              |+>+--------------+--------------+--------------+--------------+--------------++>| warn_initial | OT_BOOLEAN   | false        | Warn if the  | casadi::NLPS |+>| _bounds      |              |              | initial      | olverInterna |+>|              |              |              | guess does   | l            |+>|              |              |              | not satisfy  |              |+>|              |              |              | LBX and UBX  |              |+>+--------------+--------------+--------------+--------------+--------------++>+>>List of available monitors+>+-----------+--------------------------++>|    Id     |         Used in          |+>+===========+==========================++>| eval_nlp  | casadi::SnoptInternal    |+>+-----------+--------------------------++>| inputs    | casadi::FunctionInternal |+>+-----------+--------------------------++>| outputs   | casadi::FunctionInternal |+>+-----------+--------------------------++>| setup_nlp | casadi::SnoptInternal    |+>+-----------+--------------------------++>+>>List of available stats+>+----------------+-----------------------++>|       Id       |        Used in        |+>+================+=======================++>| n_callback_fun | casadi::SnoptInternal |+>+----------------+-----------------------++>| n_eval_grad_f  | casadi::SnoptInternal |+>+----------------+-----------------------++>| n_eval_jac_g   | casadi::SnoptInternal |+>+----------------+-----------------------++>| return_status  | casadi::SnoptInternal |+>+----------------+-----------------------++>| t_callback_fun | casadi::SnoptInternal |+>+----------------+-----------------------++>| t_eval_grad_f  | casadi::SnoptInternal |+>+----------------+-----------------------++>| t_eval_jac_g   | casadi::SnoptInternal |+>+----------------+-----------------------++>| t_mainloop     | casadi::SnoptInternal |+>+----------------+-----------------------++>+>Diagrams+>+>C++ includes: snopt_solver.hpp +-}+newtype SnoptSolver = SnoptSolver (ForeignPtr SnoptSolver')+-- typeclass decl+class SnoptSolverClass a where+  castSnoptSolver :: a -> SnoptSolver+instance SnoptSolverClass SnoptSolver where+  castSnoptSolver = id++-- baseclass instances+instance NLPSolverClass SnoptSolver where+  castNLPSolver (SnoptSolver x) = NLPSolver (castForeignPtr x)+++-- helper instances+instance Marshal SnoptSolver (Ptr SnoptSolver') where+  marshal (SnoptSolver x) = return (unsafeForeignPtrToPtr x)+  marshalFree (SnoptSolver x) _ = touchForeignPtr x+foreign import ccall unsafe "&delete_casadi__SnoptSolver" +  c_delete_casadi__SnoptSolver :: FunPtr (Ptr SnoptSolver' -> IO ())+instance WrapReturn (Ptr SnoptSolver') SnoptSolver where+  wrapReturn = (fmap SnoptSolver) . (newForeignPtr c_delete_casadi__SnoptSolver)++
+ Casadi/SnoptInterface/Enums.hs view
@@ -0,0 +1,13 @@+{-# OPTIONS_GHC -Wall #-}+{-# OPTIONS_GHC -fno-warn-unused-imports #-}+{-# LANGUAGE MultiParamTypeClasses #-}++module Casadi.SnoptInterface.Enums+       (+       ) where+++import Foreign.C.Types ( CInt(..) )+import Casadi.Internal.Marshal ( Marshal(..) )+import Casadi.Internal.WrapReturn ( WrapReturn(..) )+
+ 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-snopt-interface.cabal view
@@ -0,0 +1,38 @@+name:                casadi-bindings-snopt-interface+version:             1.9.0.2+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-snopt_interface+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++  default-language:    Haskell2010+++  extra-libraries:  stdc++++  pkgconfig-depends: casadi_snopt_interface++  ghc-prof-options: -prof -fprof-auto -fprof-cafs -rtsopts+  ghc-options: +  cc-options: -Wall -Wno-delete-non-virtual-dtor++  C-sources:        cbits/autogen/snopt_interface_classes.cpp+                    cbits/autogen/snopt_interface_functions.cpp++  exposed-modules:  Casadi.SnoptInterface.Data+                    Casadi.SnoptInterface.Enums+                    Casadi.SnoptInterface.Classes.SnoptSolver
+ cbits/autogen/snopt_interface_classes.cpp view
@@ -0,0 +1,164 @@+#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/function/symbolic_qr.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/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 "casadi/interfaces/snopt/snopt_solver.hpp"+#include <cmath>+#include <sstream>+#include <stdexcept>+#include "../marshal.hpp"++// ================== delete UserType (Namespace ["casadi"]) (Name "SnoptSolver")===============+// classType: UserType (Namespace ["casadi"]) (Name "SnoptSolver")+extern "C"+    void delete_casadi__SnoptSolver(casadi::SnoptSolver* obj);+void delete_casadi__SnoptSolver(casadi::SnoptSolver* obj){+    delete obj;+}++// ================== Constructor method: "CONSTRUCTOR" ===============+// class: "casadi::SnoptSolver"+// cppName: "casadi::SnoptSolver"+// cWrapperName: "casadi__SnoptSolver__CONSTRUCTOR__0"+// protoArgs: "(std::string ** err_msg, casadi::Function* x0)"+// args: "(x0_)"+// rettype: UserType (Namespace ["casadi"]) (Name "SnoptSolver")+// cWrapperRetType: "casadi::SnoptSolver*"+// proto: "casadi::SnoptSolver* casadi__SnoptSolver__CONSTRUCTOR__0(std::string ** err_msg, casadi::Function* x0)"+// call: "casadi::SnoptSolver(x0_)"+// params: [Ref (Const (UserType (Namespace ["casadi"]) (Name "Function")))]+extern "C"+    casadi::SnoptSolver* casadi__SnoptSolver__CONSTRUCTOR__0(std::string ** err_msg, casadi::Function* x0);+casadi::SnoptSolver* casadi__SnoptSolver__CONSTRUCTOR__0(std::string ** err_msg, casadi::Function* x0){+    try {+        casadi::Function x0_ = Marshaling<casadi::Function,casadi::Function*>::marshal(x0);++        casadi::SnoptSolver ret = casadi::SnoptSolver(x0_);+        return WrapReturn< casadi::SnoptSolver*, casadi::SnoptSolver >::wrapReturn( ret );+    } catch (std::exception& ex) {+         *err_msg = new std::string(ex.what());+         return 0;+    }+}+++// ================== Constructor method: "CONSTRUCTOR" ===============+// class: "casadi::SnoptSolver"+// cppName: "casadi::SnoptSolver"+// cWrapperName: "casadi__SnoptSolver__CONSTRUCTOR__1"+// protoArgs: "(std::string ** err_msg)"+// args: "()"+// rettype: UserType (Namespace ["casadi"]) (Name "SnoptSolver")+// cWrapperRetType: "casadi::SnoptSolver*"+// proto: "casadi::SnoptSolver* casadi__SnoptSolver__CONSTRUCTOR__1(std::string ** err_msg)"+// call: "casadi::SnoptSolver()"+// params: []+extern "C"+    casadi::SnoptSolver* casadi__SnoptSolver__CONSTRUCTOR__1(std::string ** err_msg);+casadi::SnoptSolver* casadi__SnoptSolver__CONSTRUCTOR__1(std::string ** err_msg){+    try {++        casadi::SnoptSolver ret = casadi::SnoptSolver();+        return WrapReturn< casadi::SnoptSolver*, casadi::SnoptSolver >::wrapReturn( ret );+    } catch (std::exception& ex) {+         *err_msg = new std::string(ex.what());+         return 0;+    }+}+++// ================== Static method: "creator" ===============+// class: "casadi::SnoptSolver"+// cppName: "casadi::SnoptSolver::creator"+// cWrapperName: "casadi__SnoptSolver__creator"+// protoArgs: "(std::string ** err_msg, casadi::Function* x0)"+// args: "(x0_)"+// rettype: UserType (Namespace ["casadi"]) (Name "NLPSolver")+// cWrapperRetType: "casadi::NLPSolver*"+// proto: "casadi::NLPSolver* casadi__SnoptSolver__creator(std::string ** err_msg, casadi::Function* x0)"+// call: "casadi::SnoptSolver::creator(x0_)"+// params: [Ref (Const (UserType (Namespace ["casadi"]) (Name "Function")))]+extern "C"+    casadi::NLPSolver* casadi__SnoptSolver__creator(std::string ** err_msg, casadi::Function* x0);+casadi::NLPSolver* casadi__SnoptSolver__creator(std::string ** err_msg, casadi::Function* x0){+    try {+        casadi::Function x0_ = Marshaling<casadi::Function,casadi::Function*>::marshal(x0);++        casadi::NLPSolver ret = casadi::SnoptSolver::creator(x0_);+        return WrapReturn< casadi::NLPSolver*, casadi::NLPSolver >::wrapReturn( ret );+    } catch (std::exception& ex) {+         *err_msg = new std::string(ex.what());+         return 0;+    }+}+++// ================== Normal method: "setOptionsFromFile" ===============+// class: "casadi::SnoptSolver"+// cppName: "casadi::SnoptSolver::setOptionsFromFile"+// cWrapperName: "casadi__SnoptSolver__setOptionsFromFile"+// protoArgs: "(std::string ** err_msg, casadi::SnoptSolver* obj, std::string* x0)"+// args: "(x0_)"+// rettype: CVoid+// cWrapperRetType: "void"+// proto: "void casadi__SnoptSolver__setOptionsFromFile(std::string ** err_msg, casadi::SnoptSolver* obj, std::string* x0)"+// call: "obj->setOptionsFromFile(x0_)"+// params: [Ref (Const StdString)]+extern "C"+    void casadi__SnoptSolver__setOptionsFromFile(std::string ** err_msg, casadi::SnoptSolver* obj, std::string* x0);+void casadi__SnoptSolver__setOptionsFromFile(std::string ** err_msg, casadi::SnoptSolver* obj, std::string* x0){+    try {+        std::string x0_ = Marshaling<std::string,std::string*>::marshal(x0);++    obj->setOptionsFromFile(x0_);+    } catch (std::exception& ex) {+         *err_msg = new std::string(ex.what());+         return;+    }+}+++
+ cbits/autogen/snopt_interface_functions.cpp view
@@ -0,0 +1,53 @@+#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/function/symbolic_qr.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/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 "casadi/interfaces/snopt/snopt_solver.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__