Publish tariff - Pyosch/powertac-server GitHub Wiki
For whatever reason, a Broker decides to offer a new Tariff:
- Broker creates a new TariffSpecification instance, along with the associated Rates.
- For any Rates that are not fixed, HourlyCharge instances must be included into the future at least as far as the notification interval.
- Broker sends serialized TariffSpecification (the serialization process should suck in the Rates and HourlyCharge instances, along with the Broker's ID) to server.
- Incoming TariffSpecifications are routed to the AccountingService, which does the following:
- Invokes the TariffRuleEnforcer to validate the new Tariff. If the incoming TariffSpecification does not validate, an error is returned to the Broker and the process ends.
- Creates a new TariffTransaction on the current timeslot for the tariff, representing the charge for publishing the Tariff to customers.
- Creates a Tariff instance to wrap the TariffSpecification and track its activity (publication date and realized price, for example), and stores both in the database.
- If the new Tariff contains a list of existing Tariffs that are to be superseded, those Tariffs must be updated with the supersededBy field. This is done by the new Tariff in its init() method.
- New Tariffs are published to all Brokers, by the Accounting Service.
- Every 6 hours (sim time), Customers look at the available Tariffs (by querying the database) and may decide to switch some of their subscriptions. Note that each Customer (or each individual in a population model) must always have a subscription to some Tariff. This activity can be triggered by posting periodic actions on the TimeService queue, and does not require interaction with the Accounting Service.
- Subscription and Unsubscription events can lead to credits or debits for the customers. These are handled by creating TariffTransaction objects attached to the current timeslot. The AccountingService will eventually retrieve the list of transactions for the current timeslot, process the cash transactions, and forward them to the broker.