Comments (4)
Sorry it has taken me so long to get back to you. An answer may not even be relevant for you at this point. Regardless, I'm not sure I understand your concern. The tour found by the ant is a closed loop so the starting coordinate seems irrelevant to me... am I missing something?
from acopy.
I'm closing this ticket for now but please feel free to re-engage on this issue.
from acopy.
Sure it can be closed. Back then, I was trying to solve a problem which had an analogy with TSP. I was given a starting node and had to travel all cities without returning to the starting city (Not a closed a loop like TSP) I was exploring if applying Ant Colony to my problem could be of any help. Thanks!
from acopy.
Actually, the pants library (former) had a nodes list and the route would always start on the node you listed first, if I remember correctly.
Here's the relevant code I used/wrote for 3D TSP:
import pants
import math
from waypoints import waypoints
# waypoints = {"name": (x,y,z),"anothername": (x,y,z)}
nodes = []
for key, value in waypoints.items():
nodes.append(value)
nodecount = len(nodes)
print(str(nodecount), "nodes, finding solutions")
print("...")
def euclidean2d(a, b):
return math.sqrt(pow(a[1] - b[1], 2) + pow(a[0] - b[0], 2))
def euclidean3d(a, b):
return math.sqrt(pow(a[1] - b[1], 2) + pow(a[0] - b[0], 2) + pow(a[2] - b[2], 2))
if len(nodes[1]) > 2:
world = pants.World(nodes, euclidean3d)
else:
world = pants.World(nodes, euclidean2d)
solver = pants.Solver(alpha=0.886,
beta=10,
rho=0.6,
elite=0.286,
limit=100000,
ant_count=nodecount,
Q=math.sqrt(nodecount))
solutions = solver.solutions(world)
for solution in solutions:
j += 1
assert solution.distance < best
best = solution.distance
pilgrimage = []
for i in solution.tour:
pilgrimage.append(list(waypoints.keys())[list(waypoints.values()).index(i)])
# more case-specific code I won't show
for point in pilgrimage:
print(point)
from acopy.
Related Issues (20)
- update_scent should encompass _trace_elite HOT 1
- Don't need to ask each ant if moving is possible HOT 2
- Can't copy Ants or Worlds HOT 1
- Cloned ant has source ant's uid HOT 1
- Strange method names HOT 1
- The main method is a mess! HOT 1
- No way to input coordinates from command line HOT 1
- PyPI import missing utils HOT 7
- Failure on noncomplete graph HOT 2
- Error: not exists edge when using networkx graph generator HOT 4
- [Proposal] ant's move can handles the not complete graph. HOT 1
- ValueError: The truth value of a DataFrame is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all(). HOT 2
- Only works for fully connected graphs HOT 1
- Algorirhm diverge
- bump version of click
- Yielding local best OR global best HOT 1
- Argument/property name mismatch HOT 3
- No property access for initial world pheromone level HOT 1
- No documentation for properties HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from acopy.