exp-pairs
Copyright(c) Andrew Lelechenko 2014-2020
LicenseGPL-3
Maintainer[email protected]
Safe HaskellSafe-Inferred
LanguageHaskell2010

Math.ExpPairs.LinearForm

Description

Linear forms, rational forms and constraints

Provides types for rational forms (to hold objective functions in Math.ExpPairs) and linear contraints (to hold constraints of optimization). Both of them are built atop of projective linear forms.

Synopsis

Documentation

data LinearForm t Source #

Define an affine linear form of three variables: a*k + b*l + c*m. First argument of LinearForm stands for a, second for b and third for c. Linear forms form a monoid by addition.

Constructors

LinearForm !t !t !t 

Instances

Instances details
Functor LinearForm Source # 
Instance details

Defined in Math.ExpPairs.LinearForm

Methods

fmap :: (a -> b) -> LinearForm a -> LinearForm b #

(<$) :: a -> LinearForm b -> LinearForm a #

Foldable LinearForm Source # 
Instance details

Defined in Math.ExpPairs.LinearForm

Methods

fold :: Monoid m => LinearForm m -> m #

foldMap :: Monoid m => (a -> m) -> LinearForm a -> m #

foldMap' :: Monoid m => (a -> m) -> LinearForm a -> m #

foldr :: (a -> b -> b) -> b -> LinearForm a -> b #

foldr' :: (a -> b -> b) -> b -> LinearForm a -> b #

foldl :: (b -> a -> b) -> b -> LinearForm a -> b #

foldl' :: (b -> a -> b) -> b -> LinearForm a -> b #

foldr1 :: (a -> a -> a) -> LinearForm a -> a #

foldl1 :: (a -> a -> a) -> LinearForm a -> a #

toList :: LinearForm a -> [a] #

null :: LinearForm a -> Bool #

length :: LinearForm a -> Int #

elem :: Eq a => a -> LinearForm a -> Bool #

maximum :: Ord a => LinearForm a -> a #

minimum :: Ord a => LinearForm a -> a #

sum :: Num a => LinearForm a -> a #

product :: Num a => LinearForm a -> a #

Traversable LinearForm Source # 
Instance details

Defined in Math.ExpPairs.LinearForm

Methods

traverse :: Applicative f => (a -> f b) -> LinearForm a -> f (LinearForm b) #

sequenceA :: Applicative f => LinearForm (f a) -> f (LinearForm a) #

mapM :: Monad m => (a -> m b) -> LinearForm a -> m (LinearForm b) #

sequence :: Monad m => LinearForm (m a) -> m (LinearForm a) #

NFData t => NFData (LinearForm t) Source # 
Instance details

Defined in Math.ExpPairs.LinearForm

Methods

rnf :: LinearForm t -> () #

Num t => Monoid (LinearForm t) Source # 
Instance details

Defined in Math.ExpPairs.LinearForm

Num t => Semigroup (LinearForm t) Source # 
Instance details

Defined in Math.ExpPairs.LinearForm

Generic (LinearForm t) Source # 
Instance details

Defined in Math.ExpPairs.LinearForm

Associated Types

type Rep (LinearForm t) 
Instance details

Defined in Math.ExpPairs.LinearForm

type Rep (LinearForm t) = D1 ('MetaData "LinearForm" "Math.ExpPairs.LinearForm" "exp-pairs-0.2.1.1-8itfA9RAbYGDVV8JvWzVP7" 'False) (C1 ('MetaCons "LinearForm" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 t) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 t) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 t))))

Methods

from :: LinearForm t -> Rep (LinearForm t) x #

to :: Rep (LinearForm t) x -> LinearForm t #

Num t => Num (LinearForm t) Source # 
Instance details

Defined in Math.ExpPairs.LinearForm

Show t => Show (LinearForm t) Source # 
Instance details

Defined in Math.ExpPairs.LinearForm

Eq t => Eq (LinearForm t) Source # 
Instance details

Defined in Math.ExpPairs.LinearForm

Methods

(==) :: LinearForm t -> LinearForm t -> Bool #

(/=) :: LinearForm t -> LinearForm t -> Bool #

(Num t, Eq t, Pretty t) => Pretty (LinearForm t) Source # 
Instance details

Defined in Math.ExpPairs.LinearForm

Methods

pretty :: LinearForm t -> Doc ann #

prettyList :: [LinearForm t] -> Doc ann #

type Rep (LinearForm t) Source # 
Instance details

Defined in Math.ExpPairs.LinearForm

type Rep (LinearForm t) = D1 ('MetaData "LinearForm" "Math.ExpPairs.LinearForm" "exp-pairs-0.2.1.1-8itfA9RAbYGDVV8JvWzVP7" 'False) (C1 ('MetaCons "LinearForm" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 t) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 t) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 t))))

scaleLF :: (Num t, Eq t) => t -> LinearForm t -> LinearForm t Source #

Multiply a linear form by a given coefficient.

evalLF :: Num t => (t, t, t) -> LinearForm t -> t Source #

Evaluate a linear form a*k + b*l + c*m for given k, l and m.

substituteLF :: (Eq t, Num t) => (LinearForm t, LinearForm t, LinearForm t) -> LinearForm t -> LinearForm t Source #

Substitute linear forms k, l and m into a given linear form a*k + b*l + c*m to obtain a new linear form.

data RationalForm t Source #

Define a rational form of two variables, equal to the ratio of two LinearForm.

Constructors

(LinearForm t) :/: (LinearForm t) infix 5 

Instances

Instances details
Functor RationalForm Source # 
Instance details

Defined in Math.ExpPairs.LinearForm

Methods

fmap :: (a -> b) -> RationalForm a -> RationalForm b #

(<$) :: a -> RationalForm b -> RationalForm a #

Foldable RationalForm Source # 
Instance details

Defined in Math.ExpPairs.LinearForm

Methods

fold :: Monoid m => RationalForm m -> m #

foldMap :: Monoid m => (a -> m) -> RationalForm a -> m #

foldMap' :: Monoid m => (a -> m) -> RationalForm a -> m #

foldr :: (a -> b -> b) -> b -> RationalForm a -> b #

foldr' :: (a -> b -> b) -> b -> RationalForm a -> b #

foldl :: (b -> a -> b) -> b -> RationalForm a -> b #

foldl' :: (b -> a -> b) -> b -> RationalForm a -> b #

foldr1 :: (a -> a -> a) -> RationalForm a -> a #

foldl1 :: (a -> a -> a) -> RationalForm a -> a #

toList :: RationalForm a -> [a] #

null :: RationalForm a -> Bool #

length :: RationalForm a -> Int #

elem :: Eq a => a -> RationalForm a -> Bool #

maximum :: Ord a => RationalForm a -> a #

minimum :: Ord a => RationalForm a -> a #

sum :: Num a => RationalForm a -> a #

product :: Num a => RationalForm a -> a #

Traversable RationalForm Source # 
Instance details

Defined in Math.ExpPairs.LinearForm

Methods

traverse :: Applicative f => (a -> f b) -> RationalForm a -> f (RationalForm b) #

sequenceA :: Applicative f => RationalForm (f a) -> f (RationalForm a) #

mapM :: Monad m => (a -> m b) -> RationalForm a -> m (RationalForm b) #

sequence :: Monad m => RationalForm (m a) -> m (RationalForm a) #

NFData t => NFData (RationalForm t) Source # 
Instance details

Defined in Math.ExpPairs.LinearForm

Methods

rnf :: RationalForm t -> () #

Generic (RationalForm t) Source # 
Instance details

Defined in Math.ExpPairs.LinearForm

Associated Types

type Rep (RationalForm t) 
Instance details

Defined in Math.ExpPairs.LinearForm

type Rep (RationalForm t) = D1 ('MetaData "RationalForm" "Math.ExpPairs.LinearForm" "exp-pairs-0.2.1.1-8itfA9RAbYGDVV8JvWzVP7" 'False) (C1 ('MetaCons ":/:" ('InfixI 'NotAssociative 5) 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (LinearForm t)) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (LinearForm t))))

Methods

from :: RationalForm t -> Rep (RationalForm t) x #

to :: Rep (RationalForm t) x -> RationalForm t #

Num t => Num (RationalForm t) Source # 
Instance details

Defined in Math.ExpPairs.LinearForm

Num t => Fractional (RationalForm t) Source # 
Instance details

Defined in Math.ExpPairs.LinearForm

Show t => Show (RationalForm t) Source # 
Instance details

Defined in Math.ExpPairs.LinearForm

Eq t => Eq (RationalForm t) Source # 
Instance details

Defined in Math.ExpPairs.LinearForm

(Num t, Eq t, Pretty t) => Pretty (RationalForm t) Source # 
Instance details

Defined in Math.ExpPairs.LinearForm

Methods

pretty :: RationalForm t -> Doc ann #

prettyList :: [RationalForm t] -> Doc ann #

type Rep (RationalForm t) Source # 
Instance details

Defined in Math.ExpPairs.LinearForm

type Rep (RationalForm t) = D1 ('MetaData "RationalForm" "Math.ExpPairs.LinearForm" "exp-pairs-0.2.1.1-8itfA9RAbYGDVV8JvWzVP7" 'False) (C1 ('MetaCons ":/:" ('InfixI 'NotAssociative 5) 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (LinearForm t)) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (LinearForm t))))

evalRF :: Real t => (Integer, Integer, Integer) -> RationalForm t -> RationalInf Source #

Evaluate a rational form (a*k + b*l + c*m) / (a'*k + b'*l + c'*m) for given k, l and m.

data IneqType Source #

Constants to specify the strictness of Constraint.

Constructors

Strict

Strict inequality (>0).

NonStrict

Non-strict inequality (≥0).

Instances

Instances details
Bounded IneqType Source # 
Instance details

Defined in Math.ExpPairs.LinearForm

Enum IneqType Source # 
Instance details

Defined in Math.ExpPairs.LinearForm

Generic IneqType Source # 
Instance details

Defined in Math.ExpPairs.LinearForm

Associated Types

type Rep IneqType 
Instance details

Defined in Math.ExpPairs.LinearForm

type Rep IneqType = D1 ('MetaData "IneqType" "Math.ExpPairs.LinearForm" "exp-pairs-0.2.1.1-8itfA9RAbYGDVV8JvWzVP7" 'False) (C1 ('MetaCons "Strict" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "NonStrict" 'PrefixI 'False) (U1 :: Type -> Type))

Methods

from :: IneqType -> Rep IneqType x #

to :: Rep IneqType x -> IneqType #

Show IneqType Source # 
Instance details

Defined in Math.ExpPairs.LinearForm

Eq IneqType Source # 
Instance details

Defined in Math.ExpPairs.LinearForm

Ord IneqType Source # 
Instance details

Defined in Math.ExpPairs.LinearForm

Pretty IneqType Source # 
Instance details

Defined in Math.ExpPairs.LinearForm

Methods

pretty :: IneqType -> Doc ann #

prettyList :: [IneqType] -> Doc ann #

type Rep IneqType Source # 
Instance details

Defined in Math.ExpPairs.LinearForm

type Rep IneqType = D1 ('MetaData "IneqType" "Math.ExpPairs.LinearForm" "exp-pairs-0.2.1.1-8itfA9RAbYGDVV8JvWzVP7" 'False) (C1 ('MetaCons "Strict" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "NonStrict" 'PrefixI 'False) (U1 :: Type -> Type))

data Constraint t Source #

A linear constraint of two variables.

Constructors

Constraint !(LinearForm t) !IneqType 

Instances

Instances details
Functor Constraint Source # 
Instance details

Defined in Math.ExpPairs.LinearForm

Methods

fmap :: (a -> b) -> Constraint a -> Constraint b #

(<$) :: a -> Constraint b -> Constraint a #

Foldable Constraint Source # 
Instance details

Defined in Math.ExpPairs.LinearForm

Methods

fold :: Monoid m => Constraint m -> m #

foldMap :: Monoid m => (a -> m) -> Constraint a -> m #

foldMap' :: Monoid m => (a -> m) -> Constraint a -> m #

foldr :: (a -> b -> b) -> b -> Constraint a -> b #

foldr' :: (a -> b -> b) -> b -> Constraint a -> b #

foldl :: (b -> a -> b) -> b -> Constraint a -> b #

foldl' :: (b -> a -> b) -> b -> Constraint a -> b #

foldr1 :: (a -> a -> a) -> Constraint a -> a #

foldl1 :: (a -> a -> a) -> Constraint a -> a #

toList :: Constraint a -> [a] #

null :: Constraint a -> Bool #

length :: Constraint a -> Int #

elem :: Eq a => a -> Constraint a -> Bool #

maximum :: Ord a => Constraint a -> a #

minimum :: Ord a => Constraint a -> a #

sum :: Num a => Constraint a -> a #

product :: Num a => Constraint a -> a #

Traversable Constraint Source # 
Instance details

Defined in Math.ExpPairs.LinearForm

Methods

traverse :: Applicative f => (a -> f b) -> Constraint a -> f (Constraint b) #

sequenceA :: Applicative f => Constraint (f a) -> f (Constraint a) #

mapM :: Monad m => (a -> m b) -> Constraint a -> m (Constraint b) #

sequence :: Monad m => Constraint (m a) -> m (Constraint a) #

NFData t => NFData (Constraint t) Source # 
Instance details

Defined in Math.ExpPairs.LinearForm

Methods

rnf :: Constraint t -> () #

Generic (Constraint t) Source # 
Instance details

Defined in Math.ExpPairs.LinearForm

Associated Types

type Rep (Constraint t) 
Instance details

Defined in Math.ExpPairs.LinearForm

type Rep (Constraint t) = D1 ('MetaData "Constraint" "Math.ExpPairs.LinearForm" "exp-pairs-0.2.1.1-8itfA9RAbYGDVV8JvWzVP7" 'False) (C1 ('MetaCons "Constraint" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (LinearForm t)) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 IneqType)))

Methods

from :: Constraint t -> Rep (Constraint t) x #

to :: Rep (Constraint t) x -> Constraint t #

Show t => Show (Constraint t) Source # 
Instance details

Defined in Math.ExpPairs.LinearForm

Eq t => Eq (Constraint t) Source # 
Instance details

Defined in Math.ExpPairs.LinearForm

Methods

(==) :: Constraint t -> Constraint t -> Bool #

(/=) :: Constraint t -> Constraint t -> Bool #

(Num t, Eq t, Pretty t) => Pretty (Constraint t) Source # 
Instance details

Defined in Math.ExpPairs.LinearForm

Methods

pretty :: Constraint t -> Doc ann #

prettyList :: [Constraint t] -> Doc ann #

type Rep (Constraint t) Source # 
Instance details

Defined in Math.ExpPairs.LinearForm

type Rep (Constraint t) = D1 ('MetaData "Constraint" "Math.ExpPairs.LinearForm" "exp-pairs-0.2.1.1-8itfA9RAbYGDVV8JvWzVP7" 'False) (C1 ('MetaCons "Constraint" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (LinearForm t)) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 IneqType)))

checkConstraint :: (Num t, Ord t) => (Integer, Integer, Integer) -> Constraint t -> Bool Source #

Evaluate a rational form of constraint and compare its value with 0. Strictness depends on the given IneqType.