Class Activity
- java.lang.Object
-
- org.powertac.evcustomer.beans.Activity
-
public class Activity extends Object
Represents an activity that involves driving a vehicle. Some activities involve driving for some distance and returning to the departure point; these have aninterval
value of 0. If theinterval
value is greater than zero, then the activity involves two trips, out and back. At the destination, there may or may not be a charger available, as determined by theawayChargerProbability
. The distance to be driven is determined by the associatedGroupActivity
. When scheduling activities, it is important to schedule the activities first that have the longest intervals, so they may be nested.The probability of an activity happening at all is controlled by the "day probability" as determined either by the pair
weekdayWeight
andweekendWeight
(both of which default to 1) or by theweeklyProfile
which is expected to have an entry for each of the seven days in a week. Once it is decided that an activity should be scheduled, the time (one-hour granularity for now) is determined by thedailyProfile
.Activities are added to a daily schedule one at a time, starting with the activities having the greatest
interval
. Calls topickTimeslot()
must supply a 24-element array of Activities representing those already scheduled. The array will then be updated by the call. If the customer sleeps from 23:00-6:00, then those timeslots must be pre-filled with dummy Activity instances. When called,pickTimeslot
will first determine whether to attempt to schedule the activity based on the day probability. Second, if this Activity has a non-zerointerval
, all slots that do not allow for the return trip will be eliminated. Finally, it will normalize the remaining unscheduled slots in the daily profile and pick one. If there are two trips, the same activity will be populated in both the outgoing and returning position. The caller is responsible for keeping track of whether charging is available between trips.- Author:
- Govert Buijs, John Collins
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description double
getChargerProbability()
List<String>
getDailyProfile()
Optional<double[]>
getDailyProfileOptional()
Returns an Optional containing the daily profile if it existsdouble
getDayProbability(int dayOfWeek)
Returns the probability of doing this activity on the given day, driven either by weekend/weekday probabilities, or by the weekly profile.double
getDayWeight(int day)
int
getId()
int
getInterval()
If zero, then this is an out-and-back trip within a single timeslot.String
getName()
double
getProbabilityForTimeslot(int slot)
double
getWeekdayWeight()
double
getWeekendWeight()
List<String>
getWeeklyProfile()
Optional<double[]>
getWeeklyProfileOptional()
Returns an Optional containing the weekly profile if it exists.void
setChargerProbability(double prob)
void
setDailyProfile(List<String> value)
void
setId(int value)
void
setInterval(int value)
void
setWeeklyProfile(List<String> value)
-
-
-
Constructor Detail
-
Activity
public Activity()
Default constructor, needed for wrapper classes
-
Activity
public Activity(String name)
Normal constructor, usable by auto-config
-
-
Method Detail
-
getDayWeight
public double getDayWeight(int day)
-
getId
public int getId()
-
getName
public String getName()
-
getChargerProbability
public double getChargerProbability()
-
setChargerProbability
public void setChargerProbability(double prob)
-
getInterval
public int getInterval()
If zero, then this is an out-and-back trip within a single timeslot. If one, then this is two trips in sequential timeslots, without an opportunity to charge.
-
getWeekdayWeight
public double getWeekdayWeight()
-
getWeekendWeight
public double getWeekendWeight()
-
setWeeklyProfile
@ConfigurableValue(valueType="List", dump=false, description="When this activity might start") public void setWeeklyProfile(List<String> value)
-
getWeeklyProfileOptional
public Optional<double[]> getWeeklyProfileOptional()
Returns an Optional containing the weekly profile if it exists.
-
setDailyProfile
@ConfigurableValue(valueType="List", dump=false, description="When this activity might start") public void setDailyProfile(List<String> value)
-
getDailyProfileOptional
public Optional<double[]> getDailyProfileOptional()
Returns an Optional containing the daily profile if it exists
-
getDayProbability
public double getDayProbability(int dayOfWeek)
Returns the probability of doing this activity on the given day, driven either by weekend/weekday probabilities, or by the weekly profile.
-
getProbabilityForTimeslot
public double getProbabilityForTimeslot(int slot)
-
setInterval
public void setInterval(int value)
-
setId
public void setId(int value)
-
-