C++ Simulated Travel Demand Generation Library
Summary
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.
Installation
On Fedora/CentOS/RedHat distribution
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 32, https://fr2.rpmfind.net/linux/RPM/fedora/32/x86_64/)
Building the library and test binary from Git repository
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):
- cmake
- gcc-c++
- boost-devel / libboost-dev
- python-devel / python-dev
- gettext-devel / gettext-dev
- sqlite3-devel / libsqlite3-dev
- readline-devel / readline-dev
- ncurses-devel
- soci-mysql-devel, soci-sqlite3-devel
- stdair-devel / libstdair-dev
- sevmgr-devel / libsevmgr-dev
- doxygen, ghostscript, graphviz
- tetex-latex (optional)
- rpm-build (optional)
Building the library and test binary from the tarball
The latest stable source tarball (trademgen*.tar.gz or .bz2) can be
found on GitHub: https://github.com/airsim/trademgen/tags, e.g.,
https://github.com/airsim/trademgen/archive/trademgen-1.00.6.tar.gz
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.6"
if [ -d /usr/lib64 ]; then LIBSUFFIX="64"; fi
export LIBSUFFIX_4_CMAKE="-DLIB_SUFFIX=${LIBSUFFIX}"
Then, as usual:
- To configure the project, type something like:
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} ..
- To build the project, type:
make
- To test the project, type:
make check
- To install the library (
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 -
- To package the source files, type:
make dist
- To package the binary and the (HTML and PDF) documentation:
make package
- To browse the (just installed, if enabled) HTML documentation:
midori file://${INSTALL_BASEDIR}/trademgen-$TDG_VER/share/doc/trademgen/html/index.html
- To browse the (just installed, if enabled) PDF documentation:
evince ${INSTALL_BASEDIR}/trademgen-$TDG_VER/share/doc/trademgen/html/refman.pdf
- To run the local binary version:
./trademgen/trademgen -b
- To run the installed version:
${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
Python extension
The way to interact with a C++-based Python extension is extensively described in the OpenTREP project. Only a quick start is given here.
Python dependencies
- Install Python dependencies:
$ 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
Build the Python extension
- Build the Python extension with SciKit-Build:
$ rm -rf _skbuild/ dist/ MANIFEST_
$ python3 setup.py --build-type=Debug build sdist bdist_wheel
- The Python artifacts should be similar to:
$ ls -lFh dist/
total 5872
-rw-r--r-- 1 user staff 2.0M Jun 1 15:49 rmol-1.0.5.post1-cp38-cp38-macosx_10_15_x86_64.whl
-rw-r--r-- 1 user staff 834K Jun 1 15:49 rmol-1.0.5.post1.tar.gz
- Updload the RMOL Python extension onto PyPi:
$ twine upload -u __token__ --repository-url https://upload.pypi.org/legacy/ dist/*
- The RMOL Python artifacts may then be browsed on PyyPI: https://pypi.org/project/rmol/
Use the Python extension
- Launch the Python interpreter:
$ 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/pyrmol
$ 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
- Within the Python interpreter, import, initialize and use the RMOL Python extension:
Python 3.8.3 (default, May 27 2020, 20:54:22)
[Clang 11.0.3 (clang-1103.0.32.59)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyrmol
>>> rmolLibrary = pyrmol.RMOLer()
>>> rmolLibrary.init('rmol.log', 40, 1, '')
True
>>> rmolLibrary.rmol(100, 10, 40.0)
'RMOL has completed the generation of the booking requests. See the log file for more details.\n'
>>> quit()
- Back to the Shell session, look for the results in the RMOL log file:
$ cat rmol.log
Python wrapper initialisation
[D]${STDAIR_PREFIX}/stdair/command/CmdBomManager.cpp:52: StdAir is building the BOM tree from built-in specifications.
Python wrapper initialised
Optimisation for 100 draws, capacity of 40, and with the following method: 10
[D]${RMOL_PREFIX}/rmol/service/RMOL_Service.cpp:491: Optimisation by Monte-Carlo performed in 0.000321
[D]${RMOL_PREFIX}/rmol/service/RMOL_Service.cpp:492: Result:
Yield: 100.00, Protection: 70.48, Booking limit: 100.00
Yield: 70.00, Protection: 156.19, Booking limit: 29.52
Yield: 42.00, Protection: -0.00, Booking limit: -56.19
[D]${RMOL_PREFIX}/rmol/service/RMOL_Service.cpp:505: Bid-Price Vector (BPV): 100.00, 100.00, 100.00, 100.00, 100.00, 100.00, 100.00, 100.00, 100.00, 100.00, 100.00, 100.00, 100.00, 100.00, 100.00, 100.00, 100.00, 100.00, 100.00, 100.00, 100.00, 100.00, 100.00, 100.00, 100.00, 100.00, 100.00, 100.00, 100.00, 100.00, 100.00, 100.00, 100.00, 100.00, 100.00, 100.00, 100.00, 100.00, 100.00, 100.00, 99.00, 99.00, 99.00, 99.00, 99.00, 98.00, 98.00, 97.00, 96.00, 96.00, 96.00, 96.00, 96.00, 95.00, 94.00, 94.00, 90.00, 90.00, 89.00, 88.00, 86.00, 84.00, 82.00, 80.00, 80.00, 79.00, 77.00, 76.00, 75.00, 72.00, 70.00, 70.00, 70.00, 70.00, 70.00, 70.00, 70.00, 70.00, 70.00, 70.00, 70.00, 70.00, 70.00, 70.00, 70.00, 70.00, 70.00, 70.00, 70.00, 70.00, 70.00, 70.00, 70.00, 70.00, 70.00, 70.00, 70.00, 70.00, 70.00, 70.00
End of the optimisation.
RMOL output:
- Of course, a few more features could be added to the Python extension API, in order not to have to leave the Python interpreter to interact with the results of invoking the optimizer. Do not hesitate to contribute through Pull Requests, which are always welcome!
Metadata
Release files for trademgen 1.0.6.post1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| trademgen-1.0.6.post1.tar.gz | 451.9 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| trademgen-1.0.6.post1-cp38-cp38-macosx_10_15_x86_64.whl | CPython 3.8 | CPython 3.8 | macOS 10.15+ x86-64 | Details |
Total release size: 4.0 MB
Release files / trademgen-1.0.6.post1.tar.gz
| Download URL | trademgen-1.0.6.post1.tar.gz |
|---|---|
| Size | 451.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
69a014745e0908b3281754caba81ce9e8425a24f9903e4a5920dbd543c4cb5c4
|
|
BLAKE2b-256 checksum How to use checksums |
091472a84f3eb103dfad36c69eaf878f8d04bef456edf86a573d607a2fba939c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.1 requests-toolbelt/0.8.0 tqdm/4.46.0 CPython/3.8.3
|
Release files / trademgen-1.0.6.post1-cp38-cp38-macosx_10_15_x86_64.whl
| Download URL | trademgen-1.0.6.post1-cp38-cp38-macosx_10_15_x86_64.whl |
|---|---|
| Size | 3.6 MB |
| Tags | CPython 3.8 macOS 10.15+ x86-64 |
|
SHA-256 checksum How to use checksums |
58aba1a0a230c711df216e4787a6c9d239ed7b46eacba686c551c41bd8fdfc4a
|
|
BLAKE2b-256 checksum How to use checksums |
1ae830e6619a3251949225affaeaf1901f48abe0da6be85f87da909b601d6c4e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.1 requests-toolbelt/0.8.0 tqdm/4.46.0 CPython/3.8.3
|
Security for trademgen 1.0.6.post1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.