product-mix-auction-0.1.0.0: A single-round sealed-bid auction for multiple goods

Safe HaskellNone
LanguageHaskell2010

ProductMixAuction.LP.TQSS

Contents

Description

Search for a solution to a TQSS by running the LP multiple times for different sizes of auction, and comparing the resulting demand prices to the TQSS function.

Synopsis

TQSS representation

data TQSS fun Source #

A Total Quantity Supply Schedule (TQSS) is a function from prices to the total number of units that should be made available at those prices. It must be weakly increasing (i.e. increasing any price must not decrease the TQSS).

This type represents a TQSS along with options to control how the search for the solution should take place.

The first parameter determines how the function on the price measure is represented; it will typically be TQSSFun or TQSSTable.

Constructors

TQSS 

Fields

Instances

Eq fun => Eq (TQSS fun) Source # 

Methods

(==) :: TQSS fun -> TQSS fun -> Bool #

(/=) :: TQSS fun -> TQSS fun -> Bool #

Show fun => Show (TQSS fun) Source # 

Methods

showsPrec :: Int -> TQSS fun -> ShowS #

show :: TQSS fun -> String #

showList :: [TQSS fun] -> ShowS #

Generic (TQSS fun) Source # 

Associated Types

type Rep (TQSS fun) :: * -> * #

Methods

from :: TQSS fun -> Rep (TQSS fun) x #

to :: Rep (TQSS fun) x -> TQSS fun #

ToJSON tqss => ToJSON (TQSS tqss) Source # 

Methods

toJSON :: TQSS tqss -> Value

toEncoding :: TQSS tqss -> Encoding

toJSONList :: [TQSS tqss] -> Value

toEncodingList :: [TQSS tqss] -> Encoding

FromJSON tqss => FromJSON (TQSS tqss) Source # 

Methods

parseJSON :: Value -> Parser (TQSS tqss)

parseJSONList :: Value -> Parser [TQSS tqss]

Default tqss => Default (TQSS tqss) Source # 

Methods

def :: TQSS tqss

type Rep (TQSS fun) Source # 
type Rep (TQSS fun) = D1 (MetaData "TQSS" "ProductMixAuction.LP.TQSS" "product-mix-auction-0.1.0.0-inplace" False) (C1 (MetaCons "TQSS" PrefixI True) ((:*:) (S1 (MetaSel (Just Symbol "_tqss_fun") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 fun)) (S1 (MetaSel (Just Symbol "_tqss_type") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 TQSSType))))

data TQSSType Source #

Instances

Eq TQSSType Source # 
Show TQSSType Source # 
Generic TQSSType Source # 

Associated Types

type Rep TQSSType :: * -> * #

Methods

from :: TQSSType -> Rep TQSSType x #

to :: Rep TQSSType x -> TQSSType #

ToJSON TQSSType Source # 

Methods

toJSON :: TQSSType -> Value

toEncoding :: TQSSType -> Encoding

toJSONList :: [TQSSType] -> Value

toEncodingList :: [TQSSType] -> Encoding

FromJSON TQSSType Source # 

Methods

parseJSON :: Value -> Parser TQSSType

parseJSONList :: Value -> Parser [TQSSType]

Default TQSSType Source # 

Methods

def :: TQSSType

type Rep TQSSType Source # 
type Rep TQSSType = D1 (MetaData "TQSSType" "ProductMixAuction.LP.TQSS" "product-mix-auction-0.1.0.0-inplace" False) ((:+:) (C1 (MetaCons "TQSSAbsolute" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 AbsoluteTQSS))) (C1 (MetaCons "TQSSNormalised" PrefixI False) U1))

data AbsoluteTQSS Source #

Constructors

AbsoluteTQSS 

Fields

Instances

Eq AbsoluteTQSS Source # 
Show AbsoluteTQSS Source # 
Generic AbsoluteTQSS Source # 

Associated Types

type Rep AbsoluteTQSS :: * -> * #

ToJSON AbsoluteTQSS Source # 

Methods

toJSON :: AbsoluteTQSS -> Value

toEncoding :: AbsoluteTQSS -> Encoding

toJSONList :: [AbsoluteTQSS] -> Value

toEncodingList :: [AbsoluteTQSS] -> Encoding

FromJSON AbsoluteTQSS Source # 

Methods

parseJSON :: Value -> Parser AbsoluteTQSS

parseJSONList :: Value -> Parser [AbsoluteTQSS]

type Rep AbsoluteTQSS Source # 

data TQSSPriceMeasure Source #

Choice of measure used to convert the vector of prices (one for each good) into a single price on which the TQSS is defined.

Constructors

SingleGoodPrice Good

Define the TQSS on the price of a single good.

MeanPrice

Define the TQSS on the mean price of all the goods.

data TQSSScale Source #

How to change the total quantity available in the auction when solving a TQSS.

Constructors

ScaleSupply SupplyScaleLambda

Scale the supply curves using the given parameter lambda.

AddConstraint

Do not change the supply curves, but add a constraint to the LP bounding the total quantity supplied.

Instances

Eq TQSSScale Source # 
Show TQSSScale Source # 
Generic TQSSScale Source # 

Associated Types

type Rep TQSSScale :: * -> * #

ToJSON TQSSScale Source # 

Methods

toJSON :: TQSSScale -> Value

toEncoding :: TQSSScale -> Encoding

toJSONList :: [TQSSScale] -> Value

toEncodingList :: [TQSSScale] -> Encoding

FromJSON TQSSScale Source # 

Methods

parseJSON :: Value -> Parser TQSSScale

parseJSONList :: Value -> Parser [TQSSScale]

Default TQSSScale Source # 

Methods

def :: TQSSScale

type Rep TQSSScale Source # 
type Rep TQSSScale = D1 (MetaData "TQSSScale" "ProductMixAuction.LP.TQSS" "product-mix-auction-0.1.0.0-inplace" False) ((:+:) (C1 (MetaCons "ScaleSupply" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 SupplyScaleLambda))) (C1 (MetaCons "AddConstraint" PrefixI False) U1))

type TQSSFun = Double -> Units Source #

Representation of a TQSS function as a Haskell function from the price measure to the number of units.

type TQSSTable = [TQSSStep] Source #

Representation of a TQSS function as a list of steps.

type TQSSStep = Step Units Source #

Single step in a TQSS step function.

Search strategies

data TQSSSearchMode Source #

Choice of strategy used to search for the intersection between the TQSS and the demand curve.

Constructors

BinarySearch

Find a solution to the TQSS by binary search on the interval. This minimises the number of LP iterations, but does not guarantee which solution will be returned if multiple solutions exist.

LinearSearchAll

Evaluate the TQSS at all points in the interval (separated by the step size) and choose the point at which supply and demand are closest.

LinearSearchBelow

Find a solution to the TQSS by linear search on the interval, moving in increments of the step size from the lower bound, and stopping if the upper bound is reached before the demand curve meets the TQSS.

CombinedSearch

Like LinearSearchAll, but additionally uses binary search to deliver a more precise result.

Instances

Eq TQSSSearchMode Source # 
Show TQSSSearchMode Source # 
Generic TQSSSearchMode Source # 

Associated Types

type Rep TQSSSearchMode :: * -> * #

ToJSON TQSSSearchMode Source # 

Methods

toJSON :: TQSSSearchMode -> Value

toEncoding :: TQSSSearchMode -> Encoding

toJSONList :: [TQSSSearchMode] -> Value

toEncodingList :: [TQSSSearchMode] -> Encoding

FromJSON TQSSSearchMode Source # 

Methods

parseJSON :: Value -> Parser TQSSSearchMode

parseJSONList :: Value -> Parser [TQSSSearchMode]

Default TQSSSearchMode Source # 
type Rep TQSSSearchMode Source # 
type Rep TQSSSearchMode = D1 (MetaData "TQSSSearchMode" "ProductMixAuction.LP.TQSS" "product-mix-auction-0.1.0.0-inplace" False) ((:+:) ((:+:) (C1 (MetaCons "BinarySearch" PrefixI False) U1) (C1 (MetaCons "LinearSearchAll" PrefixI False) U1)) ((:+:) (C1 (MetaCons "LinearSearchBelow" PrefixI False) U1) (C1 (MetaCons "CombinedSearch" PrefixI False) U1)))

type TQSSSearchStrategy = forall bid. Goodly bid => TQSSFun -> AbsoluteTQSS -> Maybe [Step Units] -> Auction bid -> IO [TQSSPoint] Source #

A TQSS search strategy is given the lower and upper bounds for the total size, a description of the TQSS and a scaled auction. It returns a list of points at which the TQSS was evaluated; the solution is the point at which demand is closest to supply.

Solving the TQSS

data TQSSPoint Source #

A point at which the TQSS has been evaluated.

Constructors

TQSSPoint 

Fields

  • _tqp_demand_target :: Units

    The total size of the auction that was selected.

  • _tqp_demand :: Units

    The total size of the auction (i.e. the "demand") that was evaluated (this may differ from _tqp_demand_target because when rescaling the supply curves we may change the total).

  • _tqp_price :: Double

    The price measure resulting from solving the auction at the demand size.

  • _tqp_supply :: Units

    The desired supply given by evaluating the TQSS function at the price measure.

Instances

Eq TQSSPoint Source # 
Show TQSSPoint Source # 
Generic TQSSPoint Source # 

Associated Types

type Rep TQSSPoint :: * -> * #

ToJSON TQSSPoint Source # 

Methods

toJSON :: TQSSPoint -> Value

toEncoding :: TQSSPoint -> Encoding

toJSONList :: [TQSSPoint] -> Value

toEncodingList :: [TQSSPoint] -> Encoding

FromJSON TQSSPoint Source # 

Methods

parseJSON :: Value -> Parser TQSSPoint

parseJSONList :: Value -> Parser [TQSSPoint]

Default TQSSPoint Source # 

Methods

def :: TQSSPoint

Arbitrary TQSSPoint Source # 
type Rep TQSSPoint Source # 
type Rep TQSSPoint = D1 (MetaData "TQSSPoint" "ProductMixAuction.LP.TQSS" "product-mix-auction-0.1.0.0-inplace" False) (C1 (MetaCons "TQSSPoint" PrefixI True) ((:*:) ((:*:) (S1 (MetaSel (Just Symbol "_tqp_demand_target") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Units)) (S1 (MetaSel (Just Symbol "_tqp_demand") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Units))) ((:*:) (S1 (MetaSel (Just Symbol "_tqp_price") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Double)) (S1 (MetaSel (Just Symbol "_tqp_supply") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Units)))))

runTQSS :: Goodly bid => Auction bid -> TQSS TQSSTable -> IO (Auction bid, AuctionResult bid, Units, Maybe [TQSSPoint]) Source #

Check the validity of the TQSS and solve it using either runNormalisedTQSS or runAbsoluteTQSS as appropriate.

runNormalisedTQSS :: Goodly bid => Auction bid -> TQSSTable -> IO (Auction bid, AuctionResult bid, Units, Maybe a) Source #

Solve an auction with a normalised TQSS using a single LP solver run and including the TQSS in the structure of the LP.

The resulting auction will have auction_size_limit set.

runAbsoluteTQSS :: Goodly bid => Auction bid -> Maybe [TQSSStep] -> TQSSFun -> AbsoluteTQSS -> IO (Auction bid, AuctionResult bid, Units, Maybe [TQSSPoint]) Source #

Iteratively solve an auction with a TQSS, by re-running the LP with variable total quantities and using the search strategy to find the smallest quantity for which demand is no less than the TQSS. Returns the auction scaled to the final size, the prices/allocations at that size, the total size itself and the points of the TQSS graph evaluated to determine it.

Note that if an additional constraint is being used to fix the auction size, the resulting auction will have auction_size_limit set.

Utilities

interpolateTQSS :: TQSS TQSSTable -> TQSS TQSSFun Source #

Convert a TQSS function represented as a list of steps into a proper Haskell function. If a maximum bound for the TQSS search is not set, use the upper limit of the domain of the step function.

isNondecreasingTQSSTable :: TQSSTable -> Bool Source #

Test that the TQSS function is non-decreasing.

isConstrainedTQSS :: TQSS fun -> Bool Source #

Does this TQSS work by constraining the total quantity supplied?

tqssTypeLabel :: TQSSType -> Text Source #

Text label for the prices used by this TQSS type.

Lenses

tqss_fun :: forall fun fun. Lens (TQSS fun) (TQSS fun) fun fun Source #

tqss_type :: forall fun. Lens' (TQSS fun) TQSSType Source #