Skip to content

Commit 6973382

Browse files
committed
wip
1 parent 772e032 commit 6973382

File tree

3 files changed

+27
-5
lines changed

3 files changed

+27
-5
lines changed

simplex-method.cabal

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ library
4545
Linear.SlackForm.Types
4646
Linear.SlackForm.Util
4747
Linear.System.Linear.Types
48-
Linear.System.Linear.Util
4948
Linear.System.Simple.Types
5049
Linear.System.Simple.Util
5150
Linear.System.Types
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
-- |
2+
-- Module: Linear.Constraint.Linear.Util
3+
-- Description: Utility functions for linear constraints
4+
-- Copyright: (c) Junaid Rasheed, 2020-2024
5+
-- License: BSD-3
6+
-- Maintainer: Junaid Rasheed <jrasheed178@gmail.com>
7+
-- Stability: experimental
8+
module Linear.Constraint.Linear.Util where
9+
10+
import Linear.Constraint.Linear.Types (LinearEquation (..))
11+
import Linear.Expr.Util ( exprVarsOnlyVars )
12+
import Linear.Var.Types ( Var )
13+
import qualified Data.Set as Set
14+
15+
-- | Get the variables in a linear equation
16+
linearEquationVars :: LinearEquation -> Set.Set Var
17+
linearEquationVars (LinearEquation lhs _) = exprVarsOnlyVars lhs

src/Linear/SlackForm/Types.hs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,24 @@
77
-- Stability: experimental
88
module Linear.SlackForm.Types where
99

10+
import qualified Data.Set as Set
1011
import GHC.Generics (Generic)
11-
import Linear.Expr.Types (Expr)
12+
import Linear.Expr.Types (ExprVarsOnly)
1213
import Linear.System.Linear.Types (LinearSystem)
14+
import Linear.System.Simple.Types
1315
import Linear.Var.Types (SimplexNum, Var)
1416

1517
-- Expr == SimplexNum
1618
data SlackForm = SlackForm
17-
{ maxObjective :: Expr -- TODO: should be ExprVarsOnly
19+
{ maxObjective :: ExprVarsOnly -- TODO: should be ExprVarsOnly
1820
, constraints :: LinearSystem
19-
, vars :: [Var] -- all vars are non-negative
21+
, vars :: Set.Set Var -- all vars are non-negative
2022
}
2123
deriving (Show, Eq, Read, Generic)
2224

2325
class CanBeSlackForm a where
24-
toSlackForm :: a -> SlackForm
26+
-- TODO: CanBeExprVarsOnly
27+
toSlackForm :: a -> ExprVarsOnly -> SlackForm
28+
29+
instance CanBeSlackForm LinearSystem where
30+
toSlackForm ls obj = SlackForm obj ls Set.empty

0 commit comments

Comments
 (0)