Professional Documents
Culture Documents
18B-044-SE
ASSIGNMENT 03:
CODE:
#!/usr/bin/env python
# coding: utf-8
# In[ ]:
import random as rn
import numpy as np
class AntColony(object):
self.length = length
self.all_inds = range(len(length))
self.auntt1 = auntt1
self.antb = antb
self.moving = moving
self.find = find
self.alpha = alpha
self.beta = beta
def start(self):
shortest_path = None
for i in range(self.moving):
all_paths = self.all_pathscovered()
print (shortest_path)
followedpaths = shortest_path
return followedpaths
total_dist = 0
total_dist += self.length[ele]
return total_dist
def all_pathscovered(self):
all_paths = []
for i in range(self.auntt1):
path = self.pathgenerete(0)
all_paths.append((path, self.distance(path)))
return all_paths
path = []
visited = set()
ZEESHAN ASLAM
18B-044-SE
visited.add(start)
prev = start
path.append((prev, move))
prev = move
visited.add(move)
return path
pheromone = np.copy(pheromone)
pheromone[list(visited)] = 0
return move
print("Ff")
# In[ ]:
C:\Users\PC\Downloads
ZEESHAN ASLAM
18B-044-SE
# In[2]:
# In[ ]: