Hey all,

I’m trying to do Ant Colony Optimization in Julia, and I’ve run into a problem that when using rand I always get the lowest value possible.

Most part of the function isn’t important I just didn’t want it to leave out.

```
Using Random
function selectNextNode(ant, possiblePaths, graph, pheoromoneExponent, desirabilityExponent)
sum = 0
probabilities = Float64[]
for possibleNode in possiblePaths
sum += (((graph.pheromoneMatrix[ant.currentLocation, possibleNode]) ^ pheromoneExponent) * (1/ graph.adjMatrix[ant.currentLocation, possibleNode]) ^ desirabilityExponent)
push!(probabilities, ((graph.pheromoneMatrix[ant.currentLocation, possibleNode]) ^ pheromoneExponent ) * (1/graph.adjMatrix[ant.currentLocation, possibleNode]) ^ desirabilityExponent)
end
rnd = rand(0:sum)
println("Random number between 0 and $sum is $rnd")
for i in 1:length(possiblePaths)
if(rnd < probabilities[i])
return possiblePaths[i]
end
rnd -= probabilities[i]
end
end
```

How it looks when I compile it

Any suggestion what I did wrong?