View Javadoc
1   package org.opentrafficsim.road.gtu.generator.headway;
2   
3   import java.util.Optional;
4   
5   import org.djunits.value.vdouble.scalar.Duration;
6   import org.djunits.value.vdouble.scalar.Frequency;
7   
8   /**
9    * Interface for arrivals in an {@code ArrivalsHeadwayGenerator}. Arrivals are defined as a piece-wise linear frequency over
10   * time.
11   * <p>
12   * Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
13   * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
14   * </p>
15   * @author <a href="https://github.com/averbraeck">Alexander Verbraeck</a>
16   * @author <a href="https://github.com/peter-knoppers">Peter Knoppers</a>
17   * @author <a href="https://github.com/wjschakel">Wouter Schakel</a>
18   */
19  public interface Arrivals
20  {
21  
22      /**
23       * Returns the demand at given time, which may be the sum of child objects. The input {@code sliceStart} is used to resolve
24       * the value at a time slice boundary in case of a stepwise (discontinuous) demand pattern. If {@code sliceStart = true} and
25       * {@code time} is a slice boundary, the demand value for <i>after</i> the slice boundary should be returned. In that case,
26       * the caller is processing a time slice after {@code time}, hence it's the slice start. If {@code sliceStart = false} the
27       * demand value of before the slice boundary should be returned. For continuous demand patterns, {@code sliceStart} can be
28       * ignored.
29       * @param time simulation time
30       * @param sliceStart whether the time is at the start of an arbitrary time slice
31       * @return returns the total demand for branching nodes, or the demand at a leaf node, at the given time
32       */
33      Frequency getFrequency(Duration time, boolean sliceStart);
34  
35      /**
36       * Returns the start time of the next time slice after the given time or {@code null} if no such slice exists. The next time
37       * slice starts as soon as the current slice ends, where each slice has it's own linear (or constant) demand. Thus, any
38       * change of slope in the demand pattern initiates a new slice. If {@code time} is equal to a time slice boundary, the next
39       * value should be returned.
40       * @param time time after which the first slice start time is requested
41       * @return start time of the next time slice after the given time, empty if no such slice exists
42       */
43      Optional<Duration> nextTimeSlice(Duration time);
44  
45  }