genetic-algorithm

Grid walking algorithm code correction

♀尐吖头ヾ 提交于 2019-12-12 04:34:33
问题 Grid Walking (Score 50 points): You are situated in an N dimensional grid at position (x_1,x2,...,x_N) . The dimensions of the grid are (D_1,D_2,...D_N) . In one step, you can walk one step ahead or behind in any one of the N dimensions. (So there are always 2N possible different moves). In how many ways can you take M steps such that you do not leave the grid at any point? You leave the grid if you for any x_i , either x_i <= 0 or x_i > D_i . Input: The first line contains the number of test

Max Fitness stuck at local maxima in genetic algorithm implementation

限于喜欢 提交于 2019-12-12 03:39:46
问题 Having trouble with this code below. It is implementation of population evolution. In my case the max fitness is struck at a local maxima everytime and is unable to reach max possible value. Kindly suggest necessary edits and reason for the same. Individual.java package genetic.algorithm.project; import java.util.Random; public class Individual { public static int SIZE = 300; private int[] genes = new int[SIZE]; private double fitnessValue = 0.0; // Getters and Setters public void setGene(int

Uniform Crossover in Java

情到浓时终转凉″ 提交于 2019-12-12 03:23:28
问题 I am having trouble implementing a uniform crossover in java. This is the algorithm; // Uniform Crossover public void UniformCrossover(Individual indi) { if (RVGA.rand.nextDouble() < pc) { // Put your implementation of uniform crossover here // For each gene create a random number in [0, 1]. // If the number is less than 0.5, swap the gene values in // the parents for this gene; other wise, no swapping . } I know I can int tmp and store random number, then if tmp < 0.5 continue with loop I

Genetic Algorithm for Flow shop Scheduling

做~自己de王妃 提交于 2019-12-12 02:54:47
问题 I need help in Matlab: I need to find out how to Crossover any two sequences for genetic alghorithm in FlowShop, e.g. 1st sequence = 1 5 4 7 3 2 9 8 10 6 2nd sequence = 7 8 9 10 5 4 2 1 3 6 after crossover, the off-springs should be offspring 1 = 1 5 4 7 3 2 8 9 10 6 offspring 2 = 7 8 9 10 1 5 4 3 2 6 Crossover should be such that each number doesn't repeat itself in the offspring sequence. Can anyone tell me how to do this? 回答1: There are a number of existing crossovers defined for

Jenetics constraint seems to have no effect

孤街醉人 提交于 2019-12-11 15:52:09
问题 I have implemented a variant of the knapsack problem using Jenetics as follows: @Value public class Knapsack { public static void main( final String[] args ) { final var knapsackEngine = Engine.builder( Knapsack::fitness, Knapsack.codec() ) .constraint( Knapsack.constraint() ) .build(); final var bestPhenotype = knapsackEngine.stream() .limit( 1000L ) .collect( EvolutionResult.toBestPhenotype() ); final var knapsack = bestPhenotype.getGenotype().getGene().getAllele(); final var profit =

NEAT: Speciating

狂风中的少年 提交于 2019-12-11 08:42:58
问题 I was trying to implement neat myself, using the original paper but got stuck. Let's say that in the last generation I had the following species: Specie 1: members: 100 avg_score: 100 Specie 2: members: 150 avg_score: 120 Specie 3: members: 300 avg_score: 50 Specie 4: members: 10 avg_score: 110 My attempt right now for the next gen. is the following: from each species, remove each genome except one random genome. place each genome in the species / perhaps create a new one set the score of the

How to write signature of custom GA functions? (Selection, Mutation, Crossover)

不想你离开。 提交于 2019-12-11 08:26:46
问题 It is hard for me to find Documentation on how to write signatures of my custom selection, mutation, crossover functions for Genetic Algorithm. I can't figure out how ga() functions works. (I know this exists: link ), but how these functions communicate, what they are expecting for inputs and for outputs? Q&A, More about my problem: link This are my GA options: options = gaoptimset(... 'PopulationSize', 10, ... 'Generations', 50, ... 'CrossoverFcn', {'crossoverscattered'}, ... 'MutationFcn',

What effect do crossover probabilities have in Genetic Algorithms/Genetic Programming?

本小妞迷上赌 提交于 2019-12-11 08:23:42
问题 Can any one give an example of crossover probability? I would like to know what is the benefits of determining crossover probability, and also what effect it has in genetic algorithms or genetic programming. 回答1: Crossover probability doesn't have a benefit by definition. It is merely a parameter that allows you to adjust the behavior of a genetic algorithm. Lowering the crossover probability will let more individuals continue in the next generation unchanged. This may or may not have a

Inverse Probability Selection (Inverse Fitness Selection of Evolutionary Algorithms)

為{幸葍}努か 提交于 2019-12-11 06:19:14
问题 I need to probabilistically select a sample from a set of data. Say I had a set of values array[12, 15, 29, 17, 12, 29] . The standard approach would be calculate the total (12 + 15 + 29 + 17 + 12 + 29) and then create a spinner that favors the higher value. Kinda like a pie chart where we select at random from the sample set but favor the Individual with the highest value. An example with the numbers above the chance you will randomly select array[0] is 11% while the chance that array[5] is

Weights optimization of a neural network using Genetic Algorithm

强颜欢笑 提交于 2019-12-11 05:32:21
问题 I was told to implement a neural network to do forecasting. So I created a Feed Forward MultiLayer Perceptron with a Backpropagation algorithm and it is working fine. But I need to get results faster and faster. So I thaught about genetic algorithm t ooptimize the weights in the training session. How do you suggest to encode the chromosme ? I already done it as a table of weights generated randomly (-100, 100) but it's not giving extraordinary results. I guess that the problem is that