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
-
-
Field Summary
-
Fields inherited from class org.powertac.common.interfaces.TimeslotPhaseProcessor
competitionControlService
-
-
Constructor Summary
Constructors Constructor Description AccountingService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidactivate(org.joda.time.Instant time, int phaseNumber)Processes the pending transaction list, computes interest, sends updates to brokersBalancingTransactionaddBalancingTransaction(Broker broker, double kWh, double charge)CapacityTransactionaddCapacityTransaction(Broker broker, int peakTimeslot, double threshold, double kWh, double fee)DistributionTransactionaddDistributionTransaction(Broker broker, int nSmall, int nLarge, double transport, double distroCharge)MarketTransactionaddMarketTransaction(Broker broker, Timeslot timeslot, double mWh, double price)TariffTransactionaddRegulationTransaction(Tariff tariff, CustomerInfo customer, int customerCount, double kWh, double charge)TariffTransactionaddTariffTransaction(TariffTransaction.Type txType, Tariff tariff, CustomerInfo customer, int customerCount, double kWh, double charge)DoublegetBankInterest()Returns the actual bank interest once configuration is complete.doublegetCurrentMarketPosition(Broker broker)Gets the net market position for the current timeslot.doublegetCurrentNetLoad(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.doublegetMaxInterest()Returns the high end of the bank interest range.doublegetMinInterest()Returns the low end of the bank interest range.List<TariffTransaction>getPendingTariffTransactions()Returns the current list of pending tariff transactions.voidhandleMarketTransactionsForTimeslot(Timeslot ts)Processes deferred market transactions for the current timeslot by updating the broker's cash position.Stringinitialize(Competition competition, List<String> completedInits)voidpostBalancingControl(org.powertac.common.msg.BalancingControlEvent bce)voidprocessTransaction(BalancingTransaction tx, ArrayList<Object> messages)Processes a balancing transaction by updating the broker's cash position.voidprocessTransaction(BankTransaction tx, ArrayList<Object> messages)Complains if a bank transaction is among the transactions to be handled.voidprocessTransaction(CapacityTransaction tx, ArrayList<Object> messages)Processes a capacity transaction by updating the broker's cash position.voidprocessTransaction(DistributionTransaction tx, ArrayList<Object> messages)Processes a distribution transaction by updating the broker's cash position.voidprocessTransaction(MarketTransaction tx, ArrayList<Object> messages)Processes a market transaction by ensuring that the market position will be sent to the broker.voidprocessTransaction(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)
- Specified by:
initializein interfaceInitializationService
-
addMarketTransaction
public MarketTransaction addMarketTransaction(Broker broker, Timeslot timeslot, double mWh, double price)
- Specified by:
addMarketTransactionin interfaceAccounting
-
addTariffTransaction
public TariffTransaction addTariffTransaction(TariffTransaction.Type txType, Tariff tariff, CustomerInfo customer, int customerCount, double kWh, double charge)
- Specified by:
addTariffTransactionin interfaceAccounting
-
addRegulationTransaction
public TariffTransaction addRegulationTransaction(Tariff tariff, CustomerInfo customer, int customerCount, double kWh, double charge)
- Specified by:
addRegulationTransactionin interfaceAccounting
-
addDistributionTransaction
public DistributionTransaction addDistributionTransaction(Broker broker, int nSmall, int nLarge, double transport, double distroCharge)
- Specified by:
addDistributionTransactionin interfaceAccounting
-
addBalancingTransaction
public BalancingTransaction addBalancingTransaction(Broker broker, double kWh, double charge)
- Specified by:
addBalancingTransactionin interfaceAccounting
-
addCapacityTransaction
public CapacityTransaction addCapacityTransaction(Broker broker, int peakTimeslot, double threshold, double kWh, double fee)
- Specified by:
addCapacityTransactionin interfaceAccounting
-
postBalancingControl
public void postBalancingControl(org.powertac.common.msg.BalancingControlEvent bce)
- Specified by:
postBalancingControlin 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:
getCurrentNetLoadin 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:
getCurrentSupplyDemandByBrokerin 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:
getCurrentMarketPositionin 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:
activatein interfaceAccounting- Specified by:
activatein 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:
getPendingTariffTransactionsin 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.
-
-