Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

ARITIFICAL INTELLIGENCE CODING IS IN JAVA If you use file reader please show example of the .txt file you used. I beleive the only coding

ARITIFICAL INTELLIGENCE

CODING IS IN JAVA

If you use file reader please show example of the .txt file you used.

I beleive the only coding needed is in the GeneticlAlgorithm.java

(which is the code I pasted at the very bottom)

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

//Generic algo

package ga;

public class GeneticAlgorithm {

protected int mPopulationSize;

protected int mTournamentsSize;

protected double mCrossoverProb;

protected double mMutationProb;

public GeneticAlgorithm(int populationSize,

int tournamentsSize, double crossoverProb, double mutationProb) {

mPopulationSize = populationSize;

mTournamentsSize = tournamentsSize;

mCrossoverProb = crossoverProb;

mMutationProb = mutationProb;

// ...

createInitialPopulation();

}

public void createInitialPopulation() {

// to be implemented

}

public void runOneGeneration() {

// to be implemented

}

public double getAverageFitness() {

// to be implemented; remove 0.0

return 0.0;

}

public double getBestFitness() {

// to be implemented; remove 0.0

return 0.0;

}

// other methods to be implemented

}

Description Your task is to implement a Genetic algorithm (GA) to find the maximum of the following function: 3 .3 where x and y are real numbers between -3 and 3. You can represent the problem variables as a chromosome by concatenating x and y as a binary string using 8-bits for each variable: 10 0010100 0l111 0 11 The calculation of x and y of a chromosome is done as follows: 1. A chromosome (string of 16 bits) is partitioned into two 8-bit strings 10 0 0 1 0 10and0 011 101 1 2. These strings are converted from binary (base 2) to decimal (base 10): (10001010)2 -Ix27 +0x26+0x25 +0x24 +1x23 +0x22+1x21 +0x20 138)10 and (0011 101)2-0x27 +0x26+lx25+lx24+1x23+0x22+1x21 +1x20 - (59)10 Description Your task is to implement a Genetic algorithm (GA) to find the maximum of the following function: 3 .3 where x and y are real numbers between -3 and 3. You can represent the problem variables as a chromosome by concatenating x and y as a binary string using 8-bits for each variable: 10 0010100 0l111 0 11 The calculation of x and y of a chromosome is done as follows: 1. A chromosome (string of 16 bits) is partitioned into two 8-bit strings 10 0 0 1 0 10and0 011 101 1 2. These strings are converted from binary (base 2) to decimal (base 10): (10001010)2 -Ix27 +0x26+0x25 +0x24 +1x23 +0x22+1x21 +0x20 138)10 and (0011 101)2-0x27 +0x26+lx25+lx24+1x23+0x22+1x21 +1x20 - (59)10

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions