Package org.powertac.accounting
Class AccountingService
- java.lang.Object
-
- org.powertac.common.interfaces.TimeslotPhaseProcessor
-
- org.powertac.accounting.AccountingService
-
- All Implemented Interfaces:
Accounting
,InitializationService
@Service public class AccountingService extends TimeslotPhaseProcessor implements Accounting, InitializationService
Implementation ofAccounting
- Author:
- John Collins
-
-
Constructor Summary
Constructors Constructor Description AccountingService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
activate(org.joda.time.Instant time, int phaseNumber)
Processes the pending transaction list, computes interest, sends updates to brokersBalancingTransaction
addBalancingTransaction(Broker broker, double kWh, double charge)
Adds a balancing transaction to represent the cost of imbalanceCapacityTransaction
addCapacityTransaction(Broker broker, int peakTimeslot, double threshold, double kWh, double fee)
Adds a capacity transaction to represent charges for contribution to a demand peak.DistributionTransaction
addDistributionTransaction(Broker broker, int nSmall, int nLarge, double transport, double distroCharge)
Adds a distribution transaction to represent charges for customer connections and energy transport.MarketTransaction
addMarketTransaction(Broker broker, Timeslot timeslot, double mWh, double price)
Adds a market transaction that includes both a cash component and a product commitment for a specific timeslot.TariffTransaction
addRegulationTransaction(Tariff tariff, CustomerInfo customer, int customerCount, double kWh, double charge)
Adds a tariff transaction representing a curtailment or balancing action to the current-hour transaction list.TariffTransaction
addTariffTransaction(TariffTransaction.Type txType, Tariff tariff, CustomerInfo customer, int customerCount, double kWh, double charge)
Adds a tariff transaction to the current-hour transaction list.Double
getBankInterest()
Returns the actual bank interest once configuration is complete.double
getCurrentMarketPosition(Broker broker)
Gets the net market position for the current timeslot.double
getCurrentNetLoad(Broker broker)
Returns the net load for the given broker in the current timeslot.Map<Broker,Map<TariffTransaction.Type,Double>>
getCurrentSupplyDemandByBroker()
Returns a mapping of brokers to total supply and demand among subscribed customers.double
getMaxInterest()
Returns the high end of the bank interest range.double
getMinInterest()
Returns the low end of the bank interest range.List<TariffTransaction>
getPendingTariffTransactions()
Returns the current list of pending tariff transactions.void
handleMarketTransactionsForTimeslot(Timeslot ts)
Processes deferred market transactions for the current timeslot by updating the broker's cash position.String
initialize(Competition competition, List<String> completedInits)
Initializes a plugin prior to the beginning of a game.void
postBalancingControl(BalancingControlEvent bce)
Updates a broker's cash position resulting from the Balancing Market payment for Demand Response exercise.void
processTransaction(BalancingTransaction tx, ArrayList<Object> messages)
Processes a balancing transaction by updating the broker's cash position.void
processTransaction(BankTransaction tx, ArrayList<Object> messages)
Complains if a bank transaction is among the transactions to be handled.void
processTransaction(CapacityTransaction tx, ArrayList<Object> messages)
Processes a capacity transaction by updating the broker's cash position.void
processTransaction(DistributionTransaction tx, ArrayList<Object> messages)
Processes a distribution transaction by updating the broker's cash position.void
processTransaction(MarketTransaction tx, ArrayList<Object> messages)
Processes a market transaction by ensuring that the market position will be sent to the broker.void
processTransaction(TariffTransaction tx, ArrayList<Object> messages)
Processes a tariff transaction, updating the broker's cash position and the consumption, production data in the distribution report.-
Methods inherited from class org.powertac.common.interfaces.TimeslotPhaseProcessor
init, setTimeslotPhase
-
-
-
-
Method Detail
-
initialize
public String initialize(Competition competition, List<String> completedInits)
Description copied from interface:InitializationService
Initializes a plugin prior to the beginning of a game. The completedInits parameter is the list of plugin role names that have been successfully initialized. If sequence dependencies are satisfied (or if there are no sequence dependencies), then an implementation must complete its pre-game initialization process and return its role name. If sequence dependencies are not satisfied, then an implementation must return null. It will be called again after additional successful initializations have been completed. If initialization is not possible, then returning the string 'fail' will cause the server to log an error and shut down. This will be helpful just in case the implementation also logs a detailed error message.- Specified by:
initialize
in interfaceInitializationService
-
addMarketTransaction
public MarketTransaction addMarketTransaction(Broker broker, Timeslot timeslot, double mWh, double price)
Description copied from interface:Accounting
Adds a market transaction that includes both a cash component and a product commitment for a specific timeslot.- Specified by:
addMarketTransaction
in interfaceAccounting
-
addTariffTransaction
public TariffTransaction addTariffTransaction(TariffTransaction.Type txType, Tariff tariff, CustomerInfo customer, int customerCount, double kWh, double charge)
Description copied from interface:Accounting
Adds a tariff transaction to the current-hour transaction list.- Specified by:
addTariffTransaction
in interfaceAccounting
-
addRegulationTransaction
public TariffTransaction addRegulationTransaction(Tariff tariff, CustomerInfo customer, int customerCount, double kWh, double charge)
Description copied from interface:Accounting
Adds a tariff transaction representing a curtailment or balancing action to the current-hour transaction list.- Specified by:
addRegulationTransaction
in interfaceAccounting
-
addDistributionTransaction
public DistributionTransaction addDistributionTransaction(Broker broker, int nSmall, int nLarge, double transport, double distroCharge)
Description copied from interface:Accounting
Adds a distribution transaction to represent charges for customer connections and energy transport.- Specified by:
addDistributionTransaction
in interfaceAccounting
-
addBalancingTransaction
public BalancingTransaction addBalancingTransaction(Broker broker, double kWh, double charge)
Description copied from interface:Accounting
Adds a balancing transaction to represent the cost of imbalance- Specified by:
addBalancingTransaction
in interfaceAccounting
-
addCapacityTransaction
public CapacityTransaction addCapacityTransaction(Broker broker, int peakTimeslot, double threshold, double kWh, double fee)
Description copied from interface:Accounting
Adds a capacity transaction to represent charges for contribution to a demand peak. One is generated for each peak event.- Specified by:
addCapacityTransaction
in interfaceAccounting
peakTimeslot
- when the peak occurredthreshold
- assessment thresholdkWh
- total net demand among broker's customers during timeslotfee
- assessed capacity fee for this peak event
-
postBalancingControl
public void postBalancingControl(BalancingControlEvent bce)
Description copied from interface:Accounting
Updates a broker's cash position resulting from the Balancing Market payment for Demand Response exercise.- Specified by:
postBalancingControl
in interfaceAccounting
-
getCurrentNetLoad
public double getCurrentNetLoad(Broker broker)
Returns the net load for the given broker in the current timeslot. Note that this only works AFTER the customer models have run, and BEFORE the day's transactions have been processed. The value will be negative if the broker's customers are consuming more than they produce in the current timeslot.- Specified by:
getCurrentNetLoad
in interfaceAccounting
-
getCurrentSupplyDemandByBroker
public Map<Broker,Map<TariffTransaction.Type,Double>> getCurrentSupplyDemandByBroker()
Returns a mapping of brokers to total supply and demand among subscribed customers.- Specified by:
getCurrentSupplyDemandByBroker
in interfaceAccounting
-
getCurrentMarketPosition
public double getCurrentMarketPosition(Broker broker)
Gets the net market position for the current timeslot. This only works on processed transactions, but it can be used before activation in case there can be no new market transactions for the current timeslot. This is the normal case. The value will be positive if the broker is importing power during the current timeslot.- Specified by:
getCurrentMarketPosition
in interfaceAccounting
-
activate
public void activate(org.joda.time.Instant time, int phaseNumber)
Processes the pending transaction list, computes interest, sends updates to brokers- Specified by:
activate
in interfaceAccounting
- Specified by:
activate
in classTimeslotPhaseProcessor
-
processTransaction
public void processTransaction(TariffTransaction tx, ArrayList<Object> messages)
Processes a tariff transaction, updating the broker's cash position and the consumption, production data in the distribution report.
-
processTransaction
public void processTransaction(BalancingTransaction tx, ArrayList<Object> messages)
Processes a balancing transaction by updating the broker's cash position.
-
processTransaction
public void processTransaction(DistributionTransaction tx, ArrayList<Object> messages)
Processes a distribution transaction by updating the broker's cash position.
-
processTransaction
public void processTransaction(CapacityTransaction tx, ArrayList<Object> messages)
Processes a capacity transaction by updating the broker's cash position.
-
processTransaction
public void processTransaction(MarketTransaction tx, ArrayList<Object> messages)
Processes a market transaction by ensuring that the market position will be sent to the broker. Actual transaction posting is deferred to delivery time
-
handleMarketTransactionsForTimeslot
public void handleMarketTransactionsForTimeslot(Timeslot ts)
Processes deferred market transactions for the current timeslot by updating the broker's cash position.
-
processTransaction
public void processTransaction(BankTransaction tx, ArrayList<Object> messages)
Complains if a bank transaction is among the transactions to be handled. These should be generated locally and sent directly to brokers.
-
getPendingTariffTransactions
public List<TariffTransaction> getPendingTariffTransactions()
Returns the current list of pending tariff transactions. This will be non-empty only after the customer model has run and before accounting has run in the current timeslot.- Specified by:
getPendingTariffTransactions
in interfaceAccounting
-
getMinInterest
public double getMinInterest()
Returns the low end of the bank interest range.
-
getMaxInterest
public double getMaxInterest()
Returns the high end of the bank interest range.
-
getBankInterest
public Double getBankInterest()
Returns the actual bank interest once configuration is complete.
-
-