Question: To be implemented in Python. This is how Q1 looks in the csv file: 5 -6 0 -6 3 -1 0 -1 1 Consider the

To be implemented in Python.

To be implemented in Python. This is how Q1 looks in the

This is how Q1 looks in the csv file:

5 -6 0
-6 3 -1
0 -1 1

csv file: 5 -6 0 -6 3 -1 0 -1 1 Consider

Consider the following optimization problem over function fo(x). Q-OPT: max, fQ(x) = lij lil; = x'Qx xe" i=1 j=1 with 2; E {0,1} and coefficients qij R for 1 Sisisn. (a) Implement a function that generates N candidate solutions randomly (e.g., as binary vectors such as r= [1,0,0,0,1,..., 1], x2 = [0,1,1,0, 1, ..., 0],...) and enumerates those using fQ(x). Your function should re- turn top 3 solutions and the corresponding values identified through enumeration. Sample function call and the expected outputs are provided below. list_soln_vals, list_soln = runEnumeration ("01.csv", N=100) # list_soln_vals = [(1, 0, 1), (1, 0, 0), (0, 1, 0) # list_soln = [6.0, 5.0, 3.0] 1 2 3 (b) Implement the vanilla Hill Climbing algorithm provided below to find a good solution for Q-OPT. Pick initial states // initialize randomly 2* = 8 // set as best solution while num_iter 3 times. Return the k local optima and corresponding values Some tips on the implementation, sample function call and the expected outputs are provided below. # HINT: you can hash dictionary with a tuple to store solution value pairs # e.g., if x = [1,0,1], then you can use dic[tuple (x)] = 25 1 2 3 4 = dic_solns runhillclimbing_repeated ("Q3.csv", neighbors_K=3, iter_lim=10, num_repeats=2) # dic_solns={(1,0,0,0,1 ,1,1,1): 36.0, (1,0,0,0,0,0,1,1,1): 25.0}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!