Drools 满足y中x约束的步骤
我正在制作一个时间表程序,它将Drools 满足y中x约束的步骤,drools,drools-planner,Drools,Drools Planner,我正在制作一个时间表程序,它将主题教师时段(计划实体)与时段进行一对一的匹配。有一种情况是我需要这样做:“对于y周期,至少x个SubjectTeacherPeriod必须匹配一个match\u条件” 例如,我想限制3个特定时段,其中至少两个时段由符合助理教授的教师教授 以下是包含此类约束的数据结构: Class XOfYPeriods SomeType match_condition int x List<Period> Periods //problem 我如何
主题教师时段
(计划实体)与时段
进行一对一的匹配。有一种情况是我需要这样做:“对于y周期,至少x个SubjectTeacherPeriod
必须匹配一个match\u条件
”
例如,我想限制3个特定时段,其中至少两个时段由符合助理教授
的教师教授
以下是包含此类约束的数据结构:
Class XOfYPeriods
SomeType match_condition
int x
List<Period> Periods //problem
我如何编写一个规则,从列表中计算每个
时段
s,以检查分配给这些时段
s的主题教师时段
s的x个数是否符合匹配条件
如果我以错误的形式定义我的类,请纠正我
为了举例说明,这里有一条语句需要评估以确定匹配:eval(matches($stp\u attrib,$match\u condition))
很抱歉使用了伪代码,如果它让人感到困惑而不是澄清。
SomeType
实际上是List集合进行检查。不相交的我将尝试一下,但不确定我是否完全理解您的问题陈述:
rule "X of Y Periods"
when
$c : XOfYPeriods( )
$list : List( size > $c.x ) from
accumulate( $stp : SubjectTeacherPeriod( matches(attrib, $c.match_condition),
period memberOf $c.periods ),
collectList( $stp ) )
then
// $list of STP that match the condition and
// whose period matches one of the periods in the list
end
希望有帮助。是的,我需要使用accumulate
和memberOf
。
rule "X of Y Periods"
when
$c : XOfYPeriods( )
$list : List( size > $c.x ) from
accumulate( $stp : SubjectTeacherPeriod( matches(attrib, $c.match_condition),
period memberOf $c.periods ),
collectList( $stp ) )
then
// $list of STP that match the condition and
// whose period matches one of the periods in the list
end