Class RoundTripGenerator

All Implemented Interfaces:
CondObserver<Condition,Actor>, NamedObjectOps

public class RoundTripGenerator extends TripGenerator
Trip generator trips between two hubs given Poisson traffic, A specified number of bicycles per trip, a starting hub and a set of destination hubs, the probabilities for using a given destination, and the probabilities for each destination of using the overflow area. There is additionally a random variable providing the waiting time before the return trip.

Many trips in practice will be individual trips, but some trips may be made a groups of people traveling together. To account for these trips, RoundTripGenerator allows one to specify the number of bicycles taken for a trip (one can create different trip generators for each number of bicycles that one expects to see). The generator assumes that bicycles are picked up at a hub's preferred location, and that a fraction of the trips will always use a hub's overflow area.

  • Constructor Details

    • RoundTripGenerator

      public RoundTripGenerator(DramaSimulation sim, String name, boolean intern)
      Constructor.
      Parameters:
      sim - the simulation
      name - the name of this object
      intern - true if this object should be interned in the simulation's name table; false otherwise
  • Method Details

    • setMean

      public void setMean(double mean)
      Set the mean interarrival time for trips. This method will stop the traffic generator, change the mean interarrival time, and restart the traffic generator. Correct operation is dependent on Poission traffic being memoryless: calling stop() followed by restart() has no effect on the statisitical distribution of the trips' starting times.
      Parameters:
      mean - the mean interarrival time in seconds
    • getMean

      public double getMean()
      Get the mean interarrival time for trips.
      Returns:
      the mean interarrival time in seconds
    • setWaitRV

      public void setWaitRV(DoubleRandomVariable waitrv)
      Set the time interval between arriving at a destination and starting a return trip.
      Parameters:
      waitrv - a random variable giving the time interval in seconds
    • setReturnOverflowProb

      public void setReturnOverflowProb(double p)
      Set the probability of using the starting hub's overflow area at the end of a return trip.
      Parameters:
      p - the probability
    • init

      public void init(Hub hub, double mean, int nbikes, DoubleRandomVariable waitrv, Double returnOverflowProb, Hub[] destHubs, double[] weights, double[] overflowProb)
      Initialization.
      Parameters:
      hub - the hub from which trips originate
      mean - the mean interarrival time for the starting times of trips created by this trip generator
      nbikes - the number of bicycles per trip
      waitrv - a random variable providing the time spent at a destination hub before the return trip
      returnOverflowProb - the probability of using the overflow area after returning to the starting point
      destHubs - the destination hubs
      weights - the probabilities that the destination is a particular hub
      overflowProb - the probability for a destination hub that the overflow area is used regardless of whether or not there is excess capacity in the preferred location
    • getNextInterval

      protected double getNextInterval()
      Description copied from class: TripGenerator
      Get the time interval to wait before scheduling the next trip.
      Specified by:
      getNextInterval in class TripGenerator
      Returns:
      the next trip interarrival time
    • action

      protected boolean action()
      Description copied from class: TripGenerator
      Perform an action that generates a trip. Implementations of this method will typically call the Hub method Hub.sendUsers(Hub,int,boolean,Callable) or Hub.sendUsers(Hub,int,boolean,RealValuedFunctionTwo,Callable). The Callable argument handles multi-hop trips and also a final call to TripGenerator.fireTripEnded(long,Hub) for successfully completed trips. The return value for sendUsers or sendUsers can be used to determine whether TripGenerator.fireTripStarted(long,Hub,HubDomain) or TripGenerator.fireTripFailedAtStart(long,Hub) should be called. If sendUsers or sendUsers is used mid-trip, a failure is noted by calling TripGenerator.fireTripFailedMidstream(long,Hub) (which should not be called except for multi-hop trips). For multi-hop trips, the TripGenerator.fireTripPauseStart(long,Hub) should be called to note that a trip has temporarily paused at an intermediate hub and TripGenerator.fireTripPauseEnd(long,Hub,HubDomain) to indicate that the trip is continuing after a pause.

      Note: when this method returns false, the traffic generator cannot be restarted.

      Specified by:
      action in class TripGenerator
      Returns:
      true if more trips can be generated; false otherwise
    • printConfiguration

      public void printConfiguration(String iPrefix, String prefix, boolean printName, PrintWriter out)
      Print the configuration for an instance of TripGenerator. The documentation for method SimObject.printConfiguration(String,String,boolean,java.io.PrintWriter) contains a description of how this method is used and how to override it. The method GenericActor.printConfiguration(String,String,boolean,java.io.PrintWriter) describes this method as it applies to all actors . The data that will be printed when this method is called are the following.

      For class TripGenerator:

      • the initial delay - the time to wait before trips are generated.

      Defined for class RoundTripGenerator:

      • the mean interarrival time in seconds for trips.
      • the number of bicycles per trip.
      • the starting hub.
      • the destination hubs. For each destination, the following are printed:
        • the name of a destination hub.
        • the probability of choosing this hub.
        • the probability of using the overflow area.
      Overrides:
      printConfiguration in class TripGenerator
      Parameters:
      iPrefix - the prefix to use for an initial line when printName is true with null treated as an empty string
      prefix - a prefix string (typically whitespace) to put at the start of each line other than the initial line that is printed when printName is true
      printName - requests printing the name of an object
      out - the output print writer
    • clone

      protected Object clone() throws CloneNotSupportedException
      Overrides:
      clone in class Object
      Throws:
      CloneNotSupportedException
    • isInterned

      public boolean isInterned()
      Specified by:
      isInterned in interface NamedObjectOps
    • getObjectNamer

      protected Simulation getObjectNamer()
    • getName

      public final String getName()
      Specified by:
      getName in interface NamedObjectOps
    • canDelete

      public boolean canDelete()
      Specified by:
      canDelete in interface NamedObjectOps
    • delete

      public final boolean delete()
      Specified by:
      delete in interface NamedObjectOps
    • isDeleted

      public final boolean isDeleted()
      Specified by:
      isDeleted in interface NamedObjectOps
    • deletePending

      public final boolean deletePending()
      Specified by:
      deletePending in interface NamedObjectOps