Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.pt
*.pyc
2 changes: 1 addition & 1 deletion MDCVRP/VRP_Actor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)))

Expand Down
3 changes: 2 additions & 1 deletion MDCVRP/VRP_Rollout_train.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions MDCVRP/creat_vrp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down