Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Data and class definitions for the core math programming interface.
Synopsis
- class Monad m => MonadLP v c o m | m -> v c o where
- addVariable :: m v
- deleteVariable :: v -> m ()
- getVariableName :: v -> m Text
- setVariableName :: v -> Text -> m ()
- getVariableBounds :: v -> m Bounds
- setVariableBounds :: v -> Bounds -> m ()
- getVariableValue :: v -> m Double
- addConstraint :: Inequality (Expr v) -> m c
- deleteConstraint :: c -> m ()
- getConstraintName :: c -> m Text
- setConstraintName :: c -> Text -> m ()
- getConstraintValue :: c -> m Double
- addObjective :: Expr v -> m o
- deleteObjective :: o -> m ()
- getObjectiveName :: o -> m Text
- setObjectiveName :: o -> Text -> m ()
- getObjectiveSense :: o -> m Sense
- setObjectiveSense :: o -> Sense -> m ()
- getObjectiveValue :: o -> m Double
- getTimeout :: m Double
- setTimeout :: Double -> m ()
- optimizeLP :: m SolutionStatus
- compose2 :: (c -> d) -> (a -> b -> c) -> a -> b -> d
- lift2 :: (MonadTrans t, Monad m) => (a -> b -> m c) -> a -> b -> t m c
- class MonadLP v c o m => MonadIP v c o m | m -> v c o where
- getVariableDomain :: v -> m Domain
- setVariableDomain :: v -> Domain -> m ()
- getRelativeMIPGap :: m Double
- setRelativeMIPGap :: Double -> m ()
- optimizeIP :: m SolutionStatus
- data Sense
- data SolutionStatus
- = Optimal
- | Feasible
- | Infeasible
- | Unbounded
- | Error
- data Bounds
- data Domain
- = Continuous
- | Integer
- | Binary
- data Inequality a = Inequality Ordering a a
- type Expr = LinExpr Double
Documentation
class Monad m => MonadLP v c o m | m -> v c o where Source #
A linear program.
This is a monadic context for formulating and solving linear
programs. The types v
, c
, and o
refer to the types of
variables, constraints, and objectives, respectively, used by a
particular solver backend.
addVariable :: m v Source #
Add a new (free) variable to the model.
See free
, bounded
,
nonNeg
, and nonPos
as higher-level alternatives.
deleteVariable :: v -> m () Source #
Remove a variable from the model.
getVariableName :: v -> m Text Source #
Get the name of a variable.
setVariableName :: v -> Text -> m () Source #
Set a name for a variable.
getVariableBounds :: v -> m Bounds Source #
Retrieve the current bounds associated with a variable.
setVariableBounds :: v -> Bounds -> m () Source #
Apply bounds to a variable.
See within
as a higher-level alternative.
getVariableValue :: v -> m Double Source #
Get the value of a variable in the current solution.
This value could be arbitrary if no solve has been completed, or a solve produced an infeasible or unbounded solution.
addConstraint :: Inequality (Expr v) -> m c Source #
Add a constraint representing the given inequality to the model.
See the .==.
, .==#
,
==.
, .>=.
,
.>=
, >=.
,
.<=.
, .<=
, and
<=.
functions as higher-level
alternatives.
deleteConstraint :: c -> m () Source #
Remove a constraint from the model.
getConstraintName :: c -> m Text Source #
Get the name of a constraint.
setConstraintName :: c -> Text -> m () Source #
Set a name for a constraint.
getConstraintValue :: c -> m Double Source #
Get the dual value associated with a constraint.
addObjective :: Expr v -> m o Source #
Add an objective to the problem.
Depending on the solver backend, this might replace an existing objective.
deleteObjective :: o -> m () Source #
Remove an objective from the model.
getObjectiveName :: o -> m Text Source #
Get the name of a objective.
setObjectiveName :: o -> Text -> m () Source #
Set a name for a objective.
getObjectiveSense :: o -> m Sense Source #
Get the sense of an objective.
setObjectiveSense :: o -> Sense -> m () Source #
Set the sense of an objective.
getObjectiveValue :: o -> m Double Source #
Get the value of an objective.
getTimeout :: m Double Source #
Get the timeout associated with a problem.
setTimeout :: Double -> m () Source #
Set the timeout associated with a problem.
optimizeLP :: m SolutionStatus Source #
Compute an LP-optimal solution.
Instances
compose2 :: (c -> d) -> (a -> b -> c) -> a -> b -> d Source #
Function composition involving a 2-argument function.
lift2 :: (MonadTrans t, Monad m) => (a -> b -> m c) -> a -> b -> t m c Source #
Monadic lifting involving a 2-argument function.
class MonadLP v c o m => MonadIP v c o m | m -> v c o where Source #
A (mixed) integer program.
In addition to the methods of the MonadLP
class, this monad
supports constraining variables to be either continuous or
discrete.
getVariableDomain :: v -> m Domain Source #
setVariableDomain :: v -> Domain -> m () Source #
getRelativeMIPGap :: m Double Source #
setRelativeMIPGap :: Double -> m () Source #
optimizeIP :: m SolutionStatus Source #
Instances
MonadIP v c o m => MonadIP v c o (ReaderT r m) Source # | |
Defined in Math.Programming.Types getVariableDomain :: v -> ReaderT r m Domain Source # setVariableDomain :: v -> Domain -> ReaderT r m () Source # getRelativeMIPGap :: ReaderT r m Double Source # setRelativeMIPGap :: Double -> ReaderT r m () Source # optimizeIP :: ReaderT r m SolutionStatus Source # | |
MonadIP v c o m => MonadIP v c o (StateT s m) Source # | |
Defined in Math.Programming.Types getVariableDomain :: v -> StateT s m Domain Source # setVariableDomain :: v -> Domain -> StateT s m () Source # getRelativeMIPGap :: StateT s m Double Source # setRelativeMIPGap :: Double -> StateT s m () Source # optimizeIP :: StateT s m SolutionStatus Source # |
Whether a math program is minimizing or maximizing its objective.
data SolutionStatus Source #
The outcome of an optimization.
Optimal | An optimal solution has been found. |
Feasible | A feasible solution has been found. The result may or may not be optimal. |
Infeasible | The model has been proven to be infeasible. |
Unbounded | The model has been proven to be unbounded. |
Error | An error was encountered during the solve. Instance-specific methods should be used to determine what occurred. |
Instances
Read SolutionStatus Source # | |
Defined in Math.Programming.Types readsPrec :: Int -> ReadS SolutionStatus # readList :: ReadS [SolutionStatus] # | |
Show SolutionStatus Source # | |
Defined in Math.Programming.Types showsPrec :: Int -> SolutionStatus -> ShowS # show :: SolutionStatus -> String # showList :: [SolutionStatus] -> ShowS # | |
Eq SolutionStatus Source # | |
Defined in Math.Programming.Types (==) :: SolutionStatus -> SolutionStatus -> Bool # (/=) :: SolutionStatus -> SolutionStatus -> Bool # | |
Ord SolutionStatus Source # | |
Defined in Math.Programming.Types compare :: SolutionStatus -> SolutionStatus -> Ordering # (<) :: SolutionStatus -> SolutionStatus -> Bool # (<=) :: SolutionStatus -> SolutionStatus -> Bool # (>) :: SolutionStatus -> SolutionStatus -> Bool # (>=) :: SolutionStatus -> SolutionStatus -> Bool # max :: SolutionStatus -> SolutionStatus -> SolutionStatus # min :: SolutionStatus -> SolutionStatus -> SolutionStatus # |
An interval of the real numbers.
NonNegativeReals | The non-negative reals. |
NonPositiveReals | The non-positive reals. |
Interval Double Double | Any closed interval of the reals. |
Free | Any real number. |
The type of values that a variable can take on.
Note that the Integer
constructor does not interfere with the
Integer
type, as the Integer
type does not define a constuctor
of the same name. The ambiguity is unfortunate, but other natural
nomenclature such as Integral
are similarly conflicted.
Continuous | The variable lies in the real numbers |
Integer | The variable lies in the integers |
Binary | The variable lies in the set |
data Inequality a Source #
Non-strict inequalities.
Inequality Ordering a a |