• No results found

Simulation Framework

6.1 Overview of Simulator

In the simulator, we evaluate the number of violations occurring over what can be seen as a series of customer arrival scenarios, referred to as aday. Specifically, a day represents 16 hours of simulation. Note however that the term customer arrival scenarios refer to the predicted arrivals used in the subproblems, whereas the simulated arrivals actually affect the system evolution. The performance of the rebalance and battery swap strategies are evaluated based on the recorded number of violations occurring in a day of simulation.

The simulator used is programmed in Python and event triggered. An event can be trig-gered by a customer arrival at a station, denoted asbicycle trigger, or a service vehicle arrival at a station, denoted as vehicle trigger, illustrated in Figure 6.1. A bicycle trig-ger results in a created trip or completed trip in the simulation environment. A vehicle trigger prompts solving of the DSBRCP using parameter data from a snapshot of the sim-ulated system. When solving this problem, the other vehicles in the system are assumed to also have arrived at the station next up in their respective routes. This is demonstrated in Figure 6.2, where Vehicle 1 is assumed to have arrived at Station 5 when solving the DSBRCP triggered by Vehicle 2’s arrival at Station 7. However, only the strategy obtained for Vehicle 2 is realized in the simulation.

Figure 6.1:Flowchart illustrating the high-level simulation interactions in the Python simulator

Figure 6.2:Demonstration of vehicle location assumption used to solve the DSBRCP when a vehicle arrives at a station. Vehicle 2 has arrived at station 7, triggering solving of the DSBRCP. Vehicle 1 is assumed to have arrived at its next destination, station 5.

When the simulation starts attstart, the system is set up with predefined inputs describing the initial state of the system for the specified starting time. When a service vehicle arrives at a station, a snapshot of the current system inventories are used to solve the DSBRCP.

The solution of the problem contains the service vehicle’s route and rebalancing and bat-tery swap strategy, and is used to update the system before continuing the simulation.

Bike trips are based on poisson arrivals of customers and handled in sequence between vehicle arrivals. Requests to initiate trips at stations with no available charged bikes result

in starvation violations. Requests to park bikes at full stations result in congestion viola-tions. Every time a vehicle arrives at a new station, the DSBRCP is re-solved with the new stochastic system information revealed upon arrival. This is done in an iterative manner until the duration of the simulation is up attend, shown in Figure 6.3. The current simu-lation time is tracked using a variabletcurrent. Whentendis reached, the total number of violations are calculated and evaluated. Note that it is essential that the configurations are evaluated on several days of simulation as each day only represents one possible outcome of customer arrivals.

Figure 6.3: Sequential handling of events for one scenario of customer arrivals. Subproblems are solved every time a vehicle arrives at a station. The time horizon represents the planning period used for customer arrival prediction when solving the DSBRCP

6.2 Modelling Customer Arrivals Through a Poisson Pro-cess for a Station in the Subproblem

A Poisson Process is a model for a series of discrete events where the average time be-tween events is known, but the exact timing of events is random. The arrival of an event is independent of the event before, meaning that the waiting time between events is mem-oryless (Gallager, 1997). A parameter , typically referred to as rate or intensity, is the expected number of customers arriving per minute in a given time interval. The Poisson distribution is a discrete distribution for the probability ofxevents happening in a time interval defined on non-negative integers as follows:

P oisson( t)⇠P(X =x) =e t( t)x

x! , x= 0,1,2, ...

wherexis the number of customer arrivals, is the intensity rate, andtis time steps. A Poisson process can be either homogeneous with constant intensity rate, commonly re-ferred to as a counting process, or non-homogeneous with varying intensity rate. Since the time horizon is short, we use a homogeneous Poisson process to model the customer arrivals within each time horizon (Drazek, 2013).

The arrival of customers are modelled as separate and independent Poisson processes for the three groups of customers. For each time horizon, the intensity rates, denoted 1, 2,

3, are calculated based on historical data from the stations. The homogeneous Poisson point process adheres to its own form of the law of large numbers. More specifically, with probability one:

t!1lim X(t)

t =

This implies that the intensity rate approaches the expected number of arrivals occurred per unit of time. This property is used to estimate the intensity rates for each station.

Algorithm 2 simulates the customer arrivals with a Poisson process for a customer type at a station. Every minute, the number of customer arrivals are drawn from the Poisson distribution adding the time of arrival for each customer to a customer arrival list.

Algorithm 2:Poisson arrivals for a station

Data: := arrival rate at station,t:= time steps in minutes Result:Customer arrivals:= list of times for customer arrivals

1 fori in rangetdo

2 time step arrivals =X ⇠P oisson( );

3 forj in range time step arrivalsdo

4 add i to Customer arrivals

5 end

6 end