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 void
activate(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.Tariff
getDefaultTariff(PowerType type)
Returns the default tariffdouble
getMaxPublicationFee()
double
getMaxRevocationFee()
double
getMinPublicationFee()
double
getMinRevocationFee()
Double
getPublicationFee()
int
getPublicationInterval()
int
getPublicationOffset()
Double
getRevocationFee()
void
handleMessage(BalancingOrder msg)
Processes an incoming BalancingOrder by storing it in the tariffRepo.void
handleMessage(EconomicControlEvent msg)
Processes an incoming ControlEvent from a brokervoid
handleMessage(TariffExpire update)
Handles changes in tariff expiration date.void
handleMessage(TariffRevoke update)
Handles tariff revocation.void
handleMessage(VariableRateUpdate update)
Applies a new HourlyCharge to an existing Tariff with a variable Rate.void
handleMessage(TariffSpecification spec)
Processes a newly-published tariff.String
initialize(Competition competition, List<String> completedInits)
Reads configuration parameters, registers for timeslot phase activation.void
processRevokedTariffs()
Runs through the list of pending tariff revocations, marking the tariffs and their subscriptions.void
registerNewTariffListener(NewTariffListener listener)
Registers a listener for publication of new Tariffs.boolean
setDefaultTariff(TariffSpecification newSpec)
Convenience method to set the default tariff at the beginning of the game.void
setPublicationInterval(int interval)
void
setPublicationOffset(int offset)
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.-
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:
initialize
in 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:
processRevokedTariffs
in interfaceTariffMarket
-
registerNewTariffListener
public void registerNewTariffListener(NewTariffListener listener)
Description copied from interface:TariffMarket
Registers a listener for publication of new Tariffs.- Specified by:
registerNewTariffListener
in interfaceTariffMarket
-
activate
public void activate(org.joda.time.Instant time, int phase)
Description copied from class:TimeslotPhaseProcessor
This 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:
activate
in classTimeslotPhaseProcessor
-
getActiveTariffList
public List<Tariff> getActiveTariffList(PowerType type)
Description copied from interface:TariffMarket
Returns the list of currently active tariffs for the given PowerType. The list contains only non-expired tariffs that cover the given type.- Specified by:
getActiveTariffList
in interfaceTariffMarket
-
getDefaultTariff
public Tariff getDefaultTariff(PowerType type)
Returns the default tariff- Specified by:
getDefaultTariff
in interfaceTariffMarket
-
setDefaultTariff
public boolean setDefaultTariff(TariffSpecification newSpec)
Description copied from interface:TariffMarket
Convenience 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:
setDefaultTariff
in 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:
subscribeToTariff
in interfaceTariffMarket
-
-