Safe Haskell | None |
---|---|
Language | Haskell2010 |
ProductMixAuction.LP.Core
Description
Describes the basic structure of auctions and implements the translation into a linear programme. This does not include features that require multiple LP runs, such as the TQSS.
- data Auction bid = Auction {}
- data TotalSizeLimit
- = FixedLimit Units
- | TQSSLimit [Step Units]
- mkAuction :: Supply Units -> [Bid bid] -> Auction bid
- defaultPreferences :: Supply Units -> [Good]
- auctionBidLabels :: Auction bid -> [bid]
- auctionGoodLabels :: Auction bid -> [Good]
- lookupBid :: Eq bid => bid -> Auction bid -> Maybe (Bid bid)
- showAuction :: Show bid => Auction bid -> String
- mapAuction :: Ord bid' => (bid -> bid') -> Auction bid -> Auction bid'
- data AuctionResult bid = AuctionResult {
- _ar_prices :: Map Good Price
- _ar_quantities :: Map (AVar bid) Units
- _ar_normalised_price :: Maybe Price
- data AVar bid
- = AllocVar bid Good
- | ExtraAllocVar Good
- | StepVar Good Int
- | TQSSStepVar Int
- runAuctionCore :: Goodly bid => String -> Auction bid -> IO (AuctionResult bid)
- type Goodly x = (Ord x, Show x, Read x)
- data AuctionException
- = GLPKFailed ReturnCode
- | SupplyCurveDecreasing Good
- | TQSSDecreasing
- | TQSSEmpty
- | TQSSMinAboveMax Units Units
- | TQSSGoodMissing Good
- | TQSSBadLambda
- | TQSSFirstStepNonZero
- | TQSSFirstStepTooSmall Units Units
- | TQSSNormalisedNotHorizontal
- | MaxProfitComplexBid
- | MaxProfitNotHorizontal
- | MaxProfitTQSS
- | MaxProfitNoSolution
- auction_supply :: forall bid. Lens' (Auction bid) (Supply Units)
- auction_bids :: forall bid. Lens' (Auction bid) [Bid bid]
- auction_scale :: forall bid. Lens' (Auction bid) ScaleFactor
- auction_preferences :: forall bid. Lens' (Auction bid) [Good]
- auction_constraints :: forall bid. Lens' (Auction bid) [AdditionalConstraint bid]
- auction_size_limit :: forall bid. Lens' (Auction bid) (Maybe TotalSizeLimit)
- auction_tweak_supply :: forall bid. Lens' (Auction bid) Bool
- auction_verbosity :: forall bid. Lens' (Auction bid) Verbosity
- ar_prices :: forall bid. Lens' (AuctionResult bid) (Map Good Price)
- ar_quantities :: forall bid bid. Lens (AuctionResult bid) (AuctionResult bid) (Map (AVar bid) Units) (Map (AVar bid) Units)
- ar_normalised_price :: forall bid. Lens' (AuctionResult bid) (Maybe Price)
Core auction representation
Represents an auction that can be translated directly into a single run of a linear program.
Constructors
Auction | |
Fields
|
data TotalSizeLimit Source #
Limit on the total quantity allocated by an auction, for use implementing a TQSS.
Constructors
FixedLimit Units | Limit the total quantity allocated to a constant. |
TQSSLimit [Step Units] | Limit the total quantity allocated by the given TQSS steps. |
mkAuction :: Supply Units -> [Bid bid] -> Auction bid Source #
Smart constructor for auctions, given a description of the supply curves and a list of bids, using sensible defaults for the other fields.
defaultPreferences :: Supply Units -> [Good] Source #
By default, the preference permutation for the supply lists the goods in reverse order, so that the highest good is most preferred.
auctionBidLabels :: Auction bid -> [bid] Source #
List labels of bids in the auction.
auctionGoodLabels :: Auction bid -> [Good] Source #
List labels of goods in the auction, in no particular order.
lookupBid :: Eq bid => bid -> Auction bid -> Maybe (Bid bid) Source #
Look up a bid in the auction by its label.
showAuction :: Show bid => Auction bid -> String Source #
Render an auction in a vaugely human-readable format.
Results
data AuctionResult bid Source #
Results from a single run of the LP, including a price for each good and a quantity value for each primal variable.
Constructors
AuctionResult | |
Fields
|
Instances
Show bid => Show (AuctionResult bid) Source # | |
Variables used in the linear program corresponding to an auction.
Constructors
AllocVar bid Good |
|
ExtraAllocVar Good |
|
StepVar Good Int |
|
TQSSStepVar Int |
|
Solving a single auction LP
runAuctionCore :: Goodly bid => String -> Auction bid -> IO (AuctionResult bid) Source #
Convert the auction description to a linear program, solve it using GLPK and return the results.
Utilities
type Goodly x = (Ord x, Show x, Read x) Source #
Constraints that must be satisfied by the bid label types.
data AuctionException Source #
Errors that can be thrown when solving an auction
Constructors
GLPKFailed ReturnCode | LP solver failed to produce a result, with the given return code |
SupplyCurveDecreasing Good | Good with the given label has a decreasing supply curve |
TQSSDecreasing | TQSS step function is decreasing |
TQSSEmpty | TQSS has no steps |
TQSSMinAboveMax Units Units | Lower bound of TQSS search exceeds upper bound |
TQSSGoodMissing Good | Single-good TQSS refers to a good not in the auction |
TQSSBadLambda | Non-vertical auction with a non-zero supply scale lambda |
TQSSFirstStepNonZero | First TQSS step has a non-zero price |
TQSSFirstStepTooSmall Units Units | First TQSS step smaller than initial auction size |
TQSSNormalisedNotHorizontal | Normalised prices used with a non-horizontal TQSS |
MaxProfitComplexBid | Maximising profitability used with a generalised or asymmetric bid |
MaxProfitNotHorizontal | Maximising profitability used with a non-horizontal TQSS |
MaxProfitTQSS | Maximising profitability used with a TQSS |
MaxProfitNoSolution | No solution when maximising profitability |
Instances
Lenses
auction_bids :: forall bid. Lens' (Auction bid) [Bid bid] Source #
auction_scale :: forall bid. Lens' (Auction bid) ScaleFactor Source #
auction_preferences :: forall bid. Lens' (Auction bid) [Good] Source #
auction_constraints :: forall bid. Lens' (Auction bid) [AdditionalConstraint bid] Source #
auction_size_limit :: forall bid. Lens' (Auction bid) (Maybe TotalSizeLimit) Source #
auction_tweak_supply :: forall bid. Lens' (Auction bid) Bool Source #
auction_verbosity :: forall bid. Lens' (Auction bid) Verbosity Source #
ar_quantities :: forall bid bid. Lens (AuctionResult bid) (AuctionResult bid) (Map (AVar bid) Units) (Map (AVar bid) Units) Source #
ar_normalised_price :: forall bid. Lens' (AuctionResult bid) (Maybe Price) Source #