TraDemGen aims at providing a clean API, and the corresponding C++ implementation, able to generate demand for travel solutions (e.g., from JFK to PEK on 25-05-2019) according to characteristics (e.g., Willingness-To-Pay, preferred airline, etc).
TraDemGen makes an extensive use of existing open-source libraries for increased functionality, speed and accuracy. In particular the Boost (C++ Standard Extensions: https://www.boost.org) library is used.
TraDemGen is the one of the components of the Travel Market Simulator (https://travel-sim.org). However, it may be used in a stand-alone mode.
Just use DNF (or Yum on older distributions):
$ dnf -y install trademgen-devel trademgen-doc
You can also get the RPM packages (which may work on Linux distributions like Suse and Mandriva) from the Fedora repository (e.g., for Fedora Rawhide, https://fr2.rpmfind.net/linux/RPM/fedora/devel/rawhide/x86_64/)
The Git repository may be cloned as following:
$ git clone git@github.com:airsim/trademgen.git trademgengit # through SSH
$ git clone https://github.com/airsim/trademgen.git # if the firewall filters SSH
$ cd trademgengit
Then, you need the following packages (Fedora/RedHat/CentOS names here, but names may vary according to distributions):
The latest stable source tarball (trademgen*.tar.gz
or .bz2
) can be
found on GitHub: https://github.com/airsim/trademgen/tags
As TraDemGen depends on other Travel Market Simulator (TvlSim/AirSim) modules, more specifically StdAir and SEvMgr, it may be convenient to use the MetaSim project, which pulls at once all the components of TvlSim in the same place, and then orchestrates the dependencies for the builds, installations and use of components.
If MetaSim is not used, in order to customise the following to your environment, you can alter the path to the installation directory:
export INSTALL_BASEDIR="/home/user/dev/deliveries"
export TDG_VER="1.00.11"
if [ -d /usr/lib64 ]; then LIBSUFFIX="64"; fi
export LIBSUFFIX_4_CMAKE="-DLIB_SUFFIX=${LIBSUFFIX}"
Then, as usual:
mkdir build && cd build
cmake -DCMAKE_INSTALL_PREFIX=${INSTALL_BASEDIR}/trademgen-$TDG_VER \
-DWITH_SEVMGR_PREFIX=${INSTALL_BASEDIR}/sevmgr-stable \
-DWITH_STDAIR_PREFIX=${INSTALL_BASEDIR}/stdair-stable \
-DCMAKE_BUILD_TYPE:STRING=Debug -DENABLE_TEST:BOOL=ON \
-DINSTALL_DOC:BOOL=ON -DRUN_GCOV:BOOL=OFF ${LIBSUFFIX_4_CMAKE} ..
make
make check
libtrademgen*.so*
) and the binary (trademgen),
just type:
make install
cd ${INSTALL_BASEDIR}
rm -f trademgen-stable && ln -s trademgen-${TDG_VER} trademgen-stable
cd -
make dist
make package
midori file://${INSTALL_BASEDIR}/trademgen-$TDG_VER/share/doc/trademgen/html/index.html
evince ${INSTALL_BASEDIR}/trademgen-$TDG_VER/share/doc/trademgen/html/refman.pdf
./trademgen/trademgen -b
${INSTALL_BASEDIR}/trademgen-${TDG_VER}/bin/trademgen -b
${INSTALL_BASEDIR}/trademgen-${TDG_VER}/bin/pytrademgen
${INSTALL_BASEDIR}/trademgen-${TDG_VER}/bin/trademgen_generateDemand
${INSTALL_BASEDIR}/trademgen-${TDG_VER}/bin/trademgen_extractBookingRequests
${INSTALL_BASEDIR}/trademgen-${TDG_VER}/bin/trademgen_drawBookingArrivals
${INSTALL_BASEDIR}/trademgen-${TDG_VER}/bin/trademgen_with_db
The way to interact with a C++-based Python extension is extensively described in the OpenTREP project. Only a quick start is given here.
$ python3 -m pip install -U pip
$ python3 -m pip install -U wheel
$ python3 -m pip install -U build setuptools scikit-build tox pytest sphinx twine
$ rm -rf _skbuild/ dist/ MANIFEST_
$ python3 setup.py --build-type=Debug build sdist bdist_wheel
$ ls -lFh dist/
total 7832
-rw-r--r-- 1 darnaud staff 3.4M Jun 1 17:25 trademgen-1.0.9.post1-cp38-cp38-macosx_10_15_x86_64.whl
-rw-r--r-- 1 darnaud staff 441K Jun 1 17:25 trademgen-1.0.9.post1.tar.gz
$ twine upload -u __token__ --repository-url https://upload.pypi.org/legacy/ dist/*
$ export PYTHONPATH=${PWD}/_skbuild/macosx-10.15-x86_64-3.8/cmake-install/lib:${PWD}/_skbuild/macosx-10.15-x86_64-3.8/cmake-install/lib/python3.8/site-packages/pytrademgen
$ DYLD_INSERT_LIBRARIES=/Library/Developer/CommandLineTools/usr/lib/clang/11.0.0/lib/darwin/libclang_rt.asan_osx_dynamic.dylib ASAN_OPTIONS=detect_container_overflow=0 /usr/local/Cellar/python@3.8/3.8.3/Frameworks/Python.framework/Versions/3.8/Resources/Python.app/Contents/MacOS/Python
import pytrademgen trademgenLibrary = pytrademgen.Trademgener() trademgenLibrary.init (‘trademgen.log’, 120765987, 1, ‘’) True result = trademgenLibrary.trademgen (1, “S”)
0% 10 20 30 40 50 60 70 80 90 100% |—-|—-|—-|—-|—-|—-|—-|—-|—-|—-| *******************
quit() ```
[BKG]
correspond to booking requests:
$ grep "^\[BKG\]" trademgen.log | wc -l
185
$ grep "^\[BKG\]" trademgen.log
[BKG] At 2009-Mar-25 04:40:58.001000, for (SIN, IN) SIN-BKK (OW) 2010-Feb-08 (5 days) 06:17:33 Y 1 M 499.825 55.6372 0 50 1 50
[BKG] At 2009-Apr-12 08:50:38.001000, for (BKK, IN) BKK-HKG (OW) 2010-Feb-08 (1 days) 01:00:00 Y 1 N 431.266 18.5982 0 50 1 50
[BKG] At 2009-May-13 00:24:44.001000, for (SIN, IN) SIN-HKG (OW) 2010-Feb-08 (5 days) 06:42:22 Y 1 M 1176.99 53.9946 1 50 0 50
...
[BKG] At 2010-Feb-08 06:34:50.843000, for (BKK, IN) BKK-HKG (OW) 2010-Feb-08 (5 days) 01:00:00 Y 1 N 427.22 32.9541 1 50 0 50
[BKG] At 2010-Feb-08 07:23:52.535000, for (SIN, IN) SIN-HKG (OW) 2010-Feb-08 (5 days) 07:17:47 Y 1 M 1372.76 49.7753 0 50 1 50
[BKG] At 2010-Feb-08 02:20:16.626000, for (SIN, IN) SIN-BKK (OW) 2010-Feb-08 (0 days) 12:10:14 Y 1 M 694.148 54.8685 1 50 1 50