Skip to content

Commit

Permalink
Update test
Browse files Browse the repository at this point in the history
  • Loading branch information
henry-yeh committed Nov 5, 2023
1 parent fe91d1a commit 75f2f2e
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 48 deletions.
20 changes: 3 additions & 17 deletions rcpsp/test.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
}
],
"source": [
"# MetaACO\n",
"# DeepACO\n",
"net_tsp = Net().to(device)\n",
"net_tsp.load_state_dict(torch.load(f'../pretrained/rcpsp/rcpsp{n_node}-5.pt', map_location=device))\n",
"avg_aco_best, duration = test(test_list, net_tsp, n_ants, t_aco)\n",
Expand Down Expand Up @@ -192,7 +192,7 @@
}
],
"source": [
"# MetaACO\n",
"# DeepACO\n",
"net_tsp = Net().to(device)\n",
"net_tsp.load_state_dict(torch.load(f'../pretrained/rcpsp/rcpsp{n_node}-5.pt', map_location=device))\n",
"avg_aco_best, duration = test(test_list, net_tsp, n_ants, t_aco)\n",
Expand Down Expand Up @@ -270,7 +270,7 @@
}
],
"source": [
"# MetaACO\n",
"# DeepACO\n",
"net_tsp = Net().to(device)\n",
"net_tsp.load_state_dict(torch.load(f'../pretrained/rcpsp/rcpsp{n_node}-5.pt', map_location=device))\n",
"avg_aco_best, duration = test(test_list, net_tsp, n_ants, t_aco)\n",
Expand Down Expand Up @@ -306,20 +306,6 @@
"for i, t in enumerate(t_aco):\n",
" print(\"T={}, average cost is {}.\".format(t, avg_aco_best[i]))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
8 changes: 4 additions & 4 deletions smtwtp/test.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"torch.manual_seed(12345)\n",
"\n",
"EPS = 1e-10\n",
"device = 'cuda:0'"
"device = 'cpu'"
]
},
{
Expand Down Expand Up @@ -80,7 +80,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"MetaACO"
"DeepACO"
]
},
{
Expand Down Expand Up @@ -168,7 +168,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"MetaACO"
"DeepACO"
]
},
{
Expand Down Expand Up @@ -256,7 +256,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"MetaACO"
"DeepACO"
]
},
{
Expand Down
47 changes: 23 additions & 24 deletions sop/test.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"import time\n",
"import torch\n",
"from torch.distributions import Categorical, kl\n",
"from d2l.torch import Animator\n",
"\n",
"from net import Net\n",
"from aco import ACO\n",
Expand All @@ -18,12 +17,12 @@
"torch.manual_seed(12345)\n",
"\n",
"EPS = 1e-10\n",
"device = 'cuda:0'"
"device = 'cpu'"
]
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -81,26 +80,26 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"MetaACO"
"DeepACO"
]
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 6,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"total duration: 148.10551619529724\n",
"T=1, average cost is 13.649788856506348.\n",
"T=10, average cost is 13.322684288024902.\n",
"T=20, average cost is 13.289615631103516.\n",
"T=30, average cost is 13.270099639892578.\n",
"T=40, average cost is 13.267578125.\n",
"T=50, average cost is 13.252917289733887.\n",
"T=100, average cost is 13.241530418395996.\n"
"total duration: 20.24020290374756\n",
"T=1, average cost is 13.569103240966797.\n",
"T=10, average cost is 13.329172134399414.\n",
"T=20, average cost is 13.287178039550781.\n",
"T=30, average cost is 13.26213264465332.\n",
"T=40, average cost is 13.24909782409668.\n",
"T=50, average cost is 13.239826202392578.\n",
"T=100, average cost is 13.237661361694336.\n"
]
}
],
Expand All @@ -127,21 +126,21 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"total duration: 146.17993807792664\n",
"T=1, average cost is 15.694759368896484.\n",
"T=10, average cost is 14.777204513549805.\n",
"T=20, average cost is 14.582863807678223.\n",
"T=30, average cost is 14.48759651184082.\n",
"T=40, average cost is 14.444717407226562.\n",
"T=50, average cost is 14.414101600646973.\n",
"T=100, average cost is 14.376885414123535.\n"
"total duration: 18.865866899490356\n",
"T=1, average cost is 15.692425727844238.\n",
"T=10, average cost is 14.792289733886719.\n",
"T=20, average cost is 14.588752746582031.\n",
"T=30, average cost is 14.473760604858398.\n",
"T=40, average cost is 14.423331260681152.\n",
"T=50, average cost is 14.39449691772461.\n",
"T=100, average cost is 14.354658126831055.\n"
]
}
],
Expand Down Expand Up @@ -173,7 +172,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.16"
"version": "3.11.3"
},
"orig_nbformat": 4,
"vscode": {
Expand Down
6 changes: 3 additions & 3 deletions tsp/test.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"torch.manual_seed(12345)\n",
"\n",
"EPS = 1e-10\n",
"device = 'cuda:0'"
"device = 'cuda:0' if torch.cuda.is_available() else 'cpu'"
]
},
{
Expand Down Expand Up @@ -84,7 +84,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"MetaACO"
"DeepACO"
]
},
{
Expand Down Expand Up @@ -178,7 +178,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.16"
"version": "3.11.3"
},
"orig_nbformat": 4,
"vscode": {
Expand Down

0 comments on commit 75f2f2e

Please sign in to comment.