úÎqïlàb      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRS T U V W X Y Z [ \ ] ^ _ ` a None!"(*234=BHKM fA representation that uses native 64-bit ints and 64-bit doubles. Really, this should be 32-bit ints.iAn assignment from variables to values. Maps integer variables to integers, and real variables to reals./The Representation class. Requires its members Z c and R c to be Num, Ord and Eq.AFor some reason, for type inference to work, the members must be data instead of type=. This gives some minor annoyances when unpacking them. See   below.Integers Real numbersLConvert an integer to a real. This should not lose any precision. (whereas fromIntegral 1000 :: Word8 would lose precision) @Retrieve value of integer variable - or 0, if there is no value. =Retrieve value of real variable - or 0, if there is no value. URetrieve value of an integer or real variable, with result cast to a real regardless. 4Convert a wrapped (R IntDouble) to an actual Double..Define show manually, so we can strip out the Z and R prefixes.      None!"(*234=BHKM CMaybe a lower bound, the variable's name, and maybe an upper bound.„Define upper and lower bounds of program variables. Bounds may be specified multiple times: the intersection of all bounds is used.7Create a lower and upper bound for an integer variable.3Create only a lower bound for an integer variable. 4Create only an upper bound for an integer variable. 'A binary integer variable: can only be 0 or 1.3Create a lower and upper bound for a real variable./Create only a lower bound for a real variable. 0Create only an upper bound for a real variable.    None!"(*234=BHKM Convert a K to its actual representation (Z or R).ŸFind the result type of merging, or adding, two linear functions: adding two integers produces an integer, while adding a real on either side produces a real.|Representation of either integral of real linear functions: a list of variables with coefficients, plus a constant summand."IClassify the result type of a linear function to either integral or real:#Real or mixed R$ Integral Z !"#$ !"#$"$#! ! "$#None!"(*234=BHKM%AAny linear function can be converted into a real linear function.&Integral variable'$Integral variable with coefficient 1( Real variable) Real variable with coefficient 1*An integral constant summand+An integral constant summand, Constant 0- Constant 1.A real constantb7Helper for applying function to second element of tuple/=Negate a linear function. Negation does not change the kind.0,Multiply a linear function by some constant.uNote that you cannot multiply a linear function by another linear function, as the result would likely be non-linear!1,Multiply a linear function by some constant.2HAdd two linear functions together. They can have different result types.3PSubtract one linear function from another. They can have different result types.%&'()*+,-.b/0123 !%&'()*+,-./0123! %&'()*+.,-/0123%&'()*+,-.b/01230123None!"(*234=BHKM4Different kind of constraints.iThese are not all necessary, but I have a hunch that keeping some structure may be helpful in the future. Constructors: :==Equality constraint:<=Less than or equal:<EStrictly less than: this is only allowed for purely integer functions:>=Greater than or equal:>HStrictly greater than: this is only allowed for purely integer functionsBetween Between a b c is equivalent to a :<= b :&& b :<= c:&&Conjunction of two constraints:!"name" :! constr@ Annotate a constraint with a name, or other useless informationCTrueTrivially true constraint 456789:;<=> 456789:;<= 4=<;:98765>4 =<;:98765>679:;<=None!"(*234=BHKM?`Evaluate a linear function with given assignment. If the linear function is purely integral, a Z will be returned; otherwise, R.@GEvaluate a linear function with given assignment, returning real value.A.Check whether assignment satisfies constraint.?@A?@A?@A?@ANone!"(*234=BHKMB Whole program, parameterised by: ztype of integer variablesrtype of real variablesc*representation of integers and reals (see )DOptimisation directionEThe objective functionF All constraints bundled up with :&&.G–Upper and lower bounds of variables. Not all variables need to be mentioned, and if variables are mentioned multiple times, the intersection is used.H7Direction to optimise program in: minimise or maximise. BCDEFGHIJKLM BCDEFGHIJKLM HJIBCDEFGKLMBCDEFGHJIKLM None!"(*234=BHKM; !"#$%&'()*+,-./0123456789:;<=?@ABCDEFGHIJKLMNone!"(*234=BHKMNsLinear function is represented as a map from either a integral variable or an real variable, to a real coefficient.P>Create linear function from list of variables and coefficientsQ.Evaluate linear function with given assignmentR/Find set of all variables mentioned in functionNOPQRNOPQRNOPQRNOPQR None!"(*234=BHKMSA simple constraintTAMaybe a lower bound, a linear function, and maybe an upper bound.JIn order to be meaningful, at least one of lower or upper bound should be Just.U!Conjunction of simple constraintsW4Check whether an assignment satisfies the constraintX"Get set of variables in constraintSTUVWXSTUVWXUVSTWXSTUVWX None!"(*234=BHKMY‹A program represented by objective, constraints and bounds. There is no need for an optimisation direction; the objective is just negated.^.Find set of all variables mentioned in programYZ[\]^YZ[\]^YZ[\]^YZ[\]^ None!"(*234=BHKM_Convert a Frontend  into a Canon NK. Returns the constant summand as well, as Canon Linear do not have these.Should satisfy that Fforall a l. P.evalR a l == evalR a (fst $ linear l) + (snd $ linear l)`Convert a Frontend 4 into a Canon U.Should satisfy that 1forall a c. P.check a c == check a (constraint c)aConvert a Frontend B into a Canon Y.LIf we had a solve function that worked on either, it would ideally satisfy (forall p. P.solve p == solve (program p)…However, due to potential non-determinism in solving functions, it could be possible to get a different, but still optimal, solution: Óforall p. let aP = P.solve p p' = program p a = solve p' in P.eval aP (P._objective p) == eval a (_objective p') && check a (P._constraints p) && check ..._`a_`a_`a_`a None!"(*234=BHKMNOPQRSTUVWXYZ[\]^_`ac !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMMNOPQRSTUVW**XKY Z [ ? ? L \ M M O P Q ] ^ _ U`a limp-0.3.0.0Numeric.Limp.RepNumeric.Limp.Program.BoundsNumeric.Limp.Program.ResultKindNumeric.Limp.Program.LinearNumeric.Limp.Program.ConstraintNumeric.Limp.Program.EvalNumeric.Limp.Program.ProgramNumeric.Limp.Canon.LinearNumeric.Limp.Canon.ConstraintNumeric.Limp.Canon.ProgramNumeric.Limp.Canon.ConvertNumeric.Limp.ProgramNumeric.Limp.Canon IntDouble AssignmentRepZRfromZzOfrOfzrOfunwrapR$fShowR$fShowZTFCo:R:ZIntDoubleTFCo:R:RIntDouble$fRepIntDoubleBBoundsBoundRBoundZ lowerUpperZlowerZupperZbinary lowerUpperRlowerRupperRKRepKMergeLinearLRLZKKRKZtoRzz1rr1conconZc0c1conRneg.**..+..-. ConstraintCTrue:!:&&Between:>:>=:<:<=:==$fMonoidConstraintevalevalRcheckProgram _direction _objective _constraints_bounds DirectionMaximiseMinimiseprogramminimisemaximisemkLinear varsOfLinear Constraint1C1varsOfConstraint varsOfProgramlinear constrainton2