你说的“具体来说,如果 temp_job_in_time 不是无穷大(即 float('inf')),并且 span_time 为零(表示不需要进一步调整时间间隔),那么这次 trial 就成功找到了一个合适的调度时间。”是在代码的哪几行体现出来的
时间: 2024-11-12 12:38:00 浏览: 4
这段描述对应的是代码中的 `trial` 函数部分,特别是以下几行:
```python
last_task_temp, temp_job_in_time, span_time = trial(last_task_temp, job_out_list_temp, temp_job_in_time, new_job.job_in_span)
print("trial后:", temp_job_in_time)
if temp_job_in_time == float('inf'):
break
new_job.job_in_time = temp_job_in_time
create_job_in(env=self, job=new_job, opener=job_opener, start_time=temp_job_in_time, low_bound_t=last_task_temp['low_bound_t'], remove_t=first_remove_time)
if not self.job_flag:
break
new_job.index = max_index + 1
inner_model.low_bound_time = last_task_temp['low_bound_t']
inner_model.error_list.clear()
inner_model.wash_error_tank_set.clear()
inner_model.change_chemical_tank_set.clear()
over_soak_t = calculate_inner_jobs(
env=inner_model,
move_list=move_list,
proc_list=proc_list,
job_info=[
new_job.get_info(
mat_id=[w.mat_id[0] for w in new_job.wafer],
job_in_time=new_job.job_occupy_pusher.last_value,
job_in_span=new_job.job_in_span - (new_job.job_occupy_pusher.last_value - new_job.job_in_time),
new_job=True,
current_new_job=True
)
],
remove_list=[],
rollback_time=max(last_task_temp['low_bound_t'], roll_back_time),
safe_time=self.now_safe,
ptr_station=self.ptr.last_station,
last_post_move_list={},
inner_pusher_occupy=inner_model.inner_pusher_occupy
)
cal_count += 1
# 计算过泡
for batch_job in inner_model.batch_jobs:
if batch_job.job_id in self.jobs_dict and self.jobs_dict[batch_job.job_id].last_job not in [
Constant.JobOut, Constant.JobOutOK, Constant.JobCompleted
]:
inner_job = inner_model.jobs_dict[batch_job.job_id]
for _wafer in self.jobs_dict[batch_job.job_id].wafer:
_wafer.step_id_history.merge(inner_job.step_id_history)
_wafer.station_history.merge(inner_job.station_history, _wafer, True)
_wafer.step_transfer_move_list.update(inner_job.outer_step_transfer_move_list)
_wafer.move_list.merge(inner_job.move_list)
ChangeChemical_flag = inner_model.error_list.copy()
if Constant.ChangeChemical in inner_model.error_list:
inner_model.error_list.remove(Constant.ChangeChemical)
if not job_out_list_temp and Constant.ChangeChemical in ChangeChemical_flag:
inner_model.error_list.add(Constant.ChangeChemical)
# 如果出错就结束循环
if (
Constant.WashError in inner_model.error_list or
Constant.ChangeChemical in inner_model.error_list or
Constant.DeadLock in inner_model.error_list or
(temp_job_in_time == float('inf') and new_job.job_id in inner_model.jobs_dict)
):
trial(last_task, job_out_list, -1, -1)
inner_model.error_list.clear()
inner_model.wash_error_tank_set.clear()
calculate_inner_jobs(
env=inner_model,
move_list={},
proc_list={},
job_info=[],
remove_list=[new_job.job_id],
rollback_time=roll_back_time,
ptr_station=self.ptr.last_station,
last_post_move_list={},
safe_time=self.now_safe,
inner_pusher_occupy=inner_model.inner_pusher_occupy
)
for batch_job in inner_model.batch_jobs:
inner_job = inner_model.jobs_dict[batch_job.job_id]
for _wafer in self.jobs_dict[batch_job.job_id].wafer:
_wafer.step_id_history.merge(inner_job.step_id_history)
_wafer.station_history.merge(inner_job.station_history, _wafer, True)
_wafer.step_transfer_move_list.update(inner_job.outer_step_transfer_move_list)
_wafer.move_list.merge(inner_job.move_list)
assert not inner_model.error_list
if Constant.ChangeChemical in ChangeChemical_flag:
self.change_chemical(inner_model.change_chemical_tank_set.copy())
if Constant.WashError in inner_model.error_list:
print("WashError")
self.wash_error(inner_model.wash_error_tank_set.copy())
break
elif Constant.OverSoak in inner_model.error_list:
# 如果过泡则继续循环continue
if min_good_time != float('inf'):
last_step = round((min_good_time - temp_job_in_time) / 2, 2)
last_step = last_step if last_step > 1 else 0
over_span = ((temp_job_in_time if last_step else min_good_time) - first_job_in_time) + last_step
else:
last_step = max(over_soak_t + span_time, inner_model.jobs_dict[new_job.job_id].residence_time, 40)
over_span += last_step
last_task_temp = last_task.copy()
job_out_list_temp = job_out_list.copy()
print("过泡", last_step, over_span)
# 打印变化步长,yly
continue
else:
if last_step > 2 and new_job.job_in_time not in new_job.last_good_in_time:
min_good_time = min(min_good_time, temp_job_in_time)
new_job.last_good_in_time.add(new_job.job_in_time)
last_step = round(last_step / 2, 2)
over_span -= last_step
last_task_temp = last_task.copy()
job_out_list_temp = job_out_list.copy()
print("回缩", last_step, over_span)
# 打印变化步长,yly
continue
max_index += 1
self.current_job_num += 1
job_mid.append(new_job)
first_over = True
last_remove_time.append(new_job.remove_from_pusher)
job_out_list_temp.append(new_job)
new_job.last_final_in_time = new_job.job_in_time
if last_task_temp['job']:
last_task_temp['job'].last_task_t = last_task_temp['job'].last_task_t_in if last_task_temp['task_id'] == Constant.JobIn else last_task_temp['job'].last_task_t_out
last_task = {
'job': new_job,
'task_id': Constant.JobIn,
'low_bound_t': max(new_job.last_task_t, last_task_temp['job'].last_task_t if last_task_temp['job'] else self.now_safe)
}
job_out_list = job_out_list_temp
inner_model.jobs_dict[new_job.job_id].currrent_new_job = False
inner_model.jobs_dict[new_job.job_id].residence_time = 0
single_job_run_flag = True
break
print("计算次数:", cal_count, " ;计算结果", new_job.job_in_time)
```
在这段代码中,`trial` 函数调用后的 `temp_job_in_time` 和 `span_time` 被检查以确定是否找到合适的调度时间:
- **`temp_job_in_time == float('inf')`**: 如果 `temp_job_in_time` 是无穷大,说明没有找到合适的调度时间,因此退出循环。
- **`span_time == 0`**: 如果 `span_time` 为零,说明不需要进一步调整时间间隔,这次 `trial` 成功找到了一个合适的调度时间。
具体的逻辑体现在以下几个步骤:
1. **调用 `trial` 函数**:
```python
last_task_temp, temp_job_in_time, span_time = trial(last_task_temp, job_out_list_temp, temp_job_in_time, new_job.job_in_span)
```
2. **检查 `temp_job_in_time` 是否为无穷大**:
```python
if temp_job_in_time == float('inf'):
break
```
3. **设置新的 `job_in_time` 并创建任务**:
```python
new_job.job_in_time = temp_job_in_time
create_job_in(env=self, job=new_job, opener=job_opener, start_time=temp_job_in_time, low_bound_t=last_task_temp['low_bound_t'], remove_t=first_remove_time)
```
4. **处理错误和过泡情况**:
```python
if (
Constant.WashError in inner_model.error_list or
Constant.ChangeChemical in inner_model.error_list or
Constant.DeadLock in inner_model.error_list or
(temp_job_in_time == float('inf') and new_job.job_id in inner_model.jobs_dict)
):
# 处理错误情况
break
```
5. **如果没有错误且 `span_time` 为零**:
```python
else:
if last_step > 2 and new_job.job_in_time not in new_job.last_good_in_time:
min_good_time = min(min_good_time, temp_job_in_time)
new_job.last_good_in_time.add(new_job.job_in_time)
last_step = round(last_step / 2, 2)
over_span -= last_step
last_task_temp = last_task.copy()
job_out_list_temp = job_out_list.copy()
print("回缩", last_step, over_span)
continue
```
这些步骤共同确保了在 `trial` 函数调用后,只有当 `temp_job_in_time` 不是无穷大且 `span_time` 为零时,才会认为找到了合适的调度时间。
阅读全文