Open LeonLi717 opened 2 years ago
hi when i run the BRKGA.ipynb it shows
Traceback (most recent call last): File "d:\三创\算法\3D-Bin-Packing-Problem-with-BRKGA-main\3D-Bin-Packing-Problem-with-BRKGA-main\code\test.py", line 19, in <module> model.fit(patient = 15,verbose = True) File "d:\三创\算法\3D-Bin-Packing-Problem-with-BRKGA-main\3D-Bin-Packing-Problem-with-BRKGA-main\code\model.py", line 384, in fit elites, non_elites, elite_fitness_list = self.partition(population, fitness_list) File "d:\三创\算法\3D-Bin-Packing-Problem-with-BRKGA-main\3D-Bin-Packing-Problem-with-BRKGA-main\code\model.py", line 338, in partition return population[sorted_indexs[:self.num_elites]], population[sorted_indexs[self.num_elites:]], fitness_list[sorted_indexs[:self.num_elites]] TypeError: only integer scalar arrays can be converted to a scalar index
how can i deal with it ?
Hi @Motherlesssss and all who might need it, I create a fork from this repo that fix all errors and could run using the latest python libraries
https://github.com/mich1342/3D-Bin-Packing-Problem-with-BRKGA
@mich1342 Thanks for sorting out most of the problem. There is another problem that you can fix which is the np.product()
issue. You can replace all the method with np.prod()
.
change: population = np.concatenate((elites, offsprings), axis = 0) fitness_list = elite_fitness_list + offspring_fitness_list into: population = np.concatenate((elites,mutants, offsprings), axis = 0) fitness_list = self.cal_fitness(population) and change the return of the partition() : return population[sorted_indexs[:self.num_elites]], population[sorted_indexs[self.num_elites:]]#,np.array(fitness_list)[sorted_indexs[:self.num_elites]]