Skip to content

Commit

Permalink
update data
Browse files Browse the repository at this point in the history
  • Loading branch information
RoyalSkye committed May 25, 2023
1 parent ca913ec commit c5f7b2d
Show file tree
Hide file tree
Showing 156 changed files with 597,168 additions and 14 deletions.
10 changes: 3 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,8 @@ __pycache__/

.idea/

# data & pretrain-model
backup/
data/
pretrained/

# private files
utils_plot*
imgs/
1.md
backup/
all_data/
pretrained/
19 changes: 16 additions & 3 deletions EAS/run_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def get_config():
parser.add_argument('-p_runs', default=1, type=int) # If batch_size is 1, set this to > 1 to do multiple runs for the instance in parallel
parser.add_argument('-output_path', default="EAS_results", type=str)
parser.add_argument('-norm', default="batch_no_track", choices=['instance', 'batch', 'batch_no_track', 'none'], type=str)
parser.add_argument('-gpu_id', default=2, type=int)
parser.add_argument('-gpu_id', default=0, type=int)
parser.add_argument('-seed', default=2023, type=int, help="random seed")

# EAS-Emb and EAS-Lay parameters
Expand Down Expand Up @@ -247,7 +247,9 @@ def search(run_id, config):
logging.info(f"Runtime: {runtime}s")
logging.info("MEM: " + str(cutorch.max_memory_reserved(config.gpu_id) / 1024 / 1024) + "MB")
logging.info(f"Num. instances: {len(perf)}")
print(">> Solving {}, with sol {}".format(config.instances_path, perf))
print(">> Solved {}, with sol {}".format(config.instances_path, perf))

return np.mean(perf)


def seed_everything(seed=2022):
Expand All @@ -263,4 +265,15 @@ def seed_everything(seed=2022):
seed_everything(config.seed)
if torch.cuda.is_available():
torch.cuda.set_device(config.gpu_id)
search(run_id, config)

sol_list, path_list = [], []
if os.path.isdir(config.instances_path):
path_list = [os.path.join(config.instances_path, f) for f in sorted(os.listdir(config.instances_path))]
else:
path_list = config.instances_path

for path in path_list:
config.instances_path = path
sol = search(run_id, config)
sol_list.append(sol)
print(len(sol_list), sol_list)
3 changes: 2 additions & 1 deletion POMO/CVRP/CVRPEnv.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ def load_problems(self, batch_size, problems=None, aug_factor=1):
node_demand = self.saved_node_demand[self.saved_index:self.saved_index+batch_size]
self.saved_index += batch_size
else:
depot_xy, node_xy, node_demand = get_random_problems(batch_size, self.problem_size, distribution='uniform', problem="cvrp")
depot_xy, node_xy, node_demand, capacity = get_random_problems(batch_size, self.problem_size, distribution='uniform', problem="cvrp")
node_demand = node_demand / capacity.view(-1, 1)
self.batch_size = depot_xy.size(0)

if aug_factor > 1:
Expand Down
634 changes: 634 additions & 0 deletions POMO/CVRP/CVRPTrainer_meta_grad.py

Large diffs are not rendered by default.

572 changes: 572 additions & 0 deletions POMO/CVRP/CVRPTrainer_meta_grad_reptile.py

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion POMO/CVRP/CVRP_baseline.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from utils.functions import check_extension, load_dataset, save_dataset, run_all_in_pool, move_to


def get_lkh_executable(url="http://www.akira.ruc.dk/~keld/research/LKH-3/LKH-3.0.7.tgz"):
def get_lkh_executable(url="http://www.akira.ruc.dk/~keld/research/LKH-3/LKH-3.0.8.tgz"):

cwd = os.path.abspath("lkh")
os.makedirs(cwd, exist_ok=True)
Expand Down
2 changes: 1 addition & 1 deletion POMO/TSP/TSPTrainer_Meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ def _train_one_epoch(self, epoch):
w[b] = self.task_w[idx][selected].item()
selected_tasks.append(task_params)
w = torch.softmax(torch.Tensor(w), dim=0)

for b in range(self.meta_params['B']):
task_params, task_w = selected_tasks[b], w[b].item()
# preparation
Expand Down
754 changes: 754 additions & 0 deletions POMO/TSP/TSPTrainer_meta_grad.py

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion POMO/TSP/TSP_baseline.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def solve_concorde_log(executable, directory, name, loc, disable_cache=False):
return None


def get_lkh_executable(url="http://www.akira.ruc.dk/~keld/research/LKH-3/LKH-3.0.7.tgz"):
def get_lkh_executable(url="http://www.akira.ruc.dk/~keld/research/LKH-3/LKH-3.0.8.tgz"):

cwd = os.path.abspath("lkh")
os.makedirs(cwd, exist_ok=True)
Expand Down
Loading

0 comments on commit c5f7b2d

Please sign in to comment.