Class 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 an interval value of 0. If the interval 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 the awayChargerProbability. The distance to be driven is determined by the associated GroupActivity. 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 and weekendWeight (both of which default to 1) or by the weeklyProfile 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 the dailyProfile.

    Activities are added to a daily schedule one at a time, starting with the activities having the greatest interval. Calls to pickTimeslot() 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-zero interval, 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
    • 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()
      • getWeeklyProfile

        public List<String> getWeeklyProfile()
      • getWeeklyProfileOptional

        public Optional<double[]> getWeeklyProfileOptional()
        Returns an Optional containing the weekly profile if it exists.
      • getDailyProfile

        public List<String> getDailyProfile()
      • 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)