diff --git a/scenario.csv b/scenario.csv index b0a4491..771624d 100644 --- a/scenario.csv +++ b/scenario.csv @@ -1,66 +1,11 @@ name,demand,service,from_,to,coord,is_depot,step -3,0,90.0,825.0,870.0,"(45.0, 70.0)",False,100 -16,0,90.0,384.0,429.0,"(20.0, 80.0)",False,6 -28,0,90.0,261.0,316.0,"(23.0, 52.0)",False,8 -13,0,90.0,652.0,721.0,"(25.0, 85.0)",False,9 -27,0,90.0,622.0,701.0,"(25.0, 55.0)",False,12 -6,0,90.0,15.0,67.0,"(42.0, 65.0)",False,13 -9,0,90.0,255.0,324.0,"(38.0, 68.0)",False,14 -21,0,90.0,10.0,73.0,"(30.0, 50.0)",False,16 -33,0,90.0,31.0,100.0,"(10.0, 40.0)",False,18 -18,0,90.0,99.0,148.0,"(18.0, 75.0)",False,19 -25,0,90.0,65.0,144.0,"(25.0, 50.0)",False,20 -22,0,90.0,914.0,965.0,"(30.0, 52.0)",False,21 -18,0,90.0,99.0,148.0,"(18.0, 75.0)",False,22 -20,0,90.0,278.0,345.0,"(15.0, 80.0)",False,23 -24,0,90.0,732.0,777.0,"(28.0, 55.0)",False,24 -26,0,90.0,169.0,224.0,"(25.0, 52.0)",False,26 -22,0,90.0,914.0,965.0,"(30.0, 52.0)",False,27 -20,0,90.0,278.0,345.0,"(15.0, 80.0)",False,28 -10,0,90.0,534.0,605.0,"(38.0, 70.0)",False,30 -18,0,90.0,99.0,148.0,"(18.0, 75.0)",False,32 -3,0,90.0,825.0,870.0,"(45.0, 70.0)",False,34 -16,0,90.0,384.0,429.0,"(20.0, 80.0)",False,35 -17,0,90.0,475.0,528.0,"(20.0, 85.0)",False,37 -25,0,90.0,65.0,144.0,"(25.0, 50.0)",False,38 -11,0,90.0,357.0,410.0,"(35.0, 66.0)",False,40 -21,0,90.0,10.0,73.0,"(30.0, 50.0)",False,41 -8,0,90.0,170.0,225.0,"(40.0, 66.0)",False,42 -34,0,90.0,87.0,158.0,"(8.0, 40.0)",False,43 -28,0,90.0,261.0,316.0,"(23.0, 52.0)",False,44 -12,0,90.0,448.0,505.0,"(35.0, 69.0)",False,46 -33,0,90.0,31.0,100.0,"(10.0, 40.0)",False,49 -33,0,90.0,31.0,100.0,"(10.0, 40.0)",False,50 -22,0,90.0,914.0,965.0,"(30.0, 52.0)",False,52 -5,0,90.0,727.0,782.0,"(42.0, 68.0)",False,53 -4,0,90.0,65.0,146.0,"(42.0, 66.0)",False,54 -3,0,90.0,825.0,870.0,"(45.0, 70.0)",False,55 -20,0,90.0,278.0,345.0,"(15.0, 80.0)",False,58 -21,0,90.0,10.0,73.0,"(30.0, 50.0)",False,60 -4,0,90.0,65.0,146.0,"(42.0, 66.0)",False,61 -10,0,90.0,534.0,605.0,"(38.0, 70.0)",False,64 -8,0,90.0,170.0,225.0,"(40.0, 66.0)",False,65 -14,0,90.0,30.0,92.0,"(22.0, 75.0)",False,68 -3,0,90.0,825.0,870.0,"(45.0, 70.0)",False,69 -3,0,90.0,825.0,870.0,"(45.0, 70.0)",False,70 -28,0,90.0,261.0,316.0,"(23.0, 52.0)",False,71 -14,0,90.0,30.0,92.0,"(22.0, 75.0)",False,72 -17,0,90.0,475.0,528.0,"(20.0, 85.0)",False,73 -32,0,90.0,200.0,237.0,"(10.0, 35.0)",False,79 -17,0,90.0,475.0,528.0,"(20.0, 85.0)",False,80 -13,0,90.0,652.0,721.0,"(25.0, 85.0)",False,81 -25,0,90.0,65.0,144.0,"(25.0, 50.0)",False,82 -30,0,90.0,358.0,405.0,"(20.0, 50.0)",False,83 -21,0,90.0,10.0,73.0,"(30.0, 50.0)",False,84 -14,0,90.0,30.0,92.0,"(22.0, 75.0)",False,85 -23,0,90.0,812.0,883.0,"(28.0, 52.0)",False,86 -2,0,90.0,912.0,967.0,"(45.0, 68.0)",False,87 -22,0,90.0,914.0,965.0,"(30.0, 52.0)",False,88 -32,0,90.0,200.0,237.0,"(10.0, 35.0)",False,89 -10,0,90.0,534.0,605.0,"(38.0, 70.0)",False,90 -34,0,90.0,87.0,158.0,"(8.0, 40.0)",False,91 -3,0,90.0,825.0,870.0,"(45.0, 70.0)",False,92 -24,0,90.0,732.0,777.0,"(28.0, 55.0)",False,94 -24,0,90.0,732.0,777.0,"(28.0, 55.0)",False,96 -19,0,90.0,179.0,254.0,"(15.0, 75.0)",False,97 - +3,50,90.0,825.0,870.0,"(45.0, 70.0)",False,50 +16,50,90.0,384.0,429.0,"(20.0, 80.0)",False,100 +28,50,90.0,261.0,316.0,"(23.0, 52.0)",False,150 +13,50,90.0,652.0,721.0,"(25.0, 85.0)",False,200 +27,50,90.0,622.0,701.0,"(25.0, 55.0)",False,250 +6,50,90.0,15.0,67.0,"(42.0, 65.0)",False,300 +9,50,90.0,255.0,324.0,"(38.0, 68.0)",False,350 +21,50,90.0,10.0,73.0,"(30.0, 50.0)",False,400 +33,50,90.0,31.0,100.0,"(10.0, 40.0)",False,450 +18,50,90.0,99.0,148.0,"(18.0, 75.0)",False,500 diff --git a/scenario_decrease.csv b/scenario_decrease.csv new file mode 100644 index 0000000..b1cae9d --- /dev/null +++ b/scenario_decrease.csv @@ -0,0 +1,11 @@ +name,demand,service,from_,to,coord,is_depot,step +3,10,90.0,825.0,870.0,"(45.0, 70.0)",False,50 +16,10,90.0,384.0,429.0,"(20.0, 80.0)",False,100 +28,10,90.0,261.0,316.0,"(23.0, 52.0)",False,150 +13,10,90.0,652.0,721.0,"(25.0, 85.0)",False,200 +27,10,90.0,622.0,701.0,"(25.0, 55.0)",False,250 +6,10,90.0,15.0,67.0,"(42.0, 65.0)",False,300 +9,10,90.0,255.0,324.0,"(38.0, 68.0)",False,350 +21,10,90.0,10.0,73.0,"(30.0, 50.0)",False,400 +33,10,90.0,31.0,100.0,"(10.0, 40.0)",False,450 +18,10,90.0,99.0,148.0,"(18.0, 75.0)",False,500 diff --git a/scenario_increase.csv b/scenario_increase.csv new file mode 100644 index 0000000..0d67445 --- /dev/null +++ b/scenario_increase.csv @@ -0,0 +1,11 @@ +name,demand,service,from_,to,coord,is_depot,step +3,50,90.0,825.0,870.0,"(45.0, 70.0)",False,50 +16,50,90.0,384.0,429.0,"(20.0, 80.0)",False,100 +28,50,90.0,261.0,316.0,"(23.0, 52.0)",False,150 +16,10,90.0,652.0,721.0,"(25.0, 85.0)",False,200 +28,10,90.0,622.0,701.0,"(25.0, 55.0)",False,250 +3,50,90.0,15.0,67.0,"(42.0, 65.0)",False,300 +9,50,90.0,255.0,324.0,"(38.0, 68.0)",False,350 +21,50,90.0,10.0,73.0,"(30.0, 50.0)",False,400 +9,10,90.0,31.0,100.0,"(10.0, 40.0)",False,450 +21,50,90.0,99.0,148.0,"(18.0, 75.0)",False,500 diff --git a/scenario_mix.csv b/scenario_mix.csv new file mode 100644 index 0000000..771624d --- /dev/null +++ b/scenario_mix.csv @@ -0,0 +1,11 @@ +name,demand,service,from_,to,coord,is_depot,step +3,50,90.0,825.0,870.0,"(45.0, 70.0)",False,50 +16,50,90.0,384.0,429.0,"(20.0, 80.0)",False,100 +28,50,90.0,261.0,316.0,"(23.0, 52.0)",False,150 +13,50,90.0,652.0,721.0,"(25.0, 85.0)",False,200 +27,50,90.0,622.0,701.0,"(25.0, 55.0)",False,250 +6,50,90.0,15.0,67.0,"(42.0, 65.0)",False,300 +9,50,90.0,255.0,324.0,"(38.0, 68.0)",False,350 +21,50,90.0,10.0,73.0,"(30.0, 50.0)",False,400 +33,50,90.0,31.0,100.0,"(10.0, 40.0)",False,450 +18,50,90.0,99.0,148.0,"(18.0, 75.0)",False,500 diff --git a/testing.ipynb b/testing.ipynb index 3cd68b1..27222f4 100644 --- a/testing.ipynb +++ b/testing.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "code", - "execution_count": 2, + "execution_count": 1, "metadata": {}, "outputs": [], "source": [ @@ -12,7 +12,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 2, "metadata": {}, "outputs": [], "source": [ @@ -21,7 +21,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 3, "metadata": {}, "outputs": [], "source": [ @@ -36,7 +36,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 4, "metadata": {}, "outputs": [ { @@ -133,13 +133,13 @@ "4 5 42.0 68.0 10.0 727.0 782.0 90.0" ] }, - "execution_count": 5, + "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "csv_path = Path('medium.csv')\n", + "csv_path = Path('small.csv')\n", "problem = pd.read_csv(csv_path)\n", "problem.head()\n" ] @@ -160,9 +160,65 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 5, + "metadata": {}, + "outputs": [], + "source": [ + "import random\n", + "from swarmlib_.aco4tsp.aco_algorithm import ACOAlgorithm\n", + "from swarmlib_.aco4tsp.vehicle import Vehicle\n", + "import numpy as np\n", + "from itertools import product\n", + "\n", + "def evaluate_scenario(path: Path):\n", + " vehicles = [Vehicle(50, 1) for _ in range(10)]\n", + " config = {\n", + " 'ant_number': 5,\n", + " 'num_vehicles': 10,\n", + " 'iteration_number': 500,\n", + " 'capacity': 50,\n", + " 'commit_freq': 10,\n", + " 'vehicles': vehicles,\n", + " 'instance_path': 'small.csv',\n", + " 'rho': 0.5,\n", + " 'alpha': 0.5,\n", + " 'beta': 0.5,\n", + " }\n", + "\n", + " \n", + " random.seed(42)\n", + " for alpha, rho, beta in product(np.arange(0.1, 1, 0.3), np.arange(0.1, 1, 0.3), np.arange(0.1, 1, 0.3)):\n", + " wandb.init(\n", + " project=\"dynamic aco\",\n", + " config={\n", + " **config,\n", + " 'rho': rho,\n", + " 'alpha': alpha,\n", + " 'beta': beta,\n", + " },\n", + " tags=[f'03-06-2023-{path.stem}']\n", + " )\n", + " # Logic goes here\n", + " try:\n", + " solver = ACOAlgorithm(**config, scenario_input_file=path)\n", + " best_plan, _ = solver.solve()\n", + " finally:\n", + " wandb.finish()\n" + ] + }, + { + "cell_type": "code", + "execution_count": 6, "metadata": {}, "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "Failed to detect the name of this notebook, you can set it manually with the WANDB_NOTEBOOK_NAME environment variable to enable code saving.\n", + "\u001b[34m\u001b[1mwandb\u001b[0m: Currently logged in as: \u001b[33mbohdanforostianyi\u001b[0m (\u001b[33mglider-agh\u001b[0m). Use \u001b[1m`wandb login --relogin`\u001b[0m to force relogin\n" + ] + }, { "data": { "text/html": [ @@ -191,7 +247,7 @@ { "data": { "text/html": [ - "Run data is saved locally in /home/bohdan/studies/sem8/io/wandb/run-20230603_181502-uwqcnvag" + "Run data is saved locally in /home/bohdan/studies/sem8/io/wandb/run-20230603_192225-5jpo0i5b" ], "text/plain": [ "" @@ -203,7 +259,7 @@ { "data": { "text/html": [ - "Syncing run floral-spaceship-205 to Weights & Biases (docs)
" + "Syncing run worldly-silence-211 to Weights & Biases (docs)
" ], "text/plain": [ "" @@ -227,7 +283,7 @@ { "data": { "text/html": [ - " View run at https://wandb.ai/glider-agh/dynamic%20aco/runs/uwqcnvag" + " View run at https://wandb.ai/glider-agh/dynamic%20aco/runs/5jpo0i5b" ], "text/plain": [ "" @@ -235,68 +291,93 @@ }, "metadata": {}, "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "Waiting for W&B process to finish... (success)." + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "c28f19139a8d4a29a55a3a91ddcc549c", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "VBox(children=(Label(value='0.002 MB of 0.011 MB uploaded (0.000 MB deduped)\\r'), FloatProgress(value=0.145402…" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + " View run worldly-silence-211 at: https://wandb.ai/glider-agh/dynamic%20aco/runs/5jpo0i5b
Synced 5 W&B file(s), 0 media file(s), 0 artifact file(s) and 0 other file(s)" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "Find logs at: ./wandb/run-20230603_192225-5jpo0i5b/logs" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "ename": "KeyError", + "evalue": "'cust'", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mKeyError\u001b[0m Traceback (most recent call last)", + "File \u001b[0;32m~/Soft/conda/envs/lux_ai/lib/python3.9/site-packages/pandas/core/indexes/base.py:3802\u001b[0m, in \u001b[0;36mIndex.get_loc\u001b[0;34m(self, key, method, tolerance)\u001b[0m\n\u001b[1;32m 3801\u001b[0m \u001b[39mtry\u001b[39;00m:\n\u001b[0;32m-> 3802\u001b[0m \u001b[39mreturn\u001b[39;00m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49m_engine\u001b[39m.\u001b[39;49mget_loc(casted_key)\n\u001b[1;32m 3803\u001b[0m \u001b[39mexcept\u001b[39;00m \u001b[39mKeyError\u001b[39;00m \u001b[39mas\u001b[39;00m err:\n", + "File \u001b[0;32m~/Soft/conda/envs/lux_ai/lib/python3.9/site-packages/pandas/_libs/index.pyx:138\u001b[0m, in \u001b[0;36mpandas._libs.index.IndexEngine.get_loc\u001b[0;34m()\u001b[0m\n", + "File \u001b[0;32m~/Soft/conda/envs/lux_ai/lib/python3.9/site-packages/pandas/_libs/index.pyx:165\u001b[0m, in \u001b[0;36mpandas._libs.index.IndexEngine.get_loc\u001b[0;34m()\u001b[0m\n", + "File \u001b[0;32mpandas/_libs/hashtable_class_helper.pxi:5745\u001b[0m, in \u001b[0;36mpandas._libs.hashtable.PyObjectHashTable.get_item\u001b[0;34m()\u001b[0m\n", + "File \u001b[0;32mpandas/_libs/hashtable_class_helper.pxi:5753\u001b[0m, in \u001b[0;36mpandas._libs.hashtable.PyObjectHashTable.get_item\u001b[0;34m()\u001b[0m\n", + "\u001b[0;31mKeyError\u001b[0m: 'cust'", + "\nThe above exception was the direct cause of the following exception:\n", + "\u001b[0;31mKeyError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn[6], line 2\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[39mfor\u001b[39;00m scenario \u001b[39min\u001b[39;00m [\u001b[39m'\u001b[39m\u001b[39mscenario_mix.csv\u001b[39m\u001b[39m'\u001b[39m, \u001b[39m'\u001b[39m\u001b[39mscenario_decrease.csv\u001b[39m\u001b[39m'\u001b[39m]:\n\u001b[0;32m----> 2\u001b[0m evaluate_scenario(Path(scenario))\n", + "Cell \u001b[0;32mIn[5], line 37\u001b[0m, in \u001b[0;36mevaluate_scenario\u001b[0;34m(path)\u001b[0m\n\u001b[1;32m 35\u001b[0m \u001b[39m# Logic goes here\u001b[39;00m\n\u001b[1;32m 36\u001b[0m \u001b[39mtry\u001b[39;00m:\n\u001b[0;32m---> 37\u001b[0m solver \u001b[39m=\u001b[39m ACOAlgorithm(\u001b[39m*\u001b[39;49m\u001b[39m*\u001b[39;49mconfig, scenario_input_file\u001b[39m=\u001b[39;49m\u001b[39m'\u001b[39;49m\u001b[39mscenario.csv\u001b[39;49m\u001b[39m'\u001b[39;49m)\n\u001b[1;32m 38\u001b[0m best_plan, _ \u001b[39m=\u001b[39m solver\u001b[39m.\u001b[39msolve()\n\u001b[1;32m 39\u001b[0m \u001b[39mfinally\u001b[39;00m:\n", + "File \u001b[0;32m~/studies/sem8/io/swarmlib_/aco4tsp/aco_algorithm.py:48\u001b[0m, in \u001b[0;36mACOAlgorithm.__init__\u001b[0;34m(self, instance_path, vehicles, commit_freq, capacity, scenario_input_file, **kwargs)\u001b[0m\n\u001b[1;32m 45\u001b[0m \u001b[39msuper\u001b[39m()\u001b[39m.\u001b[39m\u001b[39m__init__\u001b[39m(\u001b[39m*\u001b[39m\u001b[39m*\u001b[39mkwargs)\n\u001b[1;32m 46\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_ant_number \u001b[39m=\u001b[39m kwargs[\u001b[39m'\u001b[39m\u001b[39mant_number\u001b[39m\u001b[39m'\u001b[39m] \u001b[39m# Number of ants\u001b[39;00m\n\u001b[0;32m---> 48\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_env \u001b[39m=\u001b[39m DynamicVrpEnv(instance_path, scenario_input_file\u001b[39m=\u001b[39;49mscenario_input_file)\n\u001b[1;32m 49\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_rho \u001b[39m=\u001b[39m kwargs\u001b[39m.\u001b[39mget(\u001b[39m'\u001b[39m\u001b[39mrho\u001b[39m\u001b[39m'\u001b[39m, \u001b[39m0.5\u001b[39m) \u001b[39m# evaporation rate\u001b[39;00m\n\u001b[1;32m 50\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_alpha \u001b[39m=\u001b[39m kwargs\u001b[39m.\u001b[39mget(\u001b[39m'\u001b[39m\u001b[39malpha\u001b[39m\u001b[39m'\u001b[39m, \u001b[39m0.5\u001b[39m) \u001b[39m# used for edge detection\u001b[39;00m\n", + "File \u001b[0;32m~/studies/sem8/io/swarmlib_/aco4tsp/dynamic_vrp_env/env.py:30\u001b[0m, in \u001b[0;36mDynamicVrpEnv.__init__\u001b[0;34m(self, data_file, scenario_input_file)\u001b[0m\n\u001b[1;32m 28\u001b[0m \u001b[39melse\u001b[39;00m:\n\u001b[1;32m 29\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_scenario \u001b[39m=\u001b[39m \u001b[39mNone\u001b[39;00m\n\u001b[0;32m---> 30\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_routes_graph \u001b[39m=\u001b[39m RoutesGraph(\u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49m_initial_df)\n\u001b[1;32m 31\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_history \u001b[39m=\u001b[39m pd\u001b[39m.\u001b[39mDataFrame()\n", + "File \u001b[0;32m~/studies/sem8/io/swarmlib_/aco4tsp/dynamic_vrp_env/routes_graph.py:47\u001b[0m, in \u001b[0;36mRoutesGraph.__init__\u001b[0;34m(self, df)\u001b[0m\n\u001b[1;32m 45\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mdepot \u001b[39m=\u001b[39m \u001b[39m1\u001b[39m\n\u001b[1;32m 46\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_df \u001b[39m=\u001b[39m df\n\u001b[0;32m---> 47\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mnetworkx_graph \u001b[39m=\u001b[39m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49m_create_graph(df)\n\u001b[1;32m 48\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m__lock \u001b[39m=\u001b[39m RLock()\n", + "File \u001b[0;32m~/studies/sem8/io/swarmlib_/aco4tsp/dynamic_vrp_env/routes_graph.py:59\u001b[0m, in \u001b[0;36mRoutesGraph._create_graph\u001b[0;34m(self, df)\u001b[0m\n\u001b[1;32m 57\u001b[0m G\u001b[39m.\u001b[39mgraph[\u001b[39m'\u001b[39m\u001b[39mname\u001b[39m\u001b[39m'\u001b[39m] \u001b[39m=\u001b[39m \u001b[39m'\u001b[39m\u001b[39mACO\u001b[39m\u001b[39m'\u001b[39m\n\u001b[1;32m 58\u001b[0m \u001b[39m# set up a map from original node name to new node name\u001b[39;00m\n\u001b[0;32m---> 59\u001b[0m nodes \u001b[39m=\u001b[39m \u001b[39mlist\u001b[39m(df[\u001b[39m'\u001b[39;49m\u001b[39mcust\u001b[39;49m\u001b[39m'\u001b[39;49m]\u001b[39m.\u001b[39mto_list())\n\u001b[1;32m 60\u001b[0m names \u001b[39m=\u001b[39m {n: n \u001b[39mfor\u001b[39;00m n \u001b[39min\u001b[39;00m nodes}\n\u001b[1;32m 62\u001b[0m coords \u001b[39m=\u001b[39m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_get_coords()\n", + "File \u001b[0;32m~/Soft/conda/envs/lux_ai/lib/python3.9/site-packages/pandas/core/frame.py:3807\u001b[0m, in \u001b[0;36mDataFrame.__getitem__\u001b[0;34m(self, key)\u001b[0m\n\u001b[1;32m 3805\u001b[0m \u001b[39mif\u001b[39;00m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mcolumns\u001b[39m.\u001b[39mnlevels \u001b[39m>\u001b[39m \u001b[39m1\u001b[39m:\n\u001b[1;32m 3806\u001b[0m \u001b[39mreturn\u001b[39;00m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_getitem_multilevel(key)\n\u001b[0;32m-> 3807\u001b[0m indexer \u001b[39m=\u001b[39m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mcolumns\u001b[39m.\u001b[39;49mget_loc(key)\n\u001b[1;32m 3808\u001b[0m \u001b[39mif\u001b[39;00m is_integer(indexer):\n\u001b[1;32m 3809\u001b[0m indexer \u001b[39m=\u001b[39m [indexer]\n", + "File \u001b[0;32m~/Soft/conda/envs/lux_ai/lib/python3.9/site-packages/pandas/core/indexes/base.py:3804\u001b[0m, in \u001b[0;36mIndex.get_loc\u001b[0;34m(self, key, method, tolerance)\u001b[0m\n\u001b[1;32m 3802\u001b[0m \u001b[39mreturn\u001b[39;00m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_engine\u001b[39m.\u001b[39mget_loc(casted_key)\n\u001b[1;32m 3803\u001b[0m \u001b[39mexcept\u001b[39;00m \u001b[39mKeyError\u001b[39;00m \u001b[39mas\u001b[39;00m err:\n\u001b[0;32m-> 3804\u001b[0m \u001b[39mraise\u001b[39;00m \u001b[39mKeyError\u001b[39;00m(key) \u001b[39mfrom\u001b[39;00m \u001b[39merr\u001b[39;00m\n\u001b[1;32m 3805\u001b[0m \u001b[39mexcept\u001b[39;00m \u001b[39mTypeError\u001b[39;00m:\n\u001b[1;32m 3806\u001b[0m \u001b[39m# If we have a listlike key, _check_indexing_error will raise\u001b[39;00m\n\u001b[1;32m 3807\u001b[0m \u001b[39m# InvalidIndexError. Otherwise we fall through and re-raise\u001b[39;00m\n\u001b[1;32m 3808\u001b[0m \u001b[39m# the TypeError.\u001b[39;00m\n\u001b[1;32m 3809\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_check_indexing_error(key)\n", + "\u001b[0;31mKeyError\u001b[0m: 'cust'" + ] } ], "source": [ - "from swarmlib_.aco4tsp.aco_algorithm import ACOAlgorithm\n", - "from swarmlib_.aco4tsp.vehicle import Vehicle\n", - "import numpy as np\n", - "from itertools import product\n", - "\n", - "vehicles = [Vehicle(50, 1) for _ in range(10)]\n", - "config = {\n", - " 'ant_number': 5,\n", - " 'num_vehicles': 10,\n", - " 'iteration_number': 500,\n", - " 'capacity': 50,\n", - " 'commit_freq': 10,\n", - " 'vehicles': vehicles,\n", - " 'instance_path': csv_path,\n", - " 'rho': 0.5,\n", - " 'alpha': 0.5,\n", - " 'beta': 0.5,\n", - "}\n", - "\n", - "import random\n", - "random.seed(42)\n", - "for alpha, rho, beta in [[1,1,1]]: #product(np.arange(0.1, 1, 0.3), np.arange(0.1, 1, 0.3), np.arange(0.1, 1, 0.3)):\n", - " wandb.init(\n", - " project=\"dynamic aco\",\n", - " config={\n", - " **config,\n", - " 'rho': rho,\n", - " 'alpha': alpha,\n", - " 'beta': beta,\n", - " },\n", - " tags=[f'01-06-2023-custom-scenario']\n", - " )\n", - " # Logic goes here\n", - " try:\n", - " solver = ACOAlgorithm(**config, scenario_input_file='scenario.csv')\n", - " best_plan, _ = solver.solve()\n", - " finally:\n", - " wandb.finish()" + "for scenario in ['scenario_mix.csv', 'scenario_decrease.csv']:\n", + " evaluate_scenario(Path(scenario))" ] }, { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "wandb.finish()" - ] - }, - { - "attachments": {}, "cell_type": "markdown", "metadata": {}, - "source": [ - "# TODO\n", - "\n", - "[ ] Szkic raportu\n", - "[ ] Jak powinien wyglądać scenariusz" - ] + "source": [] } ], "metadata": {