diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ab0f6c8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.pt +*.pyc \ No newline at end of file diff --git a/MDCVRP/VRP_Actor.py b/MDCVRP/VRP_Actor.py index eab75a8..1645ff9 100644 --- a/MDCVRP/VRP_Actor.py +++ b/MDCVRP/VRP_Actor.py @@ -209,7 +209,7 @@ def __init__(self, input_dim, hidden_dim): def forward(self, encoder_inputs, pool,capcity,demand, n_steps,num_depots,T, greedy=False): num_depot = num_depots - print(num_depot) + #print(num_depot) mask1 = encoder_inputs.new_zeros((encoder_inputs.size(0), encoder_inputs.size(1))) mask = encoder_inputs.new_zeros((encoder_inputs.size(0), encoder_inputs.size(1))) diff --git a/MDCVRP/VRP_Rollout_train.py b/MDCVRP/VRP_Rollout_train.py index d7735a1..07e550d 100644 --- a/MDCVRP/VRP_Rollout_train.py +++ b/MDCVRP/VRP_Rollout_train.py @@ -16,6 +16,7 @@ device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') #device = torch.device('cpu') +num_depots=2 n_nodes = 22#nodes = nodes + depots steps = n_nodes def rollout(model, dataset,batch_size, n_nodes): @@ -91,7 +92,7 @@ def get_runs(params): scheduler = LambdaLR(actor_optim, lr_lambda=lambda f: 0.96 ** epoch) for batch_idx, batch in enumerate(data_loder): batch = batch.to(device) - tour_indices, tour_logp = actor(batch,steps*2) + tour_indices, tour_logp = actor(batch,steps*2,num_depots) rewar = reward1(batch.x, tour_indices.detach(),n_nodes) base_reward = rol_baseline.eval(batch,steps) diff --git a/MDCVRP/creat_vrp.py b/MDCVRP/creat_vrp.py index e5b4122..fed2480 100644 --- a/MDCVRP/creat_vrp.py +++ b/MDCVRP/creat_vrp.py @@ -148,8 +148,8 @@ def c_dist(x1,x2): def reward1(static, tour_indices,n_nodes): static = static.reshape(-1,n_nodes,2) - print(static.shape) - static = torch.from_numpy(static).to('cuda') + #print(static.shape) + static = static.to('cuda') static = static.transpose(2,1) tour_indices_1 = deepcopy(tour_indices)