Math Trades are trades where multiple people participate at once in order to trade items between them. Each user defines multiple "want" relationships between one or more items she offers and a items she would like to receive in return. The goal of a Math Trading algorithm is to maximize the number of items that will be eventually traded.
In this project we are approaching the real-world problem of Math Trades on BoardGameGeek (BGG)
Math Trades have been taking place on BGG since the early 2000's. Various algorithms had been developed at the time, most applying a brute-force search, an approach which would only work for small datasets due to their exponential asymptotic behavior. TradeGenie, developed by B. Perry, was a popular choice among the users.
In 2008, Chris Okasaki developed an algorithm which would run in polynomial time, subsequently releasing the JAVA source code, dubbed as TradeMaximizer. This software has been used since then as the de facto algorithm to resolve Math Trades on BGG.
Since then, B. Perry implemented a compatible multithreaded C++ version of the software, TradeThing. According to preliminary results, the performance of TradeThing is quite comparable to TradeMaximizer's.
Subsequently, the goal of this project is not to be a yet-another-C++-adaption, but to explore and evaluate the following alternatives:
- Investigate whether the performance may be enhanced by utilizing specialized, open source Graph Libraries, that have been already optimized for performance. Our main focus should be on designing effective math trading solutions by applying standard, polynomial-time algorithms on the problem, and not on optimizing graph management functions, where we already have dedicated libraries at our disposal.
- The original algorithm maximizes the number of traded items and uses "number of trading users" as a metric, over multiple iterations, to determine the best solution. We would like to explore the possibilities of amending the original algorithm itself in order to maximize the number of users that are trading at least one item, rather than rely on metrics. Therefore, we are also dealing with an algorithmic challenge.
The Math Trading problem may be formally stated as:
Given a weighted directed graph
G=(V,E)with weightsw(E), find a set of vertex-disjoint cycles that maximizes the number of covered vertices and minimizes the total edge cost among the set of optimal solutions.
The following packages are required to build the library:
g++compiler version4.9.2or newercmakeversion3.0.2or newer- The LEMON Graph Library. See Installing the LEMON library.
To generate the Doxygen-supported documentation, the following optional packages are required:
doxygengraphviz
The following package is required to run the library unit tests under the Google Test framework:
libgtest-dev
-
On Linux systems, execute from the top directory:
mkdir build cd build cmake .. make
This creates the mathtrader++ executable under build/app/mathtrader++.
- Optionally, you may also run
make docto create the documentation ifdoxygenhas been installed.
Note that this guide applies mostly on Linux systems.
Testcases from past trades may be found online
at the Online Want List Generator (OLWLG).
The official wantslists of previous Math Trades are linked
under the respective [WANT] tag.
The mathtrader++ executable is found under build/app/mathtrader++.
You may see the full option list of mathtrader++ by running ./mathtrader++ -h.
To run mathtrader++ directly on a want-list file from OLWLG, run:
./mathtrader++ --input-url http://bgg.activityclub.org/olwlg/207635-officialwants.txt
Alternatively, you may download a want-list file using wget or curl, e.g.:
wget http://bgg.activityclub.org/olwlg/207635-officialwants.txt
The testcase file may be provided either from the standard input or as a file:
./mathtrader++ < 207635-officialwants.txt
./mathtrader++ --input-file 207635-officialwants.txt
The results will be printed by default to the standard output.
You may redirect the output to a file or use the --output-file option:
./mathtrader++ --input-url http://bgg.activityclub.org/olwlg/207635-officialwants.txt > 207635-results-official.txt
./mathtrader++ --input-url http://bgg.activityclub.org/olwlg/207635-officialwants.txt --output-file 207635-results-official.txt
This library has been documented using Doxygen.
To build it, type make doc within the build/ directory.
Open in a web browser the build/html/index.html file.
A refman.pdf file may be compiled with the entire documentation.
Execute the following steps from the build/ directory:
cd latexmake- Open the
refman.pdffile.
Unit tests under the Google Test framework are provided. The Google Test framework package is required to build them. The following testing executables are compiled:
build/lib/iograph/testiograph: test the library that parses the want-list filesbuild/lib/solver/testsolver: test the library that solves the math trades
Simply run the executables to test the libraries.
- Implement scaled priority schemes.
- Add users-trading as a metric.
- Handle corner cases where there are no want lists at all.
- Parse EXPLICIT priorities; parse want lists formatted as ITEM=VALUE
- Add I/O checksums.
- Write own method in WantParser::parseLine to handle directives.
- If an OPTION fails to parse, do not skip the entire line, if multiple options are given in a single line.
- Report unknown items, i.e., items that appear in want lists but have not been previously defined.
- Add qt-based GUI.
- Implement
make install