diff --git a/Workshop - 1 (Random, BFS, DFS, DP).ipynb b/Workshop - 1 (Random, BFS, DFS, DP).ipynb index 4faa6ee..650c534 100644 --- a/Workshop - 1 (Random, BFS, DFS, DP).ipynb +++ b/Workshop - 1 (Random, BFS, DFS, DP).ipynb @@ -69,7 +69,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "There are problems at different levels. **3 simple, 2 medium, 1 difficult**." + "There are problems at different levels. **3 easy, 2 medium, 1 difficult**." ] }, { @@ -92,7 +92,7 @@ "metadata": {}, "outputs": [], "source": [ - "ulysses16 = np.array(load_data(\"./template/data/simple/ulysses16.tsp\"))" + "ulysses16 = np.array(load_data(\"./template/data/easy/ulysses16.tsp\"))" ] }, { @@ -313,7 +313,7 @@ }, "outputs": [], "source": [ - "tsp_file = './template/data/simple/ulysses16.tsp'" + "tsp_file = './template/data/easy/ulysses16.tsp'" ] }, { @@ -399,7 +399,7 @@ "metadata": {}, "outputs": [], "source": [ - "tsp_file = './template/data/simple/ulysses16.tsp'" + "tsp_file = './template/data/easy/ulysses16.tsp'" ] }, { @@ -492,7 +492,7 @@ }, "outputs": [], "source": [ - "tsp_file = './template/data/simple/ulysses16.tsp'" + "tsp_file = './template/data/easy/ulysses16.tsp'" ] }, { @@ -604,7 +604,7 @@ "metadata": {}, "outputs": [], "source": [ - "tsp_file = './template/data/simple/ulysses16.tsp'" + "tsp_file = './template/data/easy/ulysses16.tsp'" ] }, { @@ -709,7 +709,7 @@ "metadata": {}, "outputs": [], "source": [ - "tsp_file = './template/data/simple/ulysses16.tsp'" + "tsp_file = './template/data/easy/ulysses16.tsp'" ] }, { @@ -782,7 +782,7 @@ "metadata": {}, "outputs": [], "source": [ - "tsp_problem = './template/data/simple/ulysses16.tsp'" + "tsp_problem = './template/data/easy/ulysses16.tsp'" ] }, { @@ -954,7 +954,7 @@ "metadata": {}, "outputs": [], "source": [ - "# Simple\n", + "# Easy\n", "# ulysses16: 77 (BFS), 84 (DFS)\n", "# att48: 39236 (BFS), 40763 (DFS)\n", "# st70: 761 (BFS), 901 (DFS)\n", diff --git a/Workshop - 2 (UCS, A, Hill-Climbing).ipynb b/Workshop - 2 (UCS, A, Hill-Climbing).ipynb index cf10744..06d9682 100644 --- a/Workshop - 2 (UCS, A, Hill-Climbing).ipynb +++ b/Workshop - 2 (UCS, A, Hill-Climbing).ipynb @@ -69,7 +69,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "There are problems at different levels. **3 simple, 2 medium, 1 difficult**." + "There are problems at different levels. **3 easy, 2 medium, 1 difficult**." ] }, { @@ -92,7 +92,7 @@ "metadata": {}, "outputs": [], "source": [ - "ulysses16 = np.array(load_data(\"./template/data/simple/ulysses16.tsp\"))" + "ulysses16 = np.array(load_data(\"./template/data/easy/ulysses16.tsp\"))" ] }, { @@ -315,7 +315,7 @@ }, "outputs": [], "source": [ - "tsp_file = './template/data/simple/ulysses16.tsp'" + "tsp_file = './template/data/easy/ulysses16.tsp'" ] }, { @@ -430,7 +430,7 @@ "metadata": {}, "outputs": [], "source": [ - "tsp_file = './template/data/simple/ulysses16.tsp'" + "tsp_file = './template/data/easy/ulysses16.tsp'" ] }, { @@ -548,7 +548,7 @@ "metadata": {}, "outputs": [], "source": [ - "tsp_file = './template/data/simple/ulysses16.tsp'" + "tsp_file = './template/data/easy/ulysses16.tsp'" ] }, { @@ -674,7 +674,7 @@ "metadata": {}, "outputs": [], "source": [ - "tsp_file = './template/data/simple/ulysses16.tsp'" + "tsp_file = './template/data/easy/ulysses16.tsp'" ] }, { @@ -747,7 +747,7 @@ "metadata": {}, "outputs": [], "source": [ - "tsp_problem = './template/data/simple/ulysses16.tsp'" + "tsp_problem = './template/data/easy/ulysses16.tsp'" ] }, { @@ -892,7 +892,7 @@ "metadata": {}, "outputs": [], "source": [ - "# Simple\n", + "# Easy\n", "# ulysses16: 77.12 (UCS-BFS), 77.02 (A-Star)\n", "# att48: 39236 (UCS-BFS), 47853 (A-Star)\n", "# st70: 761 (UCS-BFS), time-out (A-Star)\n", diff --git a/Workshop - 4 (TSP SA).ipynb b/Workshop - 4 (TSP SA).ipynb index fc21548..2343f09 100644 --- a/Workshop - 4 (TSP SA).ipynb +++ b/Workshop - 4 (TSP SA).ipynb @@ -69,7 +69,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "There are problems at different levels. **3 simple, 2 medium, 1 difficult**." + "There are problems at different levels. **3 easy, 2 medium, 1 difficult**." ] }, { @@ -92,7 +92,7 @@ "metadata": {}, "outputs": [], "source": [ - "ulysses16 = np.array(load_data(\"./template/data/simple/ulysses16.tsp\"))" + "ulysses16 = np.array(load_data(\"./template/data/easy/ulysses16.tsp\"))" ] }, { @@ -309,7 +309,7 @@ "metadata": {}, "outputs": [], "source": [ - "tsp_file = './template/data/simple/ulysses16.tsp'" + "tsp_file = './template/data/easy/ulysses16.tsp'" ] }, { @@ -444,7 +444,7 @@ "metadata": {}, "outputs": [], "source": [ - "tsp_file = './template/data/simple/ulysses16.tsp'" + "tsp_file = './template/data/easy/ulysses16.tsp'" ] }, { @@ -521,7 +521,7 @@ "metadata": {}, "outputs": [], "source": [ - "tsp_file = './template/data/simple/ulysses16.tsp'" + "tsp_file = './template/data/easy/ulysses16.tsp'" ] }, { diff --git a/Workshop - 5 (ACO, PSO).ipynb b/Workshop - 5 (ACO, PSO).ipynb index 865c9b5..ac2c89d 100644 --- a/Workshop - 5 (ACO, PSO).ipynb +++ b/Workshop - 5 (ACO, PSO).ipynb @@ -69,7 +69,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "There are problems at different levels. **3 simple, 2 medium, 1 difficult**." + "There are problems at different levels. **3 easy, 2 medium, 1 difficult**." ] }, { @@ -92,7 +92,7 @@ "metadata": {}, "outputs": [], "source": [ - "ulysses16 = np.array(load_data(\"./template/data/simple/ulysses16.tsp\"))" + "ulysses16 = np.array(load_data(\"./template/data/easy/ulysses16.tsp\"))" ] }, { @@ -311,7 +311,7 @@ }, "outputs": [], "source": [ - "tsp_file = './template/data/simple/ulysses16.tsp'" + "tsp_file = './template/data/easy/ulysses16.tsp'" ] }, { @@ -498,7 +498,7 @@ "metadata": {}, "outputs": [], "source": [ - "tsp_file = './template/data/simple/ulysses16.tsp'" + "tsp_file = './template/data/easy/ulysses16.tsp'" ] }, { @@ -564,7 +564,7 @@ "metadata": {}, "outputs": [], "source": [ - "tsp_problem = './template/data/simple/ulysses16.tsp'" + "tsp_problem = './template/data/easy/ulysses16.tsp'" ] }, { diff --git a/Workshop - 6 (GA, SOM).ipynb b/Workshop - 6 (GA, SOM).ipynb index d5dca89..ebc33bb 100644 --- a/Workshop - 6 (GA, SOM).ipynb +++ b/Workshop - 6 (GA, SOM).ipynb @@ -69,7 +69,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "There are problems at different levels. **3 simple, 2 medium, 1 difficult**." + "There are problems at different levels. **3 easy, 2 medium, 1 difficult**." ] }, { @@ -92,7 +92,7 @@ "metadata": {}, "outputs": [], "source": [ - "ulysses16 = np.array(load_data(\"./template/data/simple/ulysses16.tsp\"))" + "ulysses16 = np.array(load_data(\"./template/data/easy/ulysses16.tsp\"))" ] }, { @@ -309,7 +309,7 @@ "metadata": {}, "outputs": [], "source": [ - "tsp_file = './template/data/simple/ulysses16.tsp'" + "tsp_file = './template/data/easy/ulysses16.tsp'" ] }, { @@ -524,7 +524,7 @@ "metadata": {}, "outputs": [], "source": [ - "tsp_problem = \"./template/data/simple/ulysses16.tsp\"" + "tsp_problem = \"./template/data/easy/ulysses16.tsp\"" ] }, { @@ -621,7 +621,7 @@ "metadata": {}, "outputs": [], "source": [ - "tsp_problem = './template/data/simple/ulysses16.tsp'" + "tsp_problem = './template/data/easy/ulysses16.tsp'" ] }, { diff --git a/template/data/simple/att48.tsp b/template/data/easy/att48.tsp similarity index 100% rename from template/data/simple/att48.tsp rename to template/data/easy/att48.tsp diff --git a/template/data/simple/st70.tsp b/template/data/easy/st70.tsp similarity index 100% rename from template/data/simple/st70.tsp rename to template/data/easy/st70.tsp diff --git a/template/data/simple/ulysses16.tsp b/template/data/easy/ulysses16.tsp similarity index 100% rename from template/data/simple/ulysses16.tsp rename to template/data/easy/ulysses16.tsp diff --git a/template/main.py b/template/main.py index 32851b7..22acfdb 100644 --- a/template/main.py +++ b/template/main.py @@ -9,18 +9,18 @@ if __name__ == "__main__": parser = argparse.ArgumentParser() - parser.add_argument('-s', '--simple', action='store_true', help='Benchmark all simple level TSP') + parser.add_argument('-e', '--easy', action='store_true', help='Benchmark all easy level TSP') parser.add_argument('-m', '--medium', action='store_true', help='Benchmark all medium level TSP') parser.add_argument('-d', '--difficult', action='store_true', help='Benchmark all difficult level TSP') args = parser.parse_args() - if (args.simple): - TSP_Bench_PATH("./data/simple/", MyModel, timeout=60) + if (args.easy): + TSP_Bench_PATH("./data/easy/", MyModel, timeout=60) if (args.medium): TSP_Bench_PATH("./data/medium/", MyModel, timeout=180) if (args.difficult): - TSP_Bench_PATH("data/difficult/", MyModel, timeout=300) + TSP_Bench_PATH("./data/difficult/", MyModel, timeout=300) - if( (not args.simple) and (not args.medium) and (not args.difficult) ): + if( (not args.easy) and (not args.medium) and (not args.difficult) ): TSP_Bench_ALL('./', MyModel) diff --git a/template/model/my_model.py b/template/model/my_model.py index a0fcc62..301adec 100644 --- a/template/model/my_model.py +++ b/template/model/my_model.py @@ -1,5 +1,6 @@ import math -import random +import numpy as np + from model.base_model import Model class MyModel(Model): diff --git a/template/tsp.py b/template/tsp.py index 2fbade1..1dd746c 100644 --- a/template/tsp.py +++ b/template/tsp.py @@ -51,7 +51,7 @@ def TSP(tsp_file, model, timeout=60): with open('output/' + os.path.splitext(os.path.basename(tsp_file))[0] + '.txt', "w") as outfile: outfile.write("-3") elif (len(best_solution) == 0): - print(exec) + print(exc) log("No Answer -1") with open('output/' + os.path.splitext(os.path.basename(tsp_file))[0] + '.txt', "w") as outfile: outfile.write("-1") @@ -145,19 +145,19 @@ def TSP_Bench_ALL(root, model): fitness_lists_all = [] times_all = [] - best_solutions_simple, fitness_lists_simple, times_simple = TSP_Bench_PATH(os.path.join(root, "data/simple/"), model, timeout=60) + best_solutions_easy, fitness_lists_easy, times_easy = TSP_Bench_PATH(os.path.join(root, "data/easy/"), model, timeout=60) best_solutions_medium, fitness_lists_medium, times_medium = TSP_Bench_PATH(os.path.join(root, "data/medium/"), model, timeout=180) best_solutions_difficult, fitness_lists_difficult, times_difficult = TSP_Bench_PATH(os.path.join(root, "data/difficult/"), model, timeout=300) - best_solutions_all.append(best_solutions_simple) + best_solutions_all.append(best_solutions_easy) best_solutions_all.append(best_solutions_medium) best_solutions_all.append(best_solutions_difficult) - fitness_lists_all.append(fitness_lists_simple) + fitness_lists_all.append(fitness_lists_easy) fitness_lists_all.append(fitness_lists_medium) fitness_lists_all.append(fitness_lists_difficult) - times_all.append(times_simple) + times_all.append(times_easy) times_all.append(times_medium) times_all.append(times_difficult) diff --git a/template/tsp.pyc b/template/tsp.pyc new file mode 100644 index 0000000..3bfd491 Binary files /dev/null and b/template/tsp.pyc differ