Created
October 31, 2015 12:23
-
-
Save timjb/c216571451551fbd400d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env stack | |
| -- stack --resolver lts-3.11 --install-ghc runghc --package hmatrix-glpk-0.4.1.0 | |
| module Main where | |
| import Numeric.LinearProgramming | |
| constraints :: [Bound [Double]] | |
| constraints = | |
| -- first vector is valid | |
| [ [ 1, 1, 1, 0, 0, 0, 0, 0, 0 ] :>=: 0 | |
| , [ 1, 0, 0, 0, 0, 0, 0, 0, 0 ] :>=: 1 | |
| , [ 0, 1, 0, 0, 0, 0, 0, 0, 0 ] :<=: 0 | |
| , [ 0, 0, 1, 0, 0, 0, 0, 0, 0 ] :<=: 0 | |
| -- second vector is valid | |
| , [ 0, 0, 0, 1, 1, 1, 0, 0, 0 ] :>=: 0 | |
| , [ 0, 0, 0, 0, 1, 0, 0, 0, 0 ] :>=: 1 | |
| , [ 0, 0, 0, 1, 0, 0, 0, 0, 0 ] :<=: 0 | |
| , [ 0, 0, 0, 0, 0, 1, 0, 0, 0 ] :<=: 0 | |
| -- third vector is valid | |
| , [ 0, 0, 0, 0, 0, 0, 1, 1, 1 ] :>=: 0 | |
| , [ 0, 0, 0, 0, 0, 0, 0, 0, 1 ] :>=: 1 | |
| , [ 0, 0, 0, 0, 0, 0, 1, 0, 0 ] :<=: 0 | |
| , [ 0, 0, 0, 0, 0, 0, 0, 1, 0 ] :<=: 0 | |
| -- at least one vector is strictly positive | |
| --, [ 1, 1, 1, 1, 1, 1, 1, 1, 1 ] :>=: 1 | |
| -- the third vector is a combination of the first two | |
| , [ 1, 0, 0, -1, 0, 0, 1, 0, 0 ] :==: 0 | |
| , [ 0, 1, 0, 0, -1, 0, 0, 1, 0 ] :==: 0 | |
| , [ 0, 0, 1, 0, 0, -1, 0, 0, 1 ] :==: 0 | |
| ] | |
| main :: IO () | |
| main = print $ simplex opt (Dense constraints) [] | |
| where opt = Minimize [1,1,1,1,1,1,1,1,1] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment