Skip to content

Extension points

tilttek/math-trade

The package is at 0.x: its extension points are stable only from its 1.0 release. Until then, a minor version may change them, and its CHANGELOG says how.

PointWhat an application givesDefault
LimitsThe size of the lists it accepts2 000 participants, 5 000 offers, 100 per participant, 500 wishes per offer, 100 offers per group, 250 000 wished offers, 8 MiB of JSON
The identifiersIts own identifiers of participants, offers and gamesNone
The seedThe text that breaks ties, announced or drawn by the applicationNone

The library has no interface to implement: the trade list, the limits and the result are values, and TradeSolver and TradeListJson keep no state between two calls.

Limits

The solver's time grows with the number of offers and of wished offers — see Testing —, so every list is checked against its limits before it is solved, and a JSON document against its length before it is decoded. An application that solves larger trades raises them; one that accepts uploads from anyone lowers them.

use Tilttek\MathTrade\Limits;

$limits = new Limits(
    participants: 500,
    offers: 2_000,
    offersPerParticipant: 20,
    wishesPerOffer: 200,
    groupSize: 50,
    wishedOffers: 100_000,
    jsonBytes: 1_048_576,
);
LimitCountsCeiling
participantsThe participants of the list100 000
offersThe offers of the list100 000
offersPerParticipantThe offers of one participant100 000
wishesPerOfferThe lines of one offer's wish list, a group counted once10 000
groupSizeThe offers of one group of wishes10 000
wishedOffersThe wished offers of the whole list, each offer of a group counted5 000 000
jsonBytesThe length of a JSON document the list is read from256 MiB

Each limit is 1 to its ceiling; another value is refused with an InvalidTradeList.

What stays in the application

  • Collecting the lists. A form, a spreadsheet import or a wish-list generator builds the TradeList, or the JSON document of the format.
  • The seed. The application announces it before the lists close, or draws it in public afterwards, and publishes it beside the result.
  • Names and addresses. The library works on identifiers. The application shows each participant the address of the one they send to once the trade is confirmed, never before.
  • The parcels. Following what was sent and received, and the participants who did not send, is the application's.