Safe Haskell | None |
---|---|
Language | Haskell2010 |
ProductMixAuction.LP.TQSS
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.
- data TQSS fun = TQSS {
- _tqss_fun :: fun
- _tqss_type :: TQSSType
- data TQSSType
- data AbsoluteTQSS = AbsoluteTQSS {}
- data TQSSPriceMeasure
- data TQSSScale
- type TQSSFun = Double -> Units
- type TQSSTable = [TQSSStep]
- type TQSSStep = Step Units
- data TQSSSearchMode
- type TQSSSearchStrategy = forall bid. Goodly bid => TQSSFun -> AbsoluteTQSS -> Maybe [Step Units] -> Auction bid -> IO [TQSSPoint]
- data TQSSPoint = TQSSPoint {}
- runTQSS :: Goodly bid => Auction bid -> TQSS TQSSTable -> IO (Auction bid, AuctionResult bid, Units, Maybe [TQSSPoint])
- runNormalisedTQSS :: Goodly bid => Auction bid -> TQSSTable -> IO (Auction bid, AuctionResult bid, Units, Maybe a)
- runAbsoluteTQSS :: Goodly bid => Auction bid -> Maybe [TQSSStep] -> TQSSFun -> AbsoluteTQSS -> IO (Auction bid, AuctionResult bid, Units, Maybe [TQSSPoint])
- interpolateTQSS :: TQSS TQSSTable -> TQSS TQSSFun
- isNondecreasingTQSSTable :: TQSSTable -> Bool
- isConstrainedTQSS :: TQSS fun -> Bool
- tqssTypeLabel :: TQSSType -> Text
- tqss_fun :: forall fun fun. Lens (TQSS fun) (TQSS fun) fun fun
- tqss_type :: forall fun. Lens' (TQSS fun) TQSSType
- atqss_price_measure :: Lens' AbsoluteTQSS TQSSPriceMeasure
- atqss_search :: Lens' AbsoluteTQSS TQSSSearchMode
- atqss_scale :: Lens' AbsoluteTQSS TQSSScale
- atqss_min_bound :: Lens' AbsoluteTQSS (Maybe Units)
- atqss_max_bound :: Lens' AbsoluteTQSS (Maybe Units)
- atqss_step_size :: Lens' AbsoluteTQSS (Maybe Units)
- tqp_demand_target :: Lens' TQSSPoint Units
- tqp_demand :: Lens' TQSSPoint Units
- tqp_price :: Lens' TQSSPoint Double
- tqp_supply :: Lens' TQSSPoint Units
TQSS representation
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
|
Constructors
TQSSAbsolute AbsoluteTQSS | |
TQSSNormalised |
data AbsoluteTQSS Source #
Constructors
AbsoluteTQSS | |
Fields
|
Instances
Eq AbsoluteTQSS Source # | |
Show AbsoluteTQSS Source # | |
Generic AbsoluteTQSS Source # | |
ToJSON AbsoluteTQSS Source # | |
FromJSON AbsoluteTQSS Source # | |
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. |
Instances
Eq TQSSPriceMeasure Source # | |
Show TQSSPriceMeasure Source # | |
Generic TQSSPriceMeasure Source # | |
ToJSON TQSSPriceMeasure Source # | |
FromJSON TQSSPriceMeasure Source # | |
Default TQSSPriceMeasure Source # | |
type Rep TQSSPriceMeasure 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 |
AddConstraint | Do not change the supply curves, but add a constraint to the LP bounding the total quantity supplied. |
type TQSSFun = Double -> Units Source #
Representation of a TQSS function as a Haskell function from the price measure to the number of units.
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 |
Instances
Eq TQSSSearchMode Source # | |
Show TQSSSearchMode Source # | |
Generic TQSSSearchMode Source # | |
ToJSON TQSSSearchMode Source # | |
FromJSON TQSSSearchMode Source # | |
Default TQSSSearchMode Source # | |
type Rep TQSSSearchMode Source # | |
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
A point at which the TQSS has been evaluated.
Constructors
TQSSPoint | |
Fields
|
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
atqss_search :: Lens' AbsoluteTQSS TQSSSearchMode Source #
atqss_scale :: Lens' AbsoluteTQSS TQSSScale Source #
atqss_min_bound :: Lens' AbsoluteTQSS (Maybe Units) Source #
atqss_max_bound :: Lens' AbsoluteTQSS (Maybe Units) Source #
atqss_step_size :: Lens' AbsoluteTQSS (Maybe Units) Source #
tqp_demand_target :: Lens' TQSSPoint Units Source #
tqp_demand :: Lens' TQSSPoint Units Source #
tqp_supply :: Lens' TQSSPoint Units Source #