Simulated annealing is just a (meta)heuristic strategy to help local search to better escape local optima. Plt.xlabel("value.", fontsize=18,fontweight='bold') How to use this code for a knapsack problem where v is a list of value of items, w being list of weights and k value be the capacity of knapsack, i have tried the following code import numpy as np Plt.xticks(np.arange(min(Temp),max(Temp),100),fontweight='bold') Plt.ylabel("Cost", fontsize=18,fontweight='bold') Plt.xlabel("Temp.", fontsize=18,fontweight='bold') Objfun_new = pd.DataFrame(new_dis_new_arr*Flow) Objfun_init = pd.DataFrame(new_dis_init_arr*Flow) # Make a adatframe of the current solution New_dis_new_arr = np.array(new_dis_df_new) New_dis_df_new = Dist.reindex(columns=xt, index=xt) New_dis_init_arr = np.array(new_dis_df_init) New_dis_df_init = Dist.reindex(columns=X0, index=X0) # Make a new list of the new set of departments Objfun1_start_Arr = np.array(Objfun1_start) Objfun1_start = pd.DataFrame(New_Dist_Arr*Flow) ![]() ![]() # Make a dataframe of the cost of the initial solution New_Dist_DF = Dist.reindex(columns=X0, index=X0) # Make a dataframe of the initial solution I was going through the course contents of Optimization with Metaheuristics in Python in udemy, where they have solved a quadratic assignment problem using Simulated annealing in python, i was trying to implement the same concept for a knapsack problem I couldnot do it.
0 Comments
Leave a Reply. |