RevKit can be downloaded from the www.revkit.org website.
RevKit has the following requirements:
./install_cmake.sh
script in the libs directory. Afterwards, add the directory libs/cmake-2.8.0/bin
to your PATH environment variable.Further requirements are boost 1.45.0, CUDD, cuddread, and PUMA. They will be automatically downloaded and added during the installation (see below). Alternatively, run the script ./install_libs.sh
in the libs directory to install the library and headers. If possible, the scripts downloads pre-compiled versions of the libraries. If no such binary is available for the used platform, the sources a downloaded (and afterwards compiled) instead. In the latter case, this process may take some time.
The following table lists the names of all directories and a short description.
Directory | Description |
algorithms | Stable algorithms (e.g. for synthesis, optimization, ...) |
bindings | Code for the Python bindings |
build | Build directory which is created by the ./build.sh script |
core | Core library with basic data structures and functions |
doc | Source code documentation and user manual |
examples | C++ First Steps examples from this documentation. |
helpers | Helper scripts for code-stub generation |
libs | Third party dependencies |
tools | Small python scripts for stand-alone usage of the algorithms |
unstable | Unstable algorithms (under development) |
In order to install RevKit, go to the directory to where you checked out the sources (i.e. where you find directories like core, algorithms, libs ...). Then, perform the following steps:
$ ./build.sh
This will compile the core and the stable algorithms. If you want to use the Python bindings, which is recommended, activate them by adding the -DBUILD_BINDINGS=ON option:
$ ./build.sh -DBUILD_BINDINGS=ON
Further options are -DBUILD_UNSTABLE=ON and -DBUILD_EXAMPLES=ON. You should add them if you plan to integrate a new C++ based algorithm or to modify the framework.
$ ./build.sh -DBUILD_UNSTABLE=ON -DBUILD_EXAMPLES=ON
If you want to install the library to certain location (which is not necessary), you can use -DCMAKE_INSTALL_PREFIX, e.g.:
$ ./build.sh -DCMAKE_INSTALL_PREFIX=/usr $ cd build $ make install
Of course, all the options can be combined and also changed after the initial building, e.g. with the cmake-gui:
$ cd build $ cmake-gui
If you added a new C++ based algorithm to RevKit or modified the existing ones, there is no need to run ./build.sh
again. Instead, you can compile your extensions by simply entering:
$ cd build $ make
Hint: The build libraries and executables are in the respective sub-directories, e.g. build/core, build/examples, ...
Internally, RevKit extensively uses the Boost libraries. Some of the concepts might also been useful for extensions. Thus, in the following two of the Boost libraries are motivated by means of small examples.
Boost.Assignment makes it easier to insert elements into containers. This is illustrated by the following example, where names are added to a vector
of std::string
.
#include <string> #include <vector> #include <boost/assign/std/vector.hpp> using namespace boost::assign; using namespace revkit; int main( int argc, char ** argv ) { std::vector<std::string> names; names += "Ada","Bob","Cipher"; return 0; }
This example also works e.g. with std::set
.
Boost.Foreach enables a foreach - style loop inside C++. This construct internally uses efficient C++ iterator techniques, so it is safe to use from this point of view. The following small example demonstrates how to use Boost.Foreach in order to loop through a vector of strings which was former created by Boost.Assign (see above). Note, that we defined a macro to call BOOST_FOREACH foreach in order to make it more readable.
#include <string> #include <vector> #include <boost/assign/std/vector.hpp> #include <boost/foreach.hpp> #define foreach BOOST_FOREACH using namespace boost::assign; using namespace revkit; int main( int argc, char ** argv ) { std::vector<std::string> names; names += "Ada","Bob","Cipher"; foreach ( const std::string& name, names ) { std::cout << "Name: " << name << std::endl; } return 0; }
Boost.Format gives you a C++ alternative to C's printf
. In the following example, first a string is printed out to the standard output and, afterwards, another string is generated. All known placeholders and format options of printf
can be used.
#include <iostream> #include <string> #include <boost/format.hpp> int main( int argc, char ** argv ) { std::cout << boost::format( "Gates: %d, Runtime: %f" ) % 12 % 3.44; std::string s = boost::str( boost::format( "Quantum costs: %d" ) % 42 ); return 0; }