Skip to content

Commit

Permalink
Fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
heatingma committed Nov 16, 2024
1 parent 9637cae commit 67fadfd
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ tsp_data_lkh = TSPDataGenerator(
num_threads=8,
nodes_num=50,
data_type="uniform",
solver="lkh",
solver="LKH",
train_samples_num=16,
val_samples_num=16,
test_samples_num=16,
Expand Down
4 changes: 2 additions & 2 deletions ml4co_kit/solver/cvrp/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ def _read_data_from_vrp_file(self, vrp_file_path: str, round_func: str):
points_list.append([client.x, client.y])
demands_list.append(client.demand if CP38 else client.delivery)
points = np.array(points_list)
demands = np.array(demands_list)
demands = np.array(demands_list).reshape(-1)

# capacity
capacity = _vehicle_types.capacity
Expand Down Expand Up @@ -650,7 +650,7 @@ def to_vrplib_folder(
# demands and capacities need be int
demands = demands.astype(np.int32)
capacities = capacities.astype(np.int32)

# .vrp files
if vrp_save_dir is not None:
# filename
Expand Down
2 changes: 1 addition & 1 deletion ml4co_kit/solver/tsp/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ def to_tsplib_folder(

# write
with open(save_path, "w") as f:
f.write(f"NAME : {name}")
f.write(f"NAME : {name}\n")
f.write(f"COMMENT : Generated by ML4CO-Kit\n")
f.write("TYPE : TSP\n")
f.write(f"DIMENSION : {self.nodes_num}\n")
Expand Down
1 change: 1 addition & 0 deletions ml4co_kit/solver/tsp/c_ga_eax_large/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def tsp_ga_eax_large_solve(
max_trials: int, sol_name: str, population_num: int,
offspring_num: int, tsp_name: str, show_info: bool = False
):
show_info = 1 if show_info else 0
tsp_path = os.path.join("tmp", tsp_name)
sol_path = os.path.join("tmp", sol_name)
ori_dir = os.getcwd()
Expand Down
10 changes: 5 additions & 5 deletions tests/test_draw.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,9 @@ def test_draw_tsp():
##############################################

if __name__ == "__main__":
# test_draw_cvrp()
# test_draw_mcl()
# test_draw_mcut()
# test_draw_mis()
test_draw_cvrp()
test_draw_mcl()
test_draw_mcut()
test_draw_mis()
test_draw_mvc()
# test_draw_tsp()
test_draw_tsp()
6 changes: 3 additions & 3 deletions tests/test_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -551,10 +551,10 @@ def test_tsp():
##############################################

if __name__ == "__main__":
test_tsp()
test_atsp()
test_cvrp()
test_mcl()
test_mcut()
test_mis()
test_mvc()
test_cvrp()
test_atsp()
test_tsp()

0 comments on commit 67fadfd

Please sign in to comment.