Package org.powertac.customer.evcharger
Class StorageState
- java.lang.Object
-
- org.powertac.customer.evcharger.StorageState
-
public class StorageState extends Object
Records the current state of a population of EV chargers subscribed to a particular tariff. The code here depends strongly on being called before subscriptions are updated in a given timeslot. In each timeslot over some arbitrary horizon (limited byringArraySize), we keep track of the number of vehicles plugged in (the number of "active" chargers) and the energy committed and not yet delivered in each future timeslot. We assume that vehicles arrive and leave at the beginning of the arrival/departure timeslots. That means they consume energy in the arrival timeslot, but not in the departure timeslot. Energy values are population values, not individual values. Individual values (if needed) are given by the ratio of energy to the number of active chargers at any given time.- Author:
- John Collins
-
-
Constructor Summary
Constructors Constructor Description StorageState(double unitCapacity)Default constructor, used to create a dummy instance.StorageState(TariffSubscription sub, double unitCapacity, int maxHorizon)Normal constructor records the subscription it decorates, specifies the maximum time (in timeslots) that we track.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcollapseElements(int timeslot)Closes out a timeslot by reducing the length of all the population and energy arrays by 1.StorageStatecopy()Returns a copy without sharing structurevoiddistributeDemand(int timeslot, List<org.powertac.customer.evcharger.DemandElement> newDemand, Double ratio)Distributes new demand over time.doubledistributeRegulation(int timeslot, double regulation)Distributes exercised regulation over the horizon starting at timeslot.voiddistributeUsage(int timeslot, double capacity)Distributes energy usage in the current timeslot across the connected EVs.StringgatherState(int timeslot)Gathers and returns a list that represents the current statevoidmoveSubscribers(int timeslotIndex, int count, StorageState oldState)Transfers subscribers from another subscription having the specified StorageState.voidrebalance(int timeslot)static StorageStaterestoreState(double unitCapacity, TariffSubscription sub, int maxHorizon, String input)Restores the current state at the start of a sim session.
-
-
-
Constructor Detail
-
StorageState
public StorageState(double unitCapacity)
Default constructor, used to create a dummy instance. The unitCapacity is the charger capacity in kW. We ignore for now the inefficiency of the charger, which is typically in the 85%-95% range.
-
StorageState
public StorageState(TariffSubscription sub, double unitCapacity, int maxHorizon)
Normal constructor records the subscription it decorates, specifies the maximum time (in timeslots) that we track. This is the maximum interval a user can specify when plugging in, and should cover the large majority of actual cases.
-
-
Method Detail
-
copy
public StorageState copy()
Returns a copy without sharing structure
-
restoreState
public static StorageState restoreState(double unitCapacity, TariffSubscription sub, int maxHorizon, String input)
Restores the current state at the start of a sim session. The record is a list of Strings representing StorageElement instances.
-
moveSubscribers
public void moveSubscribers(int timeslotIndex, int count, StorageState oldState)Transfers subscribers from another subscription having the specified StorageState. Updates the capacityVector accordingly. NOTE that when this is called, the subscriptions themselves have not yet been updated. In other words, it needs to be called in thenotifyCustomer()method, which inTariffEvaluatorhappens beforeupdateSubscriptions()is called. Specifically, this means that the population numbers in the subscriptions themselves have NOT yet been updated whenmoveSubscribers()is called. Maximum demand in each timeslot is the most that can be used. Unless the total remaining commitments are less than what the population of chargers can use in a single timeslot, then it's just the rated demand of the current active chargers. We don't care about maximum demand in future timeslots, just the current one. Minimum demand is the least that can be used in the current timeslot without jeopardizing future commitments.
-
distributeDemand
public void distributeDemand(int timeslot, List<org.powertac.customer.evcharger.DemandElement> newDemand, Double ratio)Distributes new demand over time. Demand for this subscription is the new demand times the ratio of subscribers to the total population, as given byratio. NOTE that this code assumes the newDemand list is sorted by increasing timeslot. It also assumes no constraint violations in the new demand vector.
-
distributeUsage
public void distributeUsage(int timeslot, double capacity)Distributes energy usage in the current timeslot across the connected EVs. All of the demand that's needed by vehicles that will disconnect in this timeslot needs to be covered first. Second is full charger capacity for the vehicles that have no remaining flexibility. The remaining usage is shared evenly across the remaining chargers. After distributing usage, each future timeslot needs to be re-balanced. Note that capacity is the amount for the current subscription, not the total usage for the customer.
-
distributeRegulation
public double distributeRegulation(int timeslot, double regulation)Distributes exercised regulation over the horizon starting at timeslot. Note that a positive number means up-regulation, in which case we need to replace that much energy. NOTE: We must do this before collapsing elements and rebalancing, and before distributing demand because the regulation only applies to the vehicles that were plugged in during the last timeslot when we reported the regulation capacity. We can ignore any commitment in the previous timeslot because we assume that's already been met and those vehicles will already be unplugged. Returns the residue in kWh that could not be accommodated. Return value should always be zero.
-
collapseElements
public void collapseElements(int timeslot)
Closes out a timeslot by reducing the length of all the population and energy arrays by 1. This should work because the last index now needs at most one hour to complete charging, as does the previous index. This must be done in the timeslot following demand and usage distribution, and before re-balancing.
-
rebalance
public void rebalance(int timeslot)
-
gatherState
public String gatherState(int timeslot)
Gathers and returns a list that represents the current state
-
-