Tutorials

This tutorial section will give you step by step instructions and exemples on how to use all the modules.

The first mandatory tutorial is the getting started procedure you should have already followed at this step. Once the needed Travel Simulator packages are correctly installed, the following tutorials are what you need!

For general information and a technical description of the different modules head to the user manual page once you are finished here.

Also for focused information on precise problems make sure you have a look at the F.A.Q.


How can I build correct simulation inputs?

There are two ways of giving your simulation inputs: using directly a Business Object Model tree (now referred to as the BOM tree) or parsing simulation input files to automatically build the BOM tree. The BOM tree contains exactly the same information as those files: airlines, schedules, fares, yield rules, ...

There are many ways of giving your simulation inputs:
How can I use the default BOM tree?
To familiarize yourself with the default BOM tree, load the StdAir batch directory (for instance, if you are working within the metasim environment):
cd ~/metasimgit/workspace/build/stdair/stdair/
Then launch it with the default BOM tree option '-b':
./stdair -b
If you have a look at the log file (called after the launched batch), you can find the following BOM tree structure, in this exact order :
  • a BOM tree root at the top of the tree
  • some inventory objects at level one
  • each inventory (characterised by an airline code) contains one or more flight dates (i.e. a flight number and an associated date)
  • each flight date is composed of leg date and segment date objects
  • each leg and segment contains associated cabins
  • each segment cabin is composed of at least one fare family, whcih is in turn composed of one or more booking classes
To discover the second part of the BOM tree structure, you can launch SimFQT for instance:
cd ~/metasimgit/workspace/build/simfqt/simfqt/
./simfqt -b
This batch is an interactive one, try 'help' to obtain all the existing commands, and then 'list' to discover all the O&Ds and departure dates for which some fare rules are applicable.
Then 'quit' the interactive batch and open the log file named 'simfqt.log'. At the beginning of the file, we find the BOM root display:
  • a BOM tree root at the top of the tree
  • at level one we find some airport pairs (representing the origin and the destination of existing travels)
  • at the lower level, we have date period, followed by point-of sale and channel options, followed by time period
  • then we find the fares applicable and the corresponding options (saturday night, change fees, refundable criterion)
  • finally, we have the airline codes and booking classes for which each fare rule is applicable
How can I create my own BOM tree?
To understand how to create your own BOM tree, do not hesitate to have a look into the C++ file called CmdBomManager.cpp located in the following directory:
cd ~/metasimgit/workspace/src/stdair/stdair/command/
Let us create our own BOM tree now.
First, a BOM root object (i.e. a root for all the classes in the project) must be instantiated. This is done by the stdair::STDAIR_ServiceContext context object, when the stdair::STDAIR_Service is itself instantiated. The standard procedure is illustrated below:
const BomRootKey lBomRootKey ("My first Bom Root");
BomRoot& lBomRoot = FacBom<BomRoot>::instance().create(lBomRootKey);
An airline inventory object can then be instantiated.
Let us create the "BA" airline code (corresponding to British Airways airline):
const AirlineCode_T lAirlineCodeBA ("BA");
That is, an object (let us name it lInventoryKeyBA) of type (class) stdair::InventoryKey has first to be instantiated.
const InventoryKey lInventoryKeyBA (lAirlineCodeBA);
Thanks to that key, an airline inventory object, i.e. of type (class) stdair::Inventory, can be instantiated. Let us name that airline inventory object lBAInv.
Inventory& lBAInv = FacBom<Inventory>::instance().create(lInventoryKeyBA);
Then, we must create the link parent/child to attach those two objects as defined in the BOM tree structure. That operation is as simple as using the following methods:
FacBomManager::addToListAndMap (lBomRoot, lBAInv);
FacBomManager::linkWithParent (lBomRoot, lBAInv);
Another airline inventory object, corresponding to the AF (Air France) company, can be instantiated the same way:
const AirlineCode_T lAirlineCodeAF ("AF");
const InventoryKey lAFKey (lAirlineCodeAF);
Inventory& lAFInv = FacBom::instance().create (lAFKey);
FacBomManager::addToListAndMap (lBomRoot, lAFInv);
FacBomManager::linkWithParent (lBomRoot, lAFInv);
How can I use existing input files?
When running a batch with no option specified, predefined default files are parsed and used to construct the BOM tree.
How can I create my own input files?
In this tutorial, we are going to create our own input files one by one.
Please first read the simulation input files description to familiarize yourself with each type of file.

Then, follow the steps to build:

How can I familiarise myself with the simulation event queue?

The module in charge of the event queue management is SEvMgr.
To understand its main functionality, let's launch the sevmgr interactive batch named 'sevmgr'. Hardcoded events are already present in the default queue to make it easier to understand the simulation event management.

The display should look like (here, the date of the simulation world is the 21st of January 2010):
Log filename is: sevmgr.log
sevmgr P / 2010-Jan-21 00:00:00>
Try the 'display' command to learn more about the current event. The output should look like this:
2010-Jan-21 00:00:00, BreakPoint, 2010-Jan-21 00:00:00
Let's now have a look at the whole simulation queue using the 'list' command. There are three events to come, including two booking requests and a second break point (the first one was the first event of the queue):
2010-Jan-22 10:00:00, BookingRequest, At 2010-Jan-22 10:00:00, for (SIN, IN) SIN-BKK (RI) 2010-Jan-30 (7 days) 10:00:00 Eco 3 M 1000 100 1 50 1 50
2011-May-14 00:00:00, BreakPoint, 2011-May-14 00:00:00
2011-May-15 10:00:00, BookingRequest, At 2011-May-15 10:00:00, for (LHR, DN) LHR-SYD (RI) 2011-Jun-10 (7 days) 08:00:00 Eco 3 M 1000 100 0 30 0 50 
The 'next' command plays the current event and pops the next one from the queue. This is exactly the simulation principle: the events in the queue will be popped and played one by one. The simulation will only stop when a break point is encountered which is the objective of the 'run' command.

How should I generate and insert my own booking requests in the event queue?

Now, the objective is to stop using default hard-coded events (see the tutorial How can I familiarise myself with the simulation event queue?) but to insert our own booking requests in the event queue. The module in charge of building and inserting booking requests in the queue is TraDemGen.

Load the TraDemGen batch directory (for instance, if you are working within the metasim environment):
cd ~/metasimgit/workspace/build/trademgen/trademgen/
When launching the trademgen interactive batch with no parameter, a default demand input file is parsed. This file can be found in the StdAir sample directory.
./trademgen
To see all the demand streams for which booking requests can be generated, try the command 'list_demand_stream'. You can check that you end up with the same demand streams as those defined in the input file. The output should look like:
List of demand streams
SIN-BKK 2012-Apr-30 Y
SIN-BKK 2012-May-07 Y
SIN-BKK 2012-May-14 Y
SIN-BKK 2012-May-21 Y
SIN-BKK 2012-May-28 Y
SIN-BKK 2012-Jun-04 Y
SIN-BKK 2012-Jun-11 Y
SIN-BKK 2012-Jun-18 Y
SIN-BKK 2012-Jun-25 Y
SIN-BKK 2012-Jul-02 Y
...
Then, the command 'list_event' will enable you to check that for now, the event list is empty:
List of events
EQ01
(0) 0/{11520,11520}
Let's now generate our first booking request for the first demand stream. The corresponding command is :
generate_next_br SIN-BKK 2012-Apr-30 Y
Let's now display again the event list ('list_event' command):
List of events
EQ01
(1) 0/{11520,11520}
2011-Jun-06 22:50:04.001000, BookingRequest, At 2011-Jun-06 22:50:04.001000, for (BKK, DN) SIN-BKK (RO) 2012-Apr-30 (5 days) 07:01:27 Y 1 G 185.452 55.6372 0 50
A booking request has been created: the corresponding traveller is making his request on the 6th of June 2011 and is wishing to travel on the 30th of April 2012 from Singapour to Bangkok in the Economy cabin (as expected from the demand stream key). The other parameters'values have been created using the distribution defined in the demand input file.

Let's now generate all the booking requests for this same demand stream:
generate_all_br SIN-BKK 2012-Apr-30 Y
The output display should look like:
339 more event(s) have been generated for the demand stream: 'SIN-BKK 2012-Apr-30 Y'.
Display again the event list to see all the stored booking requests.

Finally, to visualize the booking requests arrival pattern, 'quit' the interactive command line and launch a python dedicated script located in the tool directory:
./tools/trademgen_drawBookingArrivals -p trademgen.log
Do not hesitate to repeat the steps above using your own demand input file. Please, refer to the How can I build my own demand input file? tutorial first. Then launch the demand generation script with your demand file specified as input parameter:
./trademgen --input <your_demand_file.csv>

How can I perform my first fareQuote?


-