Write a computer program to implement a generational GA for the
One-Max problem:
Use the following parameters:
• Representation: binary strings of length L=25;
• Initialization: random
• Parent selection: fitness proportionate, implemented using
roulette wheel;
• Recombination: one-point crossover with probability pc=
0.7;
• Mutation: bit-flip with probability pm= 1/L;
• Population size = 100;
• Termination condition: 100 generation or optimum found.
After every generation find the best, worst, and mean fitness in
the population and (possibly) plot then on a graph with time
(generation) on the x axis.
Do 10 run and find the mean and standard deviation of the time
(generations) taken to find the optimum.
Solution
Given the specification of the problem, it is rather simple to
write a Java program.
// C++ implementation of the approach
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod (ll)(1e9 + 7)
// Iterative Function to calculate (x^y)%p in O(log y)
ll power(ll x, ll y, ll p)
{
ll res = 1; // Initialize result
x = x % p; // Update x if it is more than or
// equal to p
while (y > 0) {
// If y is odd, multiply x with
result
if (y & 1)
res = (res * x)
% p;
// y must be even now
y = y >> 1; // y = y/2
x = (x * x) % p;
}
return res;
}
// Function to count the number of binary
// strings of length N having only 0's and 1's
ll findCount(ll N)
{
int count = power(2, N, mod);
return count;
}
// Driver code
int main()
{
ll N = 25;
cout << findCount(N);
return 0;
}
Write a computer program to implement a generational GA for the One-Max problem: Use the following...
mathematical statistics use RStudio program to write a code
# Download the datas et Nile rm(list-1s)) 1ibrary(help "datasets") data("Nile" view (Nile) # Find the mean and sd of the data. It has only one variable. # Problem 1 # Design a one-tailed test with a null hypothesis HO: mu>1000 , assuming that the population sd is known and # is same as the sample sd and probability of error (alpha) 10%, can you reject the null? (50 points) # Problem...
C++. Need some help getting started. We will also have the following two functions: 1. A mutate function that randomly modifies a chromosome. 2. A crossover function that takes two chromosomes and splits each one at the same spot, then combines them together. Our genetic algorithm works by iterating over generations of chromosomes via the following process: 1. Generate random population. 2. Until we get an answer that is good enough, do the next steps in a loop: (a) Do...
Use sorting techniques in the language Python 3
Devise an algorithm and implement it in a program to solve the following problem, similar to one often faced by an MP3 player. For our purposes, a song consists of the following data fields: title (a nonempty ASCII string) composer (a (possibly empty) ASCII string), running time (a positive integer). Input consists of n songs and an integer k with 1 Sksn. Your program must find the k songs with longest running...