8
votes
Accepted
Genetic algorithm to guess coefficient of a polynomial
This is not the best algorithm
If the goal is to get the best coefficients for a polynomial so it fits the given points, then a polynomial regression algorithm such as ...
6
votes
An Algorithm Which Schedules Your Life
Formatting
Get an IDE or a linter that will give you hints about PEP8, Python's standard for code formatting. Among other things, it will suggest:
Capital letters for your constants, e.g. ...
6
votes
Accepted
Python methods to reduce running times KTNS algorithm
1. Bug
The code in the post does not compute the correct sequence of tool insertions for the Keep Tool Needed Soonest (KTNS) algorithm.
This is easiest to see if we print out the tools in the ...
6
votes
Accepted
Solving The Travelling Salesman Problem Using Genetic Algorithm
Overall, your code works (as said in the comments, it can reach your target if you tweak the parameters) and is pretty nice to look at, so good job!
There are some things that can be improved, as ...
6
votes
Simple version of NEAT
Avoid unnecessary loops/comprehensions
Replace this loop:
# for i in range(len(inputs)):
# self.inputs[i] = inputs[i]
with an O(1) assignment:
...
5
votes
Accepted
Genetic algorithm to guess password
This looks a bit like a code smell:
Chromosome(Chromosome.get_new_random_genes())
You are using the static method of the class to return something from which you ...
5
votes
Genetic Programming - Pathfinding not enougth couples
I don't know anything about Factorio which your question also seems to be about, so I can't say anything about "missing important IdeaTypes", for instance.
Since ...
5
votes
Accepted
Route finding Genetic Algorithm
Answers to your questions
The parameters at the beginning could be written as enums, but I couldn't convince myself what the advantage would be (apart from polluting the global namespace?) I thought ...
4
votes
Genetic Programming - Pathfinding not enougth couples
Interpreting the problem as a path on a graph:
The problem can be interpreted as trying to find a path (from S to T) in a graph.
E.g.
Genetic Algorithm improvements
There are several techniques to ...
4
votes
Accepted
An Algorithm Which Schedules Your Life
numpy
numpy.random has functions to generate random arrays. So, this:
...
4
votes
Accepted
Genetic algorithm for playing Tetris
The thing that strikes me immediately is the amount of repetition in genetic.py. Suppose that you needed to add a new trait. How many places in the code would have to be updated? Well, you'd need to ...
4
votes
Python methods to reduce running times KTNS algorithm
For starter, you should get a consistent coding style. Naming and spacing are usually off and makes the code harder to read. You should get yourself familiar with PEP8 and apply it to make your Python ...
4
votes
Accepted
4
votes
Solving The Travelling Salesman Problem Using Genetic Algorithm
Profiling
Here's a profiler report for the original code, showing the top 10 functions in terms of cumulative time:
...
3
votes
Accepted
Portrait Painting Genetic Algorithm
Optimization
You can achieve a significant perfomance improvement by using a so-called 'dirty rectangles' approach. Instead of calculating the color-distance of every single pixel every single time, ...
3
votes
Accepted
Genetic algorithm for Traveling Salesman
def x(self, v):
return self.vertices[v][0]
def y(self, v):
return self.vertices[v][1]
I think these two methods are dead code and could be ...
3
votes
C++ Genetic algorithm with templates
I haven't really studied your code, or tried to run it, but I'll take a swing at answering your questions. I'm going to answer them in reverse order.
Is it Ok, to have whole template classes in a ...
3
votes
Accepted
Genetic algorithm to find the minimum of a three-variable function
Better organisation
You program in its current state is one huge chunk of snippet with all logic inside it. You should consider splitting it into separate smaller functions. The limits on \$ x, y, z \...
3
votes
Accepted
Slow Bioinformatics algorithm - Clump finding algorithm in Haskell
Simple mistake: a list does not contain its length, so length traverses the list to compute the length. This means that kmerBreak...
3
votes
Accepted
Simple version of NEAT
General thoughts
The code is scattered all around the place, which makes reasoning about a bit tedious. Consider placing several classes into a single module, I would suggest one for base network-...
2
votes
Image similarity measure
To speed this up further, you should use the numpy interface of PIL (if you are not yet using ...
2
votes
Accepted
An open-source library for creating genetic algorithms
I am the wrong reviewer
Coders can be grouped into two types, those that will use libraries for anything and everything, giving automatic trust too 3rd party code, and those that see libraries as ...
2
votes
Portrait Painting Genetic Algorithm
I have two small sugestions...
Without using different math in ColorDistance which is the bottleneck (according to ReShaprer profiler (dotTrace)) as a quick speed ...
2
votes
Route finding Genetic Algorithm
Representation
############
O....#.....#
#.#.#.#.#..#
#........#.O
############
I would find this representation of a level much more readable if the empty space ...
2
votes
Accepted
Simple Genetic Algorithm in Python
From my understanding of the subject your implementation seem correct but there are numerous things you could fix or improve there.
Specific remarks
Use actually predicted values for printing i.e.
<...
2
votes
Simplified Smart Rockets using Genetic Algorithm
UX
When I run the code, I don't always see the value for "Generation" printed in the GUI.
It is sometimes clipped at the right edge of the screen. It would be better
to move it to its own ...
2
votes
Accepted
Binary genetic programming image classifier's fitness function
I'm concerned with this bit of code, the inner 3 loops:
...
2
votes
Genetic Programming - Pathfinding not enougth couples
Your problem is difficult in trying for a genetic algorithm to create a long program for which the only outputs are a single binary ('problem is solved', 'problem is not solved') and that you are ...
2
votes
Python Genetic Algorithm Implementation
On the style of the code:
While I'm not saying the code is or isn't correct, there's some small tweaks you could make it to improve it's legibility:
Spacing
Write code like you would write English (in ...
2
votes
Accepted
Genetic TSP in Java with graph expansion
Naming
You chose some confusing names.
tspGraph is not a graph, but a path/tour through the graph, and the "tsp" prefix is not helpful, as in your ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
genetic-algorithm × 67python × 29
performance × 17
java × 15
python-3.x × 11
algorithm × 11
traveling-salesman × 9
c++ × 8
beginner × 7
numpy × 5
c# × 4
simulation × 4
ai × 4
javascript × 3
game × 3
haskell × 3
image × 3
graph × 3
clojure × 3
python-2.x × 2
combinatorics × 2
machine-learning × 2
neural-network × 2
programming-challenge × 1
strings × 1