首先,问题与时间表问题有关。我要求说,在调度步骤之后,无论算法运行多长时间,所有计划的课程都必须满足硬约束。问题是,我怎样才能做到这一点?我的求解器配置如下所示
<?xml version="1.0" encoding="UTF-8"?>
<solver>
<solutionClass>com.krakfin.praca.mgr.cp.algorytm.solver.TimetableSolution</solutionClass>
<entityClass>com.krakfin.praca.mgr.cp.algorytm.domain.Lesson</entityClass>
<scoreDirectorFactory>
<scoreDefinitionType>HARD_MEDIUM_SOFT</scoreDefinitionType>
<scoreDrl>com/krakfin/praca/mgr/cp/algorytm/solver/algorytmScoreRules.drl</scoreDrl>
<initializingScoreTrend>ONLY_DOWN</initializingScoreTrend>
</scoreDirectorFactory>
<environmentMode>FAST_ASSERT</environmentMode>
<constructionHeuristic>
<constructionHeuristicType>FIRST_FIT_DECREASING</constructionHeuristicType>
</constructionHeuristic>
<localSearch>
<unionMoveSelector>
<changeMoveSelector>
<valueSelector>
<variableName>dzienNrLekcji</variableName>
</valueSelector>
</changeMoveSelector>
<changeMoveSelector>
<valueSelector>
<variableName>sala</variableName>
</valueSelector>
</changeMoveSelector>
</unionMoveSelector>
<termination>
<!--Default value if not set-->
<secondsSpentLimit>180</secondsSpentLimit>
<bestScoreLimit>0hard/0medium/0soft</bestScoreLimit>
</termination>
<acceptor>
<moveTabuSize>7</moveTabuSize>
</acceptor>
<forager>
<acceptedCountLimit>100</acceptedCountLimit>
</forager>
</localSearch>
</solver>
但是例如,如果我运行算法1分钟,结果看起来像(-6hard / -24medium / 365soft)。有没有什么方法可以让求解者没有安排尽可能多的课程但是满足所有严格的限制?
答案 0 :(得分:0)
是的,它被称为过度约束的计划。在文档中查找该关键字。医院病床计划示例已启用此功能。
答案 1 :(得分:0)
好的,文档说:
1.Add a additional score level (usually a medium level between the hard and soft level) by switching ScoreDefinition.
2.Make the planning variable nullable.
3.Add a score constraint on the new level (so usually a medium constraint) to penalize the number of unassigned entities (or a weighted sum of them).
所以我让我的计划变量可以为空
@PlanningVariable(valueRangeProviderRefs = {"workingDays"}, strengthWeightFactoryClass = DayLessonNumberStrengthWeightFactory.class, nullable = true)
public DzienNrLekcji getDzienNrLekcji() {
return base.getDzienNrLekcji();
}
@PlanningVariable(valueRangeProviderRefs = {"roomRange"}, strengthWeightFactoryClass = RoomStrengthWeightFactory.class, nullable = true)
public Sala getSala() {
return base.getSala();
}
在下一步,我添加了媒体约束未分配课程
rule "scheduledLesson"
when
$lesson : Lesson( scheduled == false )
then
scoreHolder.addMediumConstraintMatch(kcontext, -$lesson.getBase().getDuration());
end
和解算器配置保持与第一个注释相同。但改变并没有改善情况。我仍然有严格的约束。我该怎么办?顺便说一下,感谢您当前的提示,他们非常乐于助人。