Question: this code for sphere function for one vectors please update this code for two vectors with plots with simple explanations please *************************************************************** import numpy as
this code for sphere function for one vectors
please update this code for two vectors with plots
with simple explanations please ***************************************************************
import numpy as np class problem: def __init__(self,dim,bounds,problemNo): self.dim = dim self.bounds= bounds self.problemNo = problemNo def objectiveFunction(self , solution): if self.problemNo== 0: # sphere function fx = 0 for x in solution : fx+= x**2 return fx sphere = problem(2, [5.12,-5.12], 0) solution1 = np.random.uniform(low=-5.12, high=5.12, size=2) objVal = sphere.objectiveFunction(solution1)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
