genetic-algorithm

Genetic algorithm for optimization in game playing agent heuristic evaluation function

余生颓废 提交于 2019-12-01 14:04:44
This is in response to an answer given in this question: How to create a good evaluation function for a game? , particularly by @David (it is the first answer). Background : I am using a genetic algorithm to optimize the hyper parameters in a game playing agent that is using minimax / alpha beta pruning (with iterative deepening). In particular, I would like to optimize the heuristic (evaluation) function parameters using a genetic algorithm. The evaluation function I use is: f(w) = w * num_my_moves - (1-w) * num_opponent_moves The only parameter to optimize is w in [0,1]. Here's how I

Single point ordered crossover in matlab

泪湿孤枕 提交于 2019-12-01 09:20:34
I need to create ordered crossover in matlab. I have parents P1 and P2 as follow: P1=[1 2 3 4 ; 0 1 1 0], P2=[3 2 1 4 ; 0 1 0 0]. First 1 [at place P1(2,2) and P2(2,2)] is my crossover point. now I need to offsprings as follow: O1=[1 2 3 4 ; 0 1 0 0], O2=[3 2 1 4 ; 0 1 0 0]. Can you please help me? Best, Elnaz To find the crossover point, use a logical AND operator on the second line of the parents: idx = find(P1(2, :) & P2(2, :)); Then we create the offsprings by switching values between parents after the crossover point: O1 = [P1(:, 1:idx), P2(:, idx + 1:end)]; O2 = [P2(:, 1:idx), P1(:, idx

Single point ordered crossover in matlab

青春壹個敷衍的年華 提交于 2019-12-01 06:32:27
问题 I need to create ordered crossover in matlab. I have parents P1 and P2 as follow: P1=[1 2 3 4 ; 0 1 1 0], P2=[3 2 1 4 ; 0 1 0 0]. First 1 [at place P1(2,2) and P2(2,2)] is my crossover point. now I need to offsprings as follow: O1=[1 2 3 4 ; 0 1 0 0], O2=[3 2 1 4 ; 0 1 0 0]. Can you please help me? Best, Elnaz 回答1: To find the crossover point, use a logical AND operator on the second line of the parents: idx = find(P1(2, :) & P2(2, :)); Then we create the offsprings by switching values

Using DEAP (genetic algorithm library) with spark

倖福魔咒の 提交于 2019-12-01 00:18:39
Is IT possible to use DEAP ( http://deap.readthedocs.io/en/master/ ) with a spark cluster to map the fitness evaluation function. I would like to run a GA but the fitness function is rather long and I was planning on distributing it on a spark cluster. You should look at the Using Multiple Processors section in the DEAP documentation and at this example . They explain how to replace the map function in the DEAP toolbox by a map function of your choice. To use pyspark to map the fitness evaluation function, you could do something like that: from pyspark import SparkContext sc = SparkContext

Prevent inbreeding and monoculture in genetic algorithm (newbie question)

谁说我不能喝 提交于 2019-11-30 20:22:55
I am writing a genetic algorithm. My population quickly develops a monoculture. I am using a small population (32 individuals) with a small number of discrete genes (24 genes per individual) and a single point cross-over mating approach. Combine that with a roulette wheel selection strategy and it is easy to see how all the genetic diversity is lost in just a few dozen generations. What I would like to know is, what is the appropriate response? I do not have academic-level knowledge on GAs and only a few solutions come to mind: Use a larger population. (slow) Use runtime checks to prevent in

Using DEAP (genetic algorithm library) with spark

蓝咒 提交于 2019-11-30 18:31:06
问题 Is IT possible to use DEAP ( http://deap.readthedocs.io/en/master/) with a spark cluster to map the fitness evaluation function. I would like to run a GA but the fitness function is rather long and I was planning on distributing it on a spark cluster. 回答1: You should look at the Using Multiple Processors section in the DEAP documentation and at this example. They explain how to replace the map function in the DEAP toolbox by a map function of your choice. To use pyspark to map the fitness

Simulated Binary Crossover (SBX) crossover operator in Scala genetic algorithm (GA) library

佐手、 提交于 2019-11-30 17:46:09
问题 I work on a very little research team to create/adapt a Genetic Algorithm library in Scala for distributed computation with Scientific Worklow System, in our case we use the open source OpenMole software (http://www.openmole.org/). Recently, i try to understand and re-implement the SBX crossover operator written in JMetal Metaheuristics library (http://jmetal.sourceforge.net/) to adapt it in functionnal version in our Scala library. I write some code, but i need our advice or your validation

AI How to model genetic programming for Battleships

吃可爱长大的小学妹 提交于 2019-11-30 10:21:28
I have a question regarding Genetic Programming. I am going to work on a genetic algorithm for a game called Battleships . My question is: How would I decide upon a "decision" model for the AI to evolve? And how does that work? I have read multiple papers and multiple answers that just speak about using different models, but could not find something specific, which, unfortunately, I apparently need to wrap my head around the problem. I want it to evolve over multiple iterations and "learn" what works best, but not sure how to save these "decisions" (I know to a file, but "encoded" how?) in a

Code generation by genetic algorithms

拜拜、爱过 提交于 2019-11-30 10:20:15
问题 Evolutionary programming seems to be a great way to solve many optimization problems. The idea is very easy and the implementation does not make problems. I was wondering if there is any way to evolutionarily create a program in ruby/python script (or any other language)? The idea is simple: Create a population of programs Perform genetic operations (roulette-wheel selection or any other selection), create new programs with inheritance from best programs, etc. Loop point 2 until program that

How should roulette wheel selection be organized for non-sorted population in genetic algorithm?

删除回忆录丶 提交于 2019-11-30 07:35:58
My question is linked with this one: Roulette-wheel selection in Genetic algorithm. Population needs to be sorted first? If we don't sort the population what is the way of organizing roulette wheel selection for it? Surely, we have to search in linear way now. Have you got any code snippets in C++ or Java for this case? The population does not need to be sorted at all - the key to roulette selection is that the probability of a given individual being selected for reproduction is proportional to its fitness. Say you have an unsorted population, with fitnesses as follows: [12, 45, 76, 32, 54, 21