def cal_Fitness_Value(self, chromo, et_global_solution): if self.memo_FV.get(tuple(chromo)): return self.memo_FV[(tuple(chromo))].eti_penalty p = copy.deepcopy(self.problem) p.earliness_penalties[ chromo[0]] = p.earliness_penalties[chromo[0]] + p.a p.tardiness_penalties[ chromo[0]] = p.tardiness_penalties[chromo[0]] - p.a p.earliness_penalties[chromo[ self.n - 1]] = p.earliness_penalties[chromo[self.n - 1]] - p.a p.tardiness_penalties[chromo[ self.n - 1]] = p.tardiness_penalties[chromo[self.n - 1]] + p.a # memos memo_BT = bt.init_BT_memo(chromo, p.due_dates, p.processing_times) memo_ET = et.init_ET_memo(chromo, p.due_dates, p.processing_times) memo_ETI = dp.init_ETI_memo(chromo) block_lasts, end_times, eti_penalty, _ = dp.opt_ETI( memo_BT, memo_ET, memo_ETI, et_global_solution, utils.BIG_NUMBER, chromo, self.n - 1, p) # if self.iter == 0: # print(eti_penalty) real_obj, b_ratio = self.cal_Real_Objective(chromo, block_lasts, end_times, self.problem) self.memo_FV[tuple(chromo)] = utils.Solution(block_lasts, end_times, real_obj, b_ratio) return real_obj
def cal_Fitness_Value(self, chromo): if self.memo_FV.get(tuple(chromo)): return self.memo_FV[(tuple(chromo))].eti_penalty p = copy.deepcopy(self.problem) p.earliness_penalties[ chromo[0]] = p.earliness_penalties[chromo[0]] + p.a p.tardiness_penalties[ chromo[0]] = p.tardiness_penalties[chromo[0]] - p.a p.earliness_penalties[chromo[ self.n - 1]] = p.earliness_penalties[chromo[self.n - 1]] - p.a p.tardiness_penalties[chromo[ self.n - 1]] = p.tardiness_penalties[chromo[self.n - 1]] + p.a # memos sourd = Sourd(chromo, p) obj = sourd.run_bounded() # if self.iter == 0: # print(eti_penalty) self.memo_FV[tuple(chromo)] = utils.Solution([0], [0], obj, 0) return obj