our goal is to find the global minimimum at (0,0,0,...) where the function value is also zero.
Budget: $10 – $30 USD
def obj_rastrigin(x):
global func_count
func_count += 1
x = np.array(x)
return sum(x**2 + 10 - 10 * np.cos(2 * np.pi * x))
This function can be applied to an x that is any iterable of any length. We'll be working with numpy arrays. For the 10 dimensional problems your numpy array should be a vector with 10 floating point numbers. We'll enforce bounds that −5.12≤xi≤5.12 so all of the entries in x should be between those bounds.
You can try whichever crossover and mutation functions that you think would be appropriate, and adjust any hyperparameters you want to adjust. You may also use elitism if you want.
You must add local search using scipy.optimize.minimize.
To add local search to the genetic algorithm, just inside the beginning of your loop you will:
• sort pop by increasing fitness
• take the first three individuals with them lowest fitness and replace them by the minimizing location resulting from using scipy.optimize.minimize with bounds applied to each individual, also make sure to update the stored fitness values
• replace both the fitness values and the individuals in the population with their optimized values
• after the local searches sort the population again in case the order has changed
Your goal is to find the global minimimum at (0,0,0,...) where the function value is also zero. You might not reach that goal, but you should play with hyperparameters until you get close. (We regularly got 8 or 9 variables at 0 and an f(x)<1.
We do not provide any starter code for this problem.
Your goal is to find the global minimimum at (0,0,0,...) where the function value is also zero. You might not reach that goal, but you should play with hyperparameters until you get close. (We regularly got 8 or 9 variables at 0 and an f(x)<1.
global func_count
func_count += 1
x = np.array(x)
return sum(x**2 + 10 - 10 * np.cos(2 * np.pi * x))
This function can be applied to an x that is any iterable of any length. We'll be working with numpy arrays. For the 10 dimensional problems your numpy array should be a vector with 10 floating point numbers. We'll enforce bounds that −5.12≤xi≤5.12 so all of the entries in x should be between those bounds.
You can try whichever crossover and mutation functions that you think would be appropriate, and adjust any hyperparameters you want to adjust. You may also use elitism if you want.
You must add local search using scipy.optimize.minimize.
To add local search to the genetic algorithm, just inside the beginning of your loop you will:
• sort pop by increasing fitness
• take the first three individuals with them lowest fitness and replace them by the minimizing location resulting from using scipy.optimize.minimize with bounds applied to each individual, also make sure to update the stored fitness values
• replace both the fitness values and the individuals in the population with their optimized values
• after the local searches sort the population again in case the order has changed
Your goal is to find the global minimimum at (0,0,0,...) where the function value is also zero. You might not reach that goal, but you should play with hyperparameters until you get close. (We regularly got 8 or 9 variables at 0 and an f(x)<1.
We do not provide any starter code for this problem.
Your goal is to find the global minimimum at (0,0,0,...) where the function value is also zero. You might not reach that goal, but you should play with hyperparameters until you get close. (We regularly got 8 or 9 variables at 0 and an f(x)<1.