This repository has been archived on 2021-10-31. You can view files and clone it, but cannot push or open issues or pull requests.
AICup/execute.md

49 lines
2 KiB
Markdown
Raw Normal View History

2020-12-21 14:46:50 +00:00
# Instructions for execution
## Requirements
In order to reproduce the results reported in the Excel table,
one must have the following requirements:
- A Python 3 interpreter and all Python dependencies required for the `AI2020BsC` repository installed, namely
`time`, `matplotlib` and `numpy`;
- A working C++11 or greater compiler accessible from the `c++` command (Modern versions of clang and g++ are both
acceptable compilers).
## Execution
2020-12-21 15:52:19 +00:00
`cd` in the `code` directory and execute `python3 ./run.py all` from the terminal.
2020-12-21 14:46:50 +00:00
The script will automatically compile the C++ companion program and start the TSP computation for each problem.
Results will be saved in `<problemname>.sol` files where `<problemname>` is respectively the name
of the problem solved.
Execution time for each problem will be computed using the same criteria used for the original `AI2020BsC` repository.
Times and lengths found will be saved in a file named `results.csv` which will be located in the same directory as
`run.py`.
2020-12-21 15:52:19 +00:00
Should it be necessary to run the TSP algorithm problem by problem (e.g. if the execution time must be measured by an
external program,
execute first the command:
```bash
c++ -O2 -lpthread --std=c++11 -o c_prob/aco aco.cc opt.cc
```
Then execute `python3 run.py <problem name>` where `<problem name>` is the problem name without extension
(e.g. `rat783`)
The `c++` may not be repeated when running multiple problems in a one-by-one fashion.
2020-12-21 14:46:50 +00:00
## `.sol` file contents
Solution files are made up of just one line, containing a valid Python expression representing an array.
The array in question contains the order in which cities must be visited, representing each city by its number.
The array starts and ends with the starting city of the tour.
Here is the Backus Naur grammar for `.sol` files:
```
<.sol file> ::= <city array> '\n'
<city array> ::= '[' <start city> ", " <cities> <start city> ']'
<cities> ::= <city> ", " <cities> | <city> ", "
<start city> ::= unsigned integer
<city> ::= unsigned integer
```