2012-03-26 108 views
1

我正在時間表程序,它確實一對一的匹配SubjectTeacherPeriod(規劃實體)至Period。有來的時候,我需要的情況下:「y的時期,SubjectTeacherPeriod的ATLEAST x必須匹配match_condition爲了滿足Y中取X約束

例如,我想約束3個特定的時期,至少他們兩個老師教誰匹配asst prof

下面是數據結構抱着這樣的約束:當然

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

SubjectTeacherPeriodPeriod

class SubjectTeacherPeriod 
    int id 
    SomeType attrib 
    Period period 

我怎樣寫,從評估個體Period個規則一個列表檢查是否有SubjectTeacherPeriod s分配那些Period s是否符合比賽條件?

如果我以糟糕的形式定義我的類,請糾正我。

例如起見,這裏是進行評估,以確定匹配聲明:eval(matches($stp_attrib,$match_condition))


對不起,我使用僞代碼,如果它混淆超過澄清。該SomeType實際上是列表<字符串>,因此匹配條件與Collections.disjoint

回答

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 

希望它能幫助。

+0

是的,使用'accumulate'和'memberOf'是我所需要的。 – aitchnyu 2012-03-28 12:30:59

相關問題