为了满足Y中取X约束
问题描述:
我正在时间表程序,它确实一对一的匹配从SubjectTeacherPeriod
(规划实体)至Period
。有来的时候,我需要的情况下:“y的时期,SubjectTeacherPeriod
的ATLEAST x必须匹配match_condition
”为了满足Y中取X约束
例如,我想约束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
s分配那些Period
s是否符合比赛条件?
如果我以糟糕的形式定义我的类,请纠正我。
例如起见,这里是进行评估,以确定匹配声明:eval(matches($stp_attrib,$match_condition))
对不起,我使用伪代码,如果它混淆超过澄清。该SomeType
实际上是列表<字符串>,因此匹配条件与Collections.disjoint
答
我会试试看检查,但不知道我完全理解你的问题陈述:
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'是我所需要的。 – aitchnyu 2012-03-28 12:30:59