ai
This commit is contained in:
parent
bcce2ac0d5
commit
9c83fe3bbe
7 changed files with 41 additions and 14 deletions
Binary file not shown.
|
@ -17,11 +17,10 @@ def ant_colony_opt(instance):
|
|||
"kroA100": (0.9, 8, 0.4, 1000, 750, 100, 30), # 21378
|
||||
"lin318": (0.9, 8, 0.4, 1000, 500, 32, 30), # 43171
|
||||
"pcb442": (0.9, 8, 0.4, 1000, 450, 24, 3), # 52466
|
||||
"pr439": (0.9, 8, 0.4, 1000, 450, 24, 2), # 11734
|
||||
"rat783": (0.9, 8, 0.4, 1000, 450, 24, 2), # 9232
|
||||
"u1060": (0.9, 8, 0.4, 1000, 350, 6, 3), # 238025
|
||||
#"fl1577": (0.9, 8, 0.4, 1000, 50, 9, 3), # 24145
|
||||
"fl1577": (0.9, 8, 0.4, 1000, 50, 10, 5), # 24145
|
||||
"pr439": (0.9, 8, 0.4, 1000, 1000, 15, 3), # 109721
|
||||
"rat783": (0.9, 8, 0.4, 1000, 300, 28, 4), # 9218
|
||||
"u1060": (0.9, 8, 0.4, 1000, 350, 8, 10), # 235506
|
||||
"fl1577": (0.9, 8, 0.4, 1000, 50, 10, 7), # 23020
|
||||
}
|
||||
|
||||
alpha, beta, evap, weight, ants, loops, optruns = params[instance.name]
|
||||
|
|
14
approach.md
Normal file
14
approach.md
Normal file
|
@ -0,0 +1,14 @@
|
|||
# System information
|
||||
|
||||
Here is a summary of the system characteristics of the machine used to measure the execution time and
|
||||
execution results for my AI cup submission:
|
||||
|
||||
| Characteristic | Value |
|
||||
| :------------- | :----------: |
|
||||
| Machine used | Macbook Pro 2018 15" |
|
||||
| OS Version | MacOS Catalina 10.15.7 |
|
||||
| Kernel | Mach 19.6.0 |
|
||||
| Interpreter used (Python wrapper) | CPython 3.8.3 (default, Jul 2 2020, 11:26:31) |
|
||||
| Compiler used (C++ companion program) | Apple clang version 12.0.0 (clang-1200.0.32.21) |
|
||||
| Compiler optimization level (C++ companion program) | `-O2` |
|
||||
| CPU | Intel i7-8750H (12) @ 2.20GHz |
|
15
execute.md
15
execute.md
|
@ -10,7 +10,7 @@ one must have the following requirements:
|
|||
acceptable compilers).
|
||||
|
||||
## Execution
|
||||
`cd` in the `code` directory and execute `python3 ./run.py` from the terminal.
|
||||
`cd` in the `code` directory and execute `python3 ./run.py all` from the terminal.
|
||||
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
|
||||
|
@ -20,6 +20,19 @@ Execution time for each problem will be computed using the same criteria used fo
|
|||
Times and lengths found will be saved in a file named `results.csv` which will be located in the same directory as
|
||||
`run.py`.
|
||||
|
||||
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.
|
||||
|
||||
## `.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.
|
||||
|
|
8
run.py
8
run.py
|
@ -3,13 +3,13 @@ import pandas as pd
|
|||
from aco.io_tsp import ProblemInstance
|
||||
from aco.TSP_solver import TSPSolver
|
||||
import os
|
||||
import sys
|
||||
|
||||
def run(show_plots=False, verbose=False):
|
||||
os.system("rm -f " + " ".join(glob.glob("sol/*") + glob.glob("c_prob/*")))
|
||||
os.system("rm -f " + " ".join(glob.glob("sol/*.sol") + glob.glob("c_prob/*.txt")))
|
||||
if sys.argv[1] == "all":
|
||||
os.system("c++ -O2 -lpthread --std=c++11 -o c_prob/aco aco.cc opt.cc")
|
||||
problems = glob.glob('./problems/*.tsp')
|
||||
|
||||
problems = ["./problems/fl1577.tsp"]
|
||||
problems = glob.glob('./problems/*.tsp') if sys.argv[1] == "all" else [f"./problems/{sys.argv[1]}.tsp"]
|
||||
|
||||
results = []
|
||||
index = []
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -5,8 +5,10 @@ execution results for my AI cup submission:
|
|||
|
||||
| Characteristic | Value |
|
||||
| :------------- | :----------: |
|
||||
| Machine used | Macbook Pro 2018 15" |
|
||||
| OS Version | MacOS Catalina 10.15.7 |
|
||||
| Kernel | Mach 19.6.0 |
|
||||
| Compiler used | Apple clang version 12.0.0 (clang-1200.0.32.21) |
|
||||
| Compiler optimization level | `-O2` |
|
||||
| Interpreter used (Python wrapper) | CPython 3.8.3 (default, Jul 2 2020, 11:26:31) |
|
||||
| Compiler used (C++ companion program) | Apple clang version 12.0.0 (clang-1200.0.32.21) |
|
||||
| Compiler optimization level (C++ companion program) | `-O2` |
|
||||
| CPU | Intel i7-8750H (12) @ 2.20GHz |
|
Reference in a new issue