Open lfmvit opened 1 year ago
Hi @lfmvit , I have made two changes in my Halloween challenge:
1. I did add your suggestion to my code to reduce number of fitness calls. 2. I added fitness count as a global variable in the code. Therefore, my new fitness call changed to:
def fitness(state):
global count
cost = len(state)
valid = np.unique(np.any(x[state]).nonzero()[1]).shape[0]
count+=1
return valid, -cost
Thanks for your review and suggestions.
I noticed from the question asked on the "Halloween Thread" that the version of the function tweak_modified() in Halloween.ipynb may be refined a little bit by saving the past state evaluation.
the recurrent if fitness(new_state) >= fitness(current_state) statement in the mentioned method calls the fitness function twice, so saving the new fitness evaluation for the comparison in the next step should cut the total number of evaluations by half by the end of the process, using a negligible amount of memory.