def opt_ETI(memoBT, memo_ET, memo_ETI, et_global_solution, upper_bound, jobs, last, problem): total_cplex_time = 0 if memo_ETI[last].eti_penalty >= 0: eti_penalty = memo_ETI[last].eti_penalty if memo_ETI[last].end_times[last] >= upper_bound: eti_penalty = utils.BIG_NUMBER return list(memo_ETI[last].block_lasts), list( memo_ETI[last].end_times), eti_penalty, total_cplex_time block_lasts = list() end_times = list() et_slt = et.opt_ET(memo_ET, et_global_solution, jobs, problem, last) if et_slt.head_last == last: # if the optimal schedule of ET problem has only one block block_start = et_slt.tail_start eti_penalty = et_slt.et_penalty block_lasts.append(last) t = block_start for j in range(last + 1): t = t + problem.processing_times[jobs[j]] end_times.append(t) else: block_lasts, end_times, eti_penalty, cplex_time = dp(memoBT, memo_ET, memo_ETI, et_global_solution, et_slt.head_last, et_slt.tail_first, jobs, last, problem) total_cplex_time += cplex_time memo_ETI[last].block_lasts = list(block_lasts) memo_ETI[last].end_times = list(end_times) memo_ETI[last].eti_penalty = eti_penalty if end_times[last] >= upper_bound: eti_penalty = utils.BIG_NUMBER return block_lasts, end_times, eti_penalty, total_cplex_time
def opt_ETI_Bounded(memoBT, memo_ET, memo_ETI_bounded, et_global_solution, upper_bound, idle_bound, jobs, last, problem): if memo_ETI_bounded[last].eti_penalty >= 0: eti_penalty = memo_ETI_bounded[last].eti_penalty if memo_ETI_bounded[last].end_times[last] >= upper_bound: eti_penalty = utils.BIG_NUMBER elif memo_ETI_bounded[last].num_idle > idle_bound: eti_penalty = utils.BIG_NUMBER return list(memo_ETI_bounded[last].block_lasts), list( memo_ETI_bounded[last].end_times), eti_penalty, 0 block_lasts = list() end_times = list() if idle_bound == 0: start_UB, end_UB, et_penalty_UB, cplex_time = bt.time_block( memoBT, jobs, 0, last, problem) block_lasts.append(last) t = start_UB for i in range(last + 1): t += problem.processing_times[jobs[i]] end_times.append(t) return block_lasts, end_times, et_penalty_UB, 0 et_slt = et.opt_ET(memo_ET, et_global_solution, jobs, problem, last) # new lemma 5 if et_slt.tail_end > upper_bound: et_penalty_boundary, _ = et.opt_ET_with_boundary( jobs, 0, last, problem, upper_bound) delta_et = et_penalty_boundary - et_slt.et_penalty if et_slt.num_idle * problem.b < delta_et: return block_lasts, end_times, utils.BIG_NUMBER, 0 if et_slt.tail_first <= et_global_solution.block_lasts[0]: block_start, end_UB, et_penalty_UB, cplex_time = bt.time_block( memoBT, jobs, 0, last, problem) eti_penalty = et_penalty_UB block_lasts.append(last) t = block_start for j in range(last + 1): t = t + problem.processing_times[jobs[j]] end_times.append(t) else: start_UB, end_UB, et_penalty_UB, cplex_time = bt.time_block( memoBT, jobs, 0, last, problem) idle_bound = min( idle_bound, et_slt.num_idle, math.floor( round(et_penalty_UB - et_slt.et_penalty, 4) / problem.b)) block_lasts, end_times, eti_penalty, cplex_time = dp_Bounded( memoBT, memo_ET, memo_ETI_bounded, et_global_solution, et_slt.head_last, et_slt.tail_first, jobs, last, idle_bound, problem) num_idle = len(block_lasts) - 1 memo_ETI_bounded[last].block_lasts = list(block_lasts) memo_ETI_bounded[last].end_times = list(end_times) memo_ETI_bounded[last].eti_penalty = eti_penalty memo_ETI_bounded[last].num_idle = num_idle if num_idle > idle_bound: eti_penalty = utils.BIG_NUMBER if end_times[last] >= upper_bound: eti_penalty = utils.BIG_NUMBER return block_lasts, end_times, eti_penalty, 0