-- Initial lagrangian.cabal generated by cabal init. For further -- documentation, see http://haskell.org/cabal/users-guide/ -- The name of the package. name: lagrangian -- The package version. See the Haskell package versioning policy (PVP) -- for standards guiding when and how versions should be incremented. -- http://www.haskell.org/haskellwiki/Package_versioning_policy -- PVP summary: +-+------- breaking API changes -- | | +----- non-breaking API additions -- | | | +--- code changes with no API change version: 0.2.0.1 -- A short (one-line) description of the package. synopsis: Solve lagrangian multiplier problems -- A longer description of the package. description: Numerically solve convex lagrange multiplier problems with conjugate gradient descent. . Convexity is key, otherwise the descent algorithm can return the wrong answer. . Convexity can be tested by assuring that the hessian of the lagrangian is positive definite over region the function is defined in. . I have provided test that the hessian is positive definite at a point, which is something, but not enough to ensure that the whole function is convex. . Be that as it may, if you know what the your lagrangian is convex you can use 'solve' to find the minimum. . For example, find the maximum entropy with the constraint that the probabilities add up to one. . @ solve 0.00001 (negate . sum . map (\x -> x * log x), [(sum, 1)]) 3 @ . Gives the answer ([0.33, 0.33, 0.33], [-0.09]) . The first elements of the result pair are the arguments for the objective function at the minimum. The second elements are the lagrange multipliers. . -- URL for the project homepage or repository. homepage: http://github.com/jfischoff/lagrangian -- The license under which the package is released. license: BSD3 -- The file containing the license text. license-file: LICENSE -- The package author(s). author: Jonathan Fischoff -- An email address to which users can send suggestions, bug reports, and -- patches. maintainer: jonathangfischoff@gmail.com -- A copyright notice. -- copyright: category: Math build-type: Simple -- Constraint on the version of Cabal needed to build this package. cabal-version: >=1.8 library -- Modules exported by the library. exposed-modules: Numeric.AD.Lagrangian -- Modules included in this library but not exported. other-modules: Numeric.AD.Lagrangian.Internal -- Other library packages from which modules are imported. build-depends: base ==4.6.*, nonlinear-optimization ==0.3.*, vector ==0.10.*, ad ==3.4.*, hmatrix == 0.14.* -- Directories containing source files. hs-source-dirs: src Test-Suite tests Hs-Source-Dirs: src, tests type: exitcode-stdio-1.0 main-is: Main.hs build-depends: base ==4.6.*, nonlinear-optimization ==0.3.*, vector ==0.10.*, ad ==3.3.*, hmatrix == 0.14.*, test-framework ==0.6.*, test-framework-hunit ==0.2.*, test-framework-quickcheck2 ==0.2.*, HUnit == 1.2.*