{-# OPTIONS_GHC -Wall -Werror #-}
module Documentation.SBV.Examples.Optimization.Production where
import Data.SBV
production :: Goal
production :: Goal
production = do SInteger
x <- String -> Symbolic SInteger
sInteger String
"X"
SInteger
y <- String -> Symbolic SInteger
sInteger String
"Y"
let timeA :: SInteger
timeA = SInteger
50 forall a. Num a => a -> a -> a
* SInteger
x forall a. Num a => a -> a -> a
+ SInteger
24 forall a. Num a => a -> a -> a
* SInteger
y
timeB :: SInteger
timeB = SInteger
30 forall a. Num a => a -> a -> a
* SInteger
x forall a. Num a => a -> a -> a
+ SInteger
33 forall a. Num a => a -> a -> a
* SInteger
y
forall (m :: * -> *). SolverContext m => SBool -> m ()
constrain forall a b. (a -> b) -> a -> b
$ SInteger
timeA forall a. OrdSymbolic a => a -> a -> SBool
.<= SInteger
40 forall a. Num a => a -> a -> a
* SInteger
60
forall (m :: * -> *). SolverContext m => SBool -> m ()
constrain forall a b. (a -> b) -> a -> b
$ SInteger
timeB forall a. OrdSymbolic a => a -> a -> SBool
.<= SInteger
35 forall a. Num a => a -> a -> a
* SInteger
60
let finalX :: SInteger
finalX = SInteger
x forall a. Num a => a -> a -> a
+ SInteger
30
finalY :: SInteger
finalY = SInteger
y forall a. Num a => a -> a -> a
+ SInteger
90
forall (m :: * -> *). SolverContext m => SBool -> m ()
constrain forall a b. (a -> b) -> a -> b
$ SInteger
finalX forall a. OrdSymbolic a => a -> a -> SBool
.>= SInteger
75
forall (m :: * -> *). SolverContext m => SBool -> m ()
constrain forall a b. (a -> b) -> a -> b
$ SInteger
finalY forall a. OrdSymbolic a => a -> a -> SBool
.>= SInteger
95
forall a. Metric a => String -> SBV a -> Goal
maximize String
"stock" forall a b. (a -> b) -> a -> b
$ (SInteger
finalX forall a. Num a => a -> a -> a
- SInteger
75) forall a. Num a => a -> a -> a
+ (SInteger
finalY forall a. Num a => a -> a -> a
- SInteger
95)