Skip to main content
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 ...
G. Sliepen's user avatar
  • 69.5k
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. ...
Reinderien's user avatar
  • 71.2k
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 ...
Gareth Rees's user avatar
  • 50.1k
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 ...
gazoh's user avatar
  • 3,399
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: ...
tdy's user avatar
  • 2,266
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 ...
Graipher's user avatar
  • 41.7k
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 ...
Juho's user avatar
  • 3,649
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 ...
G. Sliepen's user avatar
  • 69.5k
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 ...
Tommaso Fontana's user avatar
4 votes
Accepted

An Algorithm Which Schedules Your Life

numpy numpy.random has functions to generate random arrays. So, this: ...
RootTwo's user avatar
  • 10.7k
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 ...
Gareth Rees's user avatar
  • 50.1k
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 ...
301_Moved_Permanently's user avatar
4 votes
Accepted

Much more efficient trisexual genetic algorithm for TSP in Java

...
swpalmer's user avatar
  • 281
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: ...
RootTwo's user avatar
  • 10.7k
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, ...
Pieter Witvoet's user avatar
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 ...
Peter Taylor's user avatar
  • 24.5k
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 ...
indi's user avatar
  • 16.6k
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 \...
hjpotter92's user avatar
  • 8,941
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...
Li-yao Xia's user avatar
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-...
301_Moved_Permanently's user avatar
2 votes

Image similarity measure

To speed this up further, you should use the numpy interface of PIL (if you are not yet using ...
Graipher's user avatar
  • 41.7k
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 ...
Blindman67's user avatar
  • 22.9k
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 ...
t3chb0t's user avatar
  • 44.7k
2 votes

Route finding Genetic Algorithm

Representation ############ O....#.....# #.#.#.#.#..# #........#.O ############ I would find this representation of a level much more readable if the empty space ...
user985366's user avatar
  • 1,775
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. <...
Diane M's user avatar
  • 513
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 ...
toolic's user avatar
  • 16.4k
2 votes
Accepted

Binary genetic programming image classifier's fitness function

I'm concerned with this bit of code, the inner 3 loops: ...
Cris Luengo's user avatar
  • 7,041
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 ...
Charles Merriam's user avatar
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 ...
RGS's user avatar
  • 1,078
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 ...
Ralf Kleberhoff's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible