满足y约束中的x

时间:2012-03-26 14:21:30

标签: drools drools-planner

我正在制作一个时间表计划,该计划从SubjectTeacherPeriod(计划实体)到Period执行一对一匹配。有一种情况需要:“y期间,SubjectTeacherPeriod的至少x必须与match_condition匹配

例如,我想约束3个特定时期,其中至少有两个时期由与asst prof匹配的教师讲授。

这是持有这种约束的数据结构:

Class XOfYPeriods
  SomeType match_condition 
  int x
  List<Period> Periods //problem 

SubjectTeacherPeriod当然有Period

class SubjectTeacherPeriod
  int id
  SomeType attrib
  Period period

如何编写评估列表中各个Period的规则,以检查分配了SubjectTeacherPeriod个的Period的x个数量符合比赛条件?

如果我以错误的形式定义我的课程,请纠正我。

为了举例,这里是一个要评估以确定匹配的语句:eval(matches($stp_attrib,$match_condition))


很抱歉使用Pseudocode如果它比澄清更困惑。 SomeType实际上是List&lt;串GT;因此,使用Collections.disjoint

检查匹配条件

1 个答案:

答案 0 :(得分:2)

我会尝试一下,但不确定我是否完全理解你的问题陈述:

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

希望它有所帮助。

相关问题