Publish Tariff - Pyosch/powertac-server GitHub Wiki

up

For whatever reason, a Broker decides to offer a new Tariff:

  1. Broker creates a new TariffSpecification instance, along with the associated Rates.
  2. For any Rates that are not fixed, HourlyCharge instances must be included into the future at least as far as the notification interval.
  3. Broker sends serialized TariffSpecification (the serialization process should suck in the Rates and HourlyCharge instances, along with the Broker's ID) to server.
  4. Incoming TariffSpecifications are routed to the AccountingService, which does the following:
    1. 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.
    2. Creates a new TariffTransaction on the current timeslot for the tariff, representing the charge for publishing the Tariff to customers.
    3. 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.
  5. 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.
  6. New Tariffs are published to all Brokers, by the Accounting Service.
  7. 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.
  8. 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.
⚠️ **GitHub.com Fallback** ⚠️