genetic-algorithm

Genetic Algorithm in Java problems

最后都变了- 提交于 2019-12-06 08:01:32
I am having trouble creating a Genetic Algorithm in java. I am competing in an online GA contest. I am trying to save the best result each time back into index 0, but it just becomes a reference to the original index. Meaning when I evolve the rest of the indexes, if it evolves the best members original index I lose it. I have tried shimming it with a getClone method that converts the objects data to and int array and creates a new object from it. Individual class: class Individual { public int[] angle; public int[] thrust; public double fitness; public Individual(){ angle = new int[2]; thrust

Writing Simulated Annealing algorithm for 0-1 knapsack in C#

天涯浪子 提交于 2019-12-06 06:36:56
问题 I'm in the process of learning about simulated annealing algorithms and have a few questions on how I would modify an example algorithm to solve a 0-1 knapsack problem. I found this great code on CP: http://www.codeproject.com/KB/recipes/simulatedAnnealingTSP.aspx I'm pretty sure I understand how it all works now (except the whole Bolzman condition, as far as I'm concerned is black magic, though I understand about escaping local optimums and apparently this does exactly that). I'd like to re

How to “crossover” two strings (1234 & abcd -> 12cd & ab34)

给你一囗甜甜゛ 提交于 2019-12-06 02:28:27
问题 Am developing a genetic algorithm in Java, that like all of them, requires the crossover of two parent chromosomes. These chromosomes can be quite long, anywhere from 30 to 500 (but whatever length they have, they will all be the same size, so if the length is 80, in that GA run all will be 80). I thought of developing in different ways but they all just seem to me like very inefficient, so I thought I might ask for new, different points of view and suggestions. For example, one of the ways I

Crossover different length genotypes

允我心安 提交于 2019-12-05 17:56:50
E.g. I have two random representatives 1 6 8 9 0 3 4 7 5 and 3 6 5 7 8 5 What are the ways to crossover them? Add some empty numbers (or operations or sth) on the end of every genotype so they will have the same size? 3 6 5 7 8 5 -1 -1 -1 where -1 means nothing? Or copy few number from first genotype and some from second? What is the way you use? If you already have variable length chromosomes, then it shouldnt matter how you do it, you just need to select a crossover point for each of them, and then crossover as normal. For example using your chromosomes, I have selected two points (.) at

Why does adding Crossover to my Genetic Algorithm gives me worse results?

做~自己de王妃 提交于 2019-12-05 17:43:02
问题 I have implemented a Genetic Algorithm to solve the Traveling Salesman Problem (TSP). When I use only mutation, I find better solutions than when I add in crossover. I know that normal crossover methods do not work for TSP, so I implemented both the Ordered Crossover and the PMX Crossover methods, and both suffer from bad results. Here are the other parameters I'm using: Mutation : Single Swap Mutation or Inverted Subsequence Mutation (as described by Tiendil here) with mutation rates tested

Algorithm to optimize # threads used in a calculation

别来无恙 提交于 2019-12-05 16:14:00
I'm performing an operation, lets call it CalculateSomeData. CalculateSomeData operates in successive "generations", numbered 1..x. The number of generations in the entire run is fixed by the input parameters to CalculateSomeData and is known a priori. A single generation takes anywhere from 30 minutes to 2 hours to complete. Some of that variability is due to the input parameters and that cannot be controlled. However, a portion of that variability is due to things like hardware capacities, CPU load from other processes, network bandwidth load, etc. One parameter that can be controlled per

What's the fastest heuristic algorithm to split students into groups?

a 夏天 提交于 2019-12-05 13:47:16
I have X number of students, where X is a multiple of 6. I now want to split up the students into groups of 6. I have a function that measures how "good" a group of 6 is (lets say it's a black box that runs in constant time for now). By splitting up the students, and then calling my function on each group to measure it's goodness, and then summing up the goodness of each group, I'm able to measure how "good" a certain set of groups is. I'm trying to create an algorithm that will group the students in a way so that the total goodness of all the groups is maximized, and no group has an

Efficient Implementation of Fitness-Proportionate “Roulette” Selection

懵懂的女人 提交于 2019-12-05 08:33:50
问题 I am currently writing a keyboard layout optimization algorithm in C (such as the one designed by Peter Klausler) and I want to implement a fitness-proportionate selection as described here (PDF Link): With roulette selection you select members of the population based on a roullete wheel model. Make a pie chart, where the area of a member’s slice to the whole circle is the ratio of the members fitness to the total population. As you can see if a point on the circumfrence of the circle is

Algorithm for computing timetable given restrictions

坚强是说给别人听的谎言 提交于 2019-12-05 06:08:18
I'm considering a hypothetical problem, and looking for guidance on how to approach solving the problem, from an algorithmic point of view. The Problem: Consider a university. You have the following objects: Teaching staff. Each staff member teaches one or more papers. Students. Each student takes one or more papers. Rooms. Rooms hold a certain number of students, and contain certain types of equipment. Papers. Require a certain type of equipment, and a certain amount of time each week. Given information about enrollments (i.e.- how many students are enrolled in each paper, and what staff are

Choosing individuals from a population, by a fitness function

本小妞迷上赌 提交于 2019-12-05 06:03:19
I've been working on an algorithm, where I need to choose n individuals from a population of size k, where k is much bigger than n. All individuals have a fitness value, therefore the selection should favor higher fitness values. However, I don't want to simply choose best n individuals, the worse ones should have a chance also. (Natural selection) So, I decided to find the min and max fitness values within population. So, any individual would have p = (current - min) / (max - min) probability to be chosen, but I can not just iterate over all of them, roll the dice and choose one if the