genetic-algorithm

c++ Genetic Algorithm Mutation error

人盡茶涼 提交于 2019-12-07 15:23:25
I Have a problem with the mutation function within my genetic Algorithm. I can't quite see what I am doing wrong either. I've looked at this code for a while and I think the logic is correct, it's just not producing the results i want. The problem When i output the Binary array located in the Child Struct, If mutation has occured on any of the bits, then a random number will be changed, and not the one that should be. for example 0000000 is the binary string mutation has occured on the second bit 0001000 would be the result This section is located within the main. for (int Child = 0; Child <

How to implement ordered crossover

ⅰ亾dé卋堺 提交于 2019-12-07 09:12:01
问题 So I have two parents ABCDE EDCBA can I just select a subset from both: From parent one: ACD From parent two: EDC Then I copy parent one into offspring one but copy the selected subset with parent twos order so: Offspring one: DBCAE Offspring two: CDEBA 回答1: To answer the title question: http://www.eecs.tufts.edu/~jfinke02/jmona/xref/jmona/example/tsp/crossover/OrderedCrossoverFunction.html: 1 /** 2 * OrderedCrossoverFunction.java 3 * 4 * Copyright 2009, 2010 Jeffrey Finkelstein 5 * 6 * This

Crossover different length genotypes

雨燕双飞 提交于 2019-12-07 08:38:53
问题 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? 回答1: 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

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

…衆ロ難τιáo~ 提交于 2019-12-07 07:16:31
问题 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

Algorithm for computing timetable given restrictions

帅比萌擦擦* 提交于 2019-12-07 03:59:41
问题 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

Choosing individuals from a population, by a fitness function

徘徊边缘 提交于 2019-12-07 02:26:52
问题 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)

How to perform rank based selection in a genetic algorithm?

泪湿孤枕 提交于 2019-12-06 23:08:56
问题 I am implementing a small genetic algorithm framework - primarily for private use, unless I manage to make something reasonable at which time I will post it as open source. Right now I am focusing on selection techniques. So far I have implemented roulette wheel selection, stochastic universal sampling and tournament selection. Next on my list is rank based selection. I had a little more difficulty finding information about that than the other techniques that I've already implemented, but

Linear fitness scaling in Genetic Algorithm produces negative fitness values

落花浮王杯 提交于 2019-12-06 13:36:06
问题 I have a GA with a fitness function that can evaluate to negative or positive values. For the sake of this question let's assume the function u = 5 - (x^2 + y^2) where x in [-5.12 .. 5.12] y in [-5.12 .. 5.12] Now in the selection phase of GA I am using simple roulette wheel. Since to be able to use simple roulette wheel my fitness function must be positive for concrete cases in a population, I started looking for scaling solutions. The most natural seems to be linear fitness scaling . It

Accessing ArrayList<ArrayList<SomeObject>> elements

两盒软妹~` 提交于 2019-12-06 13:32:29
I have an ArrayList of ArrayList s where i need to find a simple way of accessing the elements, to make it easier to understand i have drawn my goal of what i want to achieve: As seen on the image above the main ArrayList consists of m ArrayList , where i wish to get an element by using a get method which goes from 0 to N elements, where N is the total elements of ArrayList1 and ArrayList2 . More ArrayList's may occur. I can of course iterate through the elements by using two for-loops, which is not what im searching for in this case. You would need to basically have the the ArrayList members

Pattern prediction using Genetic Algorithm

爱⌒轻易说出口 提交于 2019-12-06 08:53:13
问题 I am a newbie to Genetic Algorithm. I am trying to predict the pattern of occurrences of rules. For example, I have a set of rules defined as below. Rule 1, Rule 2, Rule 3, Rule 4, Rule 5, Rule 6, For a given date, I could have only Rule 2, Rule 3 and Rule 6 are used. So I would represent this data as a string as stated below 0 1 1 0 0 1 where 1 denotes that the rule is used and 0 denotes that the rule never get used on that day. So I would have set of data for 5 days as below 011001, 100010,