Tutorial 1: EVs and Scenarios

See tutorial/tutorial_1_EVs_and_Scenarios.mlx. This tutorial includes advanced topics on EV and Scenario. You can refer to EV and Scenario while following this tutorial to better understand the methods and properties discussed here.

An EV object

1. Create an EV object

An EVobject contains information such as the arrival/departure time of an EV, battery capacity, initially stored energy, reference energy. The following syntax creates EV objects.

ev1 = EV();                         % Create an EV object with default parameters.
ev2 = EV(Arr_time=2, Dep_time=6);   % Create an EV object with name-value arguments.

Once created, the properties of an EV object can be modified using set() method. (Directly changing the properties is forbidden.)

ev1 = set(ev1,E_ini=40);
ev2 = ev2.set(E_ref=80);

2. Validate an EV object

Each EV object has a property named valid, which indicates whether the object has passed a validation process.

ev1.valid
ev2.valid

The following syntax executes a validation process and chage valid true if all the requirements (e.g., Arr_time < Dep_time, E_ref <= E_cap) for an EV object are satisfied.

ev1 = validate(ev1);
ev2 = ev2.validate();
ev1.valid
ev2.valid

However, modifying a property afterward requires an additional validation.

ev1 = set(ev1,U_max=15);
ev1.valid

A Scenario object

A Scenario object is an object that contains all information describing a charging scheduling problem, such as the base load profile, electricity price, limits on charging powers, EV behaviors, and topology of communication infrastructure.

1. Import a scenario from json

Navigate to the tutorial/Sample_Lf folder. Inspect the following files.

“Sample_LF_cent.json” and “Sample_LF_dist.json” that contain all key information

  • “Baseload.xlsx” that contains a base load profile

  • “EV_Lf.xlsx” that contains all EV information: arrival/departure times, battery capacities, etc

To create a scenario object by importing the information provided in these files, execute the following.

scenario1 = import_scenario('Sample_Lf_cent.json');

2. Create a scenario manually

Indeed, it is possible to create a scenario object manually.

Problem_type = "Lf";                % We focus on the load flattening problem
T            = 3;                   % Consider three time slots
Delta        = 10;                  % of length 10 minutes.
D            = [100; 150; 100];     % The base load at each time slot is 100kW, 150kW, 100kW.
N_c          = 2;                   % We consider two chargers
N_ev         = 2;                   % and two EVs.
EVs          = [ev1, ev2];          % EVs contains information about the two EVs.

scenario2 = Scenario(Problem_type=Problem_type, ...
                      T=T, ...
                      Delta=Delta, ...
                      D=D, ...
                      N_c=N_c, ...
                      N_ev=N_ev,...
                      EVs=EVs);     % Now we can create a scenario object.

3. Generate a scenario from ScenarioGenerator object

Another method is to instanciate a ScenarioGenerator object and generate a scenario from it.

gen = PoissonScenarioGenerator(T=24);               % Instantiate a PoissonScenarioGenerator
                                                    % object that generates scenarios of length 24.
                                                    % Here, we set other parameters to default values.

scenario3 = generate(gen);                          % Then, generate a scenario from it.

4. Validate a scenario

A Scenario object also has a property named valid which indicates whether the object has passed the validation process.

scenario1.valid
scenario2.valid
scenario3.valid

One can see that both scenario_1 and scenario_3 are valid, whereas scenario_2 is not. This is because the functions import_scenario() and generate() of PoissonScenarioGenerator automatically perform a validation process. Here, we demonstrate the validation process for scenario_2.

scenario2 = validate(scenario2);
scenario2.valid

All scheduling functions provided in SH-V2G-Simulatior undergo this scenario validation process before executing the scheduling.

Note

validate() includes the validation of all contained EV objects.

5.Modifying properties of a scenario

The properties of a scenario object can be modified by set() method.

scenario2 = set(scenario2,Delta=30);
scenario2 = scenario2.set(N_c=3);

A single EV object can be replaced using set_ev() method.

ev2_new = EV(Charger_ind=3);
scenario2 = scenario2.set_ev(2,ev2_new);

However, again, modifying a property afterward requires an additional validation.

scenario2.valid

6. Obtaining a subscenario from a scenario

In some cases, it is required to generate a subscenario from a given scenario, for example, when performing scheduling in a receding horizon manner or when analyzing the results.

The method get_subscenario() supports this functionality with various options.

The name-value arguments ini and fin specify the initial time slot and the final time slot for obtaining a subscenario.

subscenario_1a = scenario1.get_subscenario(ini=2,fin=5);
  • subscenario_1a corresponds to the time slot 2, 3, 4 of the scenario1.

  • subscenario_1a.EVs consists of the EVs that is connected to a charger at some time slot among 2, 3, 4.

Setting future_evs=false makes the subscenario exclude the EVs that arrives in the future (i.e., at time slots after ini).

subscenario_1b = scenario1.get_subscenario(ini=2,fin=5,future_evs=false);
  • subscenario_1b.EVs consists of the EVs that is connected to a charger at time slot 2.

By providing E_ini argument we can set the E_ini of the EVs in the subscenario.

subscenario_1c = scenario1.get_subscenario(ini=2,fin=5,E_ini=zeros(1,50));
subscenario_1a.EVs(1).E_ini
subscenario_1c.EVs(1).E_ini
  • For each i, subscenario_1c.EVs(i).E_ini is set to 0.