新增每门课程的“优先上课日 / 偏好节次范围”,与硬性可排范围分离。

遗传算法在满足冲突、容量、场地等硬约束后,优先满足课程偏好;偏好无法满足时仍会安排可行课次。
管理员可通过“课程偏好权重”控制偏好的影响程度。
修复遗传适应度:教室容量冗余、同一任务分散、日负载和实验场地偏好现在都会实际参与种群评分
This commit is contained in:
biss committed 2026-08-17 11:10:49 +08:00
1 parent 94bc064697
commit c4649f9cdc
10 files changed
+7409 -17

No files matched your search

+31 -1
View File
@@ -43,6 +43,7 @@ const optimizationSettings = reactive({
earlyPeriodPenalty: 30,
latePeriodPenalty: 30,
roomCapacityWasteWeight: 1,
coursePreferenceWeight: 180,
})
const optimizationSaving = ref(false)
const constraintFilters = reactive({
@@ -387,6 +388,9 @@ function openConstraint(item: any) {
: [1, 2, 3, 4, 5],
earliestPeriod: item.earliestPeriod,
latestPeriod: item.latestPeriod,
preferredDayOfWeeks: [...(item.preferredDayOfWeeks ?? [])],
preferredEarliestPeriod: item.preferredEarliestPeriod,
preferredLatestPeriod: item.preferredLatestPeriod,
})
constraintDialog.value = true
}
@@ -407,6 +411,9 @@ async function saveConstraint() {
allowedDayOfWeeks: constraintForm.allowedDayOfWeeks ?? [],
earliestPeriod: constraintForm.earliestPeriod || null,
latestPeriod: constraintForm.latestPeriod || null,
preferredDayOfWeeks: constraintForm.preferredDayOfWeeks ?? [],
preferredEarliestPeriod: constraintForm.preferredEarliestPeriod || null,
preferredLatestPeriod: constraintForm.preferredLatestPeriod || null,
}
await http.put(`/schedules/constraints/${constraintForm.teachingTaskId}`, payload)
constraintDialog.value = false
@@ -1266,7 +1273,7 @@ onBeforeUnmount(() => {
show-icon
/>
<el-form label-position="top" class="optimization-form">
<div class="form-grid">
<div class="form-grid">
<el-form-item label="教师同日课次惩罚">
<el-input-number v-model="optimizationSettings.teacherSameDayWeight" :min="0" :max="10000" />
<small class="field-hint">优先将同一教师的课程分散到不同日期。</small>
@@ -1295,6 +1302,10 @@ onBeforeUnmount(() => {
<el-input-number v-model="optimizationSettings.roomCapacityWasteWeight" :min="0" :max="10000" />
<small class="field-hint">优先使用容量更贴合教学班人数的可用教室。</small>
</el-form-item>
<el-form-item label="课程偏好权重">
<el-input-number v-model="optimizationSettings.coursePreferenceWeight" :min="0" :max="10000" />
<small class="field-hint">课程设置了偏好日期或节次时,优先满足该偏好。</small>
</el-form-item>
</div>
</el-form>
</el-tab-pane>
@@ -1456,6 +1467,25 @@ onBeforeUnmount(() => {
</el-select>
</el-form-item>
</div>
<el-divider content-position="left">排课偏好(可不填)</el-divider>
<el-form-item label="优先上课日">
<el-checkbox-group v-model="constraintForm.preferredDayOfWeeks">
<el-checkbox v-for="day in weekdays" :key="day.value" :value="day.value">{{ day.label }}</el-checkbox>
</el-checkbox-group>
<small class="field-hint">不是硬限制;无冲突的前提下,遗传算法会优先选择这些日期。</small>
</el-form-item>
<div class="form-grid">
<el-form-item label="偏好最早开始节次">
<el-select v-model="constraintForm.preferredEarliestPeriod" clearable>
<el-option v-for="period in periods" :key="period" :label="`第 ${period} 节 · ${timeLabel(period)}`" :value="period" />
</el-select>
</el-form-item>
<el-form-item label="偏好最晚结束节次">
<el-select v-model="constraintForm.preferredLatestPeriod" clearable>
<el-option v-for="period in periods" :key="period" :label="`第 ${period} 节 · ${timeLabel(period)}`" :value="period" />
</el-select>
</el-form-item>
</div>
</template>
</el-form>
<template #footer>