Package org.powertac.tariffmarket
Class TariffMarketService
- java.lang.Object
-
- org.powertac.common.interfaces.TimeslotPhaseProcessor
-
- org.powertac.tariffmarket.TariffMarketService
-
- All Implemented Interfaces:
InitializationService,TariffMarket
@Service public class TariffMarketService extends TimeslotPhaseProcessor implements TariffMarket, InitializationService
Implements the Tariff Market abstraction. Incoming tariff-related messages from brokers are received and processed, tariffs are published periodically, and subscriptions are processed on behalf of customers.- Author:
- John Collins
-
-
Constructor Summary
Constructors Constructor Description TariffMarketService()Default constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidactivate(org.joda.time.Instant time, int phase)This method gets called once during each timeslot.List<Tariff>getActiveTariffList(PowerType type)Returns the list of currently active tariffs for the given PowerType.TariffgetDefaultTariff(PowerType type)Returns the default tariffdoublegetMaxPublicationFee()doublegetMaxRevocationFee()doublegetMinPublicationFee()doublegetMinRevocationFee()DoublegetPublicationFee()intgetPublicationInterval()intgetPublicationOffset()DoublegetRevocationFee()voidhandleMessage(BalancingOrder msg)Processes an incoming BalancingOrder by storing it in the tariffRepo.voidhandleMessage(EconomicControlEvent msg)Processes an incoming ControlEvent from a brokervoidhandleMessage(TariffExpire update)Handles changes in tariff expiration date.voidhandleMessage(TariffRevoke update)Handles tariff revocation.voidhandleMessage(VariableRateUpdate update)Applies a new HourlyCharge to an existing Tariff with a variable Rate.voidhandleMessage(TariffSpecification spec)Processes a newly-published tariff.Stringinitialize(Competition competition, List<String> completedInits)Reads configuration parameters, registers for timeslot phase activation.voidprocessRevokedTariffs()Runs through the list of pending tariff revocations, marking the tariffs and their subscriptions.voidregisterNewTariffListener(NewTariffListener listener)Registers a listener for publication of new Tariffs.booleansetDefaultTariff(TariffSpecification newSpec)Convenience method to set the default tariff at the beginning of the game.voidsetPublicationInterval(int interval)voidsetPublicationOffset(int offset)voidsubscribeToTariff(Tariff tariff, CustomerInfo customer, int customerCount)If customerCount is positive, subscribes a block of Customers from a single Customer model to the specified Tariff, as long as the Tariff is not expired or revoked.-
Methods inherited from class org.powertac.common.interfaces.TimeslotPhaseProcessor
init, setTimeslotPhase
-
-
-
-
Method Detail
-
initialize
public String initialize(Competition competition, List<String> completedInits)
Reads configuration parameters, registers for timeslot phase activation.- Specified by:
initializein interfaceInitializationService
-
getMinPublicationFee
public double getMinPublicationFee()
-
getMaxPublicationFee
public double getMaxPublicationFee()
-
getPublicationFee
public Double getPublicationFee()
-
getMinRevocationFee
public double getMinRevocationFee()
-
getMaxRevocationFee
public double getMaxRevocationFee()
-
getRevocationFee
public Double getRevocationFee()
-
getPublicationInterval
public int getPublicationInterval()
-
setPublicationInterval
@ConfigurableValue(valueType="Integer", description="Number of timeslots between tariff publication events. Must be at most 24.") public void setPublicationInterval(int interval)
-
getPublicationOffset
public int getPublicationOffset()
-
setPublicationOffset
@ConfigurableValue(valueType="Integer", description="Number of timeslots from the first timeslot to delay the first publication event. It does not work well to make this zero, because brokers do not have an opportunity to post tariffs in timeslot 0.") public void setPublicationOffset(int offset)
-
handleMessage
public void handleMessage(TariffSpecification spec)
Processes a newly-published tariff.
-
handleMessage
public void handleMessage(TariffExpire update)
Handles changes in tariff expiration date.
-
handleMessage
public void handleMessage(TariffRevoke update)
Handles tariff revocation.
-
handleMessage
public void handleMessage(VariableRateUpdate update)
Applies a new HourlyCharge to an existing Tariff with a variable Rate.
-
handleMessage
public void handleMessage(EconomicControlEvent msg)
Processes an incoming ControlEvent from a broker
-
handleMessage
public void handleMessage(BalancingOrder msg)
Processes an incoming BalancingOrder by storing it in the tariffRepo. Balancing orders can be used for interruptible tariffs, but not in the presence of RegulationRates. For tariffs with RegulationRates, the BalancingOrders are automatically constructed from the RRs. In other words, BalancingOrders can be used to permit up-regulation through curtailment, but not if the customer expects to be paid for the balancing events.
-
processRevokedTariffs
public void processRevokedTariffs()
Runs through the list of pending tariff revocations, marking the tariffs and their subscriptions.- Specified by:
processRevokedTariffsin interfaceTariffMarket
-
registerNewTariffListener
public void registerNewTariffListener(NewTariffListener listener)
Description copied from interface:TariffMarketRegisters a listener for publication of new Tariffs.- Specified by:
registerNewTariffListenerin interfaceTariffMarket
-
activate
public void activate(org.joda.time.Instant time, int phase)Description copied from class:TimeslotPhaseProcessorThis method gets called once during each timeslot. To get called, the module must first call the register(phaseNumber) method on CompetitionControl. The call will give the current simulation time and phase number in the arguments.- Specified by:
activatein classTimeslotPhaseProcessor
-
getActiveTariffList
public List<Tariff> getActiveTariffList(PowerType type)
Description copied from interface:TariffMarketReturns the list of currently active tariffs for the given PowerType. The list contains only non-expired tariffs that cover the given type.- Specified by:
getActiveTariffListin interfaceTariffMarket
-
getDefaultTariff
public Tariff getDefaultTariff(PowerType type)
Returns the default tariff- Specified by:
getDefaultTariffin interfaceTariffMarket
-
setDefaultTariff
public boolean setDefaultTariff(TariffSpecification newSpec)
Description copied from interface:TariffMarketConvenience method to set the default tariff at the beginning of the game. Returns true just in case the tariff was valid and was successfully saved.- Specified by:
setDefaultTariffin interfaceTariffMarket
-
subscribeToTariff
public void subscribeToTariff(Tariff tariff, CustomerInfo customer, int customerCount)
If customerCount is positive, subscribes a block of Customers from a single Customer model to the specified Tariff, as long as the Tariff is not expired or revoked. If customerCount is negative, unsubscribes a block of customers from the specified tariff. Processing is deferred unless the customer has no subscriptions, which should only be true at the start of a boot or sim session.Note that you cannot unsubscribe directly from a Tariff -- you have to do that from the TariffSubscription that represents the Tariff you want to unsubscribe from.
- Specified by:
subscribeToTariffin interfaceTariffMarket
-
-