1

我正在制作一个时间表程序,该程序SubjectTeacherPeriod计划实体)到Period. 有一种情况,我需要:“对于 y 个周期,至少 x 个SubjectTeacherPeriod必须匹配一个match_condition

例如,我想限制 3 个特定时期,其中至少两个由与 匹配的教师教授asst prof

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

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

SubjectTeacherPeriodPeriod当然有

class SubjectTeacherPeriod
  int id
  SomeType attrib
  Period period

如何编写一个规则来评估列表Period中的单个s以检查分配给这些s 的x 个s 是否满足匹配条件?SubjectTeacherPeriodPeriod

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

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


如果混淆多于澄清,请抱歉使用伪代码。实际上是 List< String> ,因此SomeType匹配条件是用Collections.disjoint

4

1 回答 1

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

希望能帮助到你。

于 2012-03-27T18:19:49.523 回答