我想在StatefulKnowledgeSession中插入大量事实。
但它没有到达fireAllRules()部分
我的事实有10k事实。进入MySQL。
http://i.stack.imgur.com/Xbnoh.png
http://i.stack.imgur.com/7tJEU.png
和陈旧
我的代码:
public void runDrools() {
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
starttime = new Date();
if (PersonalCondition1.isSelected() && ConvenienceDay_jCheckBox.isSelected()) {
kbuilder.add(ResourceFactory.newClassPathResource("Rules1_Conv_Schedule.drl", getClass()), ResourceType.DRL);
} else if (PersonalCondition1.isSelected() && !ConvenienceDay_jCheckBox.isSelected()) {
kbuilder.add(ResourceFactory.newClassPathResource("Rules1_Non-Conv_Schedule.drl", getClass()), ResourceType.DRL);
} else if (PersonalCondition2.isSelected() && ConvenienceDay_jCheckBox.isSelected()) {
kbuilder.add(ResourceFactory.newClassPathResource("Rules2_Conv_Schedule.drl", getClass()), ResourceType.DRL);
} else if (PersonalCondition2.isSelected() && !ConvenienceDay_jCheckBox.isSelected()) {
kbuilder.add(ResourceFactory.newClassPathResource("Rules2_Non-Conv_Schedule.drl", getClass()), ResourceType.DRL);
}
if (kbuilder.hasErrors()) {
System.err.println(kbuilder.getErrors().toString());
}
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
boolean InBuild, NearbyBuild, OutBuild;
if (NearbyBuild1.isSelected()) {
InBuild = false;
NearbyBuild = true;
OutBuild = true;
} else if (NearbyBuild2.isSelected()) {
InBuild = true;
NearbyBuild = true;
OutBuild = true;
} else {
InBuild = false;
NearbyBuild = false;
OutBuild = true;
}
if (Control3_jCheckBox.isSelected()) {
Amount_Test = (Integer) Amount_jSpinner.getValue();
} else {
Amount_Test = 0;
}
Check check = new Check(Amount_Test, InBuild, NearbyBuild, OutBuild, Status_JLabel);
ksession.insert(check);
Data_List list = new Data_List();
ksession.insert(list);
if (Control3_jCheckBox.isSelected()) {
Amount_Test = (Integer) Amount_jSpinner.getValue();
} else {
Amount_Test = 2;
}
try {
rs_ro = stm_ro.executeQuery("SELECT * FROM room");
while (rs_ro.next()) {
String code = rs_ro.getString("ro_code"),
capa = rs_ro.getString("ro_capacity");
Room room = new Room(code, Integer.parseInt(capa));
ksession.insert(room);
}
rs_sch_exam = stm_sch_exam.executeQuery("SELECT *,DATE_FORMAT(sch_date,'%a') AS day FROM schedule_exam ORDER BY sch_date ASC");
while (rs_sch_exam.next()) {
String date = rs_sch_exam.getString("sch_date"),
day = rs_sch_exam.getString("day"),
start = rs_sch_exam.getString("sch_start"),
end = rs_sch_exam.getString("sch_end"),
subj = rs_sch_exam.getString("sch_subject"),
depa = rs_sch_exam.getString("sch_depart"),
sec = rs_sch_exam.getString("sch_sec"),
room = rs_sch_exam.getString("sch_room");
Schedule schedule = new Schedule(date, day, subj, sec, depa, room, start, end);
schedule.setConnect(getHost(), getUser(), getPass());
ksession.insert(schedule);
}
Random rand = new Random();
rs_peo = stm_peo.executeQuery("SELECT * FROM control_exam");
while (rs_peo.next()) {
String code = rs_peo.getString("ce_code"),
depart = rs_peo.getString("ce_department"),
room = rs_peo.getString("ce_room"),
sun = rs_peo.getString("ce_sunday"),
mon = rs_peo.getString("ce_monday"),
tue = rs_peo.getString("ce_tuesday"),
wed = rs_peo.getString("ce_wednesday"),
thu = rs_peo.getString("ce_thursday"),
fri = rs_peo.getString("ce_friday"),
sat = rs_peo.getString("ce_saturday"),
max = rs_peo.getString("ce_maxcontrol");
if (max.equals("")) {
max = MaxDays_jSpinner.getValue() + "";
}
Control_Exam controlExam = new Control_Exam(code, depart, room,
Integer.parseInt(sun), Integer.parseInt(mon), Integer.parseInt(tue),
Integer.parseInt(wed), Integer.parseInt(thu), Integer.parseInt(fri),
Integer.parseInt(sat), Integer.parseInt(max));
controlExam.setConnect(getHost(), getUser(), getPass());
ksession.insert(controlExam);
}
rs_sub = stm_sub.executeQuery("SELECT * FROM subject");
while (rs_sub.next()) {
String code = rs_sub.getString("su_code"),
name = rs_sub.getString("su_name"),
educator = rs_sub.getString("su_educator");
Subject subject = new Subject(code, name, educator);
System.out.println(" subject:" + subject.getCode());
ksession.insert(subject);
}
rs_nea = stm_nea.executeQuery("SELECT * FROM nearby");
while (rs_nea.next()) {
String build = rs_nea.getString("nb_build"),
near;
if (NearbyBuild1.isSelected()) {
near = rs_nea.getString("nb_nearby") + "," + build;
} else {
near = rs_nea.getString("nb_nearby");
}
Nearby nearby = new Nearby(build, near);
System.out.println(" nearby:" + nearby.getBuild());
ksession.insert(nearby);
}
databasetime = new Date();
if ((((databasetime.getTime() - starttime.getTime()) / 1000) / 60) >= 1) {
DatabaseTime = MTime.format(databasetime.getTime() - starttime.getTime()) + " นาที";
} else {
DatabaseTime = MSTime.format(databasetime.getTime() - starttime.getTime()) + " วินาที";
}
ksession.fireAllRules();
ksession.dispose();
} catch (Exception e) {
Amount_Test = -1;
Manage_Schedule.this.dispose();
}
}
简单规则(Rules1_Non-Conv_Schedule.drl):
import schedule.Schedule
import schedule.Nearby
import schedule.Room
import schedule.Subject
import schedule.Control_Exam
import schedule.Check
import schedule.Data_List
rule "Add control exam first in Build"
salience 14
when
$check : Check( )
eval( $check.getInBuildState() )
$scheduleCheck : Schedule( )
$controlExamCondition : Control_Exam( max > 0 )
$room : Room( build == $controlExamCondition.getBuild() )
$subject : Subject( educator1 not in( $controlExamCondition.getCode() ),
educator2 not in( $controlExamCondition.getCode() ),
educator3 not in( $controlExamCondition.getCode() ),
educator4 not in( $controlExamCondition.getCode() ),
educator5 not in( $controlExamCondition.getCode() ) )
$schedule : Schedule( room == $room.getCode() ,
subject == $subject.getCode() ,
date == $scheduleCheck.getDate() &&
starttime <= $scheduleCheck.getStarttime() && endtime > $scheduleCheck.getStarttime() )
$controlExamList : Data_List( ) from accumulate( $scheduleCECheck : Schedule( date == $scheduleCheck.getDate() ,
starttime == $scheduleCheck.getStarttime() || endtime == $scheduleCheck.getStarttime() ) ,
init( Data_List DataList = new Data_List(); ),
action( DataList.addData($scheduleCECheck.getControl1()); DataList.addData($scheduleCECheck.getControl2()); DataList.addData($scheduleCECheck.getControl3()); ),
result( DataList ) )
$controlExam : Control_Exam( code not memberOf ( $controlExamList.getArrayCode() ) ) from $controlExamCondition
eval($schedule.getStateEmptyCE1())
then
modify( $schedule ) { setControlExam1( $controlExam.getCode() ) };
modify( $controlExam ) { checkMax( $schedule.getDate() ) };
$check.setTextState("เพิ่มผู้คุมสอบที่ 1: "+$controlExam.getCode() + " ในห้องสอบ: " + $schedule.getRoom() + " วันที่: " + $schedule.getDate() + " เวลา: " + $schedule.getRealStartTime() + " - " + $schedule.getRealEndTime());
end
rule "Add control exam first nearby Build"
salience 11
when
$check : Check( )
eval( $check.getNearbyBuildState() )
$scheduleCheck : Schedule( )
$near : Nearby( )
$room : Room( build == $near.getBuild() )
$controlExamCondition : Control_Exam( build memberOf ( $near.getArrayNearBy() ) , max > 0 )
$subject : Subject( educator1 not in( $controlExamCondition.getCode() ),
educator2 not in( $controlExamCondition.getCode() ),
educator3 not in( $controlExamCondition.getCode() ),
educator4 not in( $controlExamCondition.getCode() ),
educator5 not in( $controlExamCondition.getCode() ) )
$schedule : Schedule( room == $room.getCode() ,
subject == $subject.getCode() ,
date == $scheduleCheck.getDate() &&
starttime <= $scheduleCheck.getStarttime() && endtime > $scheduleCheck.getStarttime() )
$controlExamList : Data_List( ) from accumulate( $scheduleCECheck : Schedule( date == $scheduleCheck.getDate() ,
starttime == $scheduleCheck.getStarttime() || endtime == $scheduleCheck.getStarttime() ) ,
init( Data_List DataList = new Data_List(); ),
action( DataList.addData($scheduleCECheck.getControl1()); DataList.addData($scheduleCECheck.getControl2()); DataList.addData($scheduleCECheck.getControl3()); ),
result( DataList ) )
$controlExam : Control_Exam( code not memberOf ( $controlExamList.getArrayCode() ) ) from $controlExamCondition
eval($schedule.getStateEmptyCE1())
then
modify( $schedule ) { setControlExam1( $controlExam.getCode() ) };
modify( $controlExam ) { checkMax( $schedule.getDate() ) };
$check.setTextState("เพิ่มผู้คุมสอบที่ 1: "+$controlExam.getCode() + " ในห้องสอบ: " + $schedule.getRoom() + " วันที่: " + $schedule.getDate() + " เวลา: " + $schedule.getRealStartTime() + " - " + $schedule.getRealEndTime());
end
rule "Add control exam first out Build"
salience 0
when
$check : Check( )
eval( $check.getOutBuildState() )
$scheduleCheck : Schedule( )
$controlExamCondition : Control_Exam( max > 0 )
$subject : Subject( educator1 not in( $controlExamCondition.getCode() ),
educator2 not in( $controlExamCondition.getCode() ),
educator3 not in( $controlExamCondition.getCode() ),
educator4 not in( $controlExamCondition.getCode() ),
educator5 not in( $controlExamCondition.getCode() ) )
$schedule : Schedule( subject == $subject.getCode() ,
date == $scheduleCheck.getDate() &&
starttime <= $scheduleCheck.getStarttime() && endtime > $scheduleCheck.getStarttime() )
$controlExamList : Data_List( ) from accumulate( $scheduleCECheck : Schedule( date == $scheduleCheck.getDate() ,
starttime == $scheduleCheck.getStarttime() || endtime == $scheduleCheck.getStarttime() ) ,
init( Data_List DataList = new Data_List(); ),
action( DataList.addData($scheduleCECheck.getControl1()); DataList.addData($scheduleCECheck.getControl2()); DataList.addData($scheduleCECheck.getControl3()); ),
result( DataList ) )
$controlExam : Control_Exam( code not memberOf ( $controlExamList.getArrayCode() ) ) from $controlExamCondition
eval($schedule.getStateEmptyCE1())
then
modify( $schedule ) { setControlExam1( $controlExam.getCode() ) };
modify( $controlExam ) { checkMax( $schedule.getDate() ) };
$check.setTextState("เพิ่มผู้คุมสอบที่ 1: "+$controlExam.getCode() + " ในห้องสอบ: " + $schedule.getRoom() + " วันที่: " + $schedule.getDate() + " เวลา: " + $schedule.getRealStartTime() + " - " + $schedule.getRealEndTime());
end
rule "Add control exam second in Build"
salience 14
when
$check : Check( )
eval( $check.getInBuildState() )
$scheduleCheck : Schedule( )
$controlExamCondition : Control_Exam( max > 0 )
$room : Room( build == $controlExamCondition.getBuild() )
$subject : Subject( educator1 not in( $controlExamCondition.getCode() ),
educator2 not in( $controlExamCondition.getCode() ),
educator3 not in( $controlExamCondition.getCode() ),
educator4 not in( $controlExamCondition.getCode() ),
educator5 not in( $controlExamCondition.getCode() ) )
$schedule : Schedule( room == $room.getCode() ,
subject == $subject.getCode() ,
date == $scheduleCheck.getDate() &&
starttime <= $scheduleCheck.getStarttime() && endtime > $scheduleCheck.getStarttime() )
$controlExamList : Data_List( ) from accumulate( $scheduleCECheck : Schedule( date == $scheduleCheck.getDate() ,
starttime == $scheduleCheck.getStarttime() || endtime == $scheduleCheck.getStarttime() ) ,
init( Data_List DataList = new Data_List(); ),
action( DataList.addData($scheduleCECheck.getControl1()); DataList.addData($scheduleCECheck.getControl2()); DataList.addData($scheduleCECheck.getControl3()); ),
result( DataList ) )
$controlExam : Control_Exam( code not memberOf ( $controlExamList.getArrayCode() ) ) from $controlExamCondition
eval( !$schedule.getStateEmptyCE1() && $schedule.getStateEmptyCE2() )
then
modify( $schedule ) { setControlExam2( $controlExam.getCode() ) };
modify( $controlExam ) { checkMax( $schedule.getDate() ) };
$check.setTextState("เพิ่มผู้คุมสอบที่ 2: "+$controlExam.getCode() + " ในห้องสอบ: " + $schedule.getRoom() + " วันที่: " + $schedule.getDate() + " เวลา: " + $schedule.getRealStartTime() + " - " + $schedule.getRealEndTime());
end
rule "Add control exam second nearby Build"
salience 11
when
$check : Check( )
eval( $check.getNearbyBuildState() )
$scheduleCheck : Schedule( )
$near : Nearby( )
$room : Room( build == $near.getBuild() )
$controlExamCondition : Control_Exam( build memberOf ( $near.getArrayNearBy() ) , max > 0 )
$subject : Subject( educator1 not in( $controlExamCondition.getCode() ),
educator2 not in( $controlExamCondition.getCode() ),
educator3 not in( $controlExamCondition.getCode() ),
educator4 not in( $controlExamCondition.getCode() ),
educator5 not in( $controlExamCondition.getCode() ) )
$schedule : Schedule( room == $room.getCode() ,
subject == $subject.getCode() ,
date == $scheduleCheck.getDate() &&
starttime <= $scheduleCheck.getStarttime() && endtime > $scheduleCheck.getStarttime() )
$controlExamList : Data_List( ) from accumulate( $scheduleCECheck : Schedule( date == $scheduleCheck.getDate() ,
starttime == $scheduleCheck.getStarttime() || endtime == $scheduleCheck.getStarttime() ) ,
init( Data_List DataList = new Data_List(); ),
action( DataList.addData($scheduleCECheck.getControl1()); DataList.addData($scheduleCECheck.getControl2()); DataList.addData($scheduleCECheck.getControl3()); ),
result( DataList ) )
$controlExam : Control_Exam( code not memberOf ( $controlExamList.getArrayCode() ) ) from $controlExamCondition
eval( !$schedule.getStateEmptyCE1() && $schedule.getStateEmptyCE2() )
then
modify( $schedule ) { setControlExam2( $controlExam.getCode() ) };
modify( $controlExam ) { checkMax( $schedule.getDate() ) };
$check.setTextState("เพิ่มผู้คุมสอบที่ 2: "+$controlExam.getCode() + " ในห้องสอบ: " + $schedule.getRoom() + " วันที่: " + $schedule.getDate() + " เวลา: " + $schedule.getRealStartTime() + " - " + $schedule.getRealEndTime());
end
rule "Add control exam second out Build"
salience 0
when
$check : Check( )
eval( $check.getOutBuildState() )
$scheduleCheck : Schedule( )
$controlExamCondition : Control_Exam( max > 0 )
$subject : Subject( educator1 not in( $controlExamCondition.getCode() ),
educator2 not in( $controlExamCondition.getCode() ),
educator3 not in( $controlExamCondition.getCode() ),
educator4 not in( $controlExamCondition.getCode() ),
educator5 not in( $controlExamCondition.getCode() ) )
$schedule : Schedule( subject == $subject.getCode() ,
date == $scheduleCheck.getDate() &&
starttime <= $scheduleCheck.getStarttime() && endtime > $scheduleCheck.getStarttime() )
$controlExamList : Data_List( ) from accumulate( $scheduleCECheck : Schedule( ) from $scheduleCheck ,
init( Data_List DataList = new Data_List(); ),
action( DataList.addData($scheduleCECheck.getControl1()); DataList.addData($scheduleCECheck.getControl2()); DataList.addData($scheduleCECheck.getControl3()); ),
result( DataList ) )
$controlExam : Control_Exam( code not memberOf ( $controlExamList.getArrayCode() ) ) from $controlExamCondition
eval( !$schedule.getStateEmptyCE1() && $schedule.getStateEmptyCE2() )
then
modify( $schedule ) { setControlExam2( $controlExam.getCode() ) };
modify( $controlExam ) { checkMax( $schedule.getDate() ) };
$check.setTextState("เพิ่มผู้คุมสอบที่ 2: "+$controlExam.getCode() + " ในห้องสอบ: " + $schedule.getRoom() + " วันที่: " + $schedule.getDate() + " เวลา: " + $schedule.getRealStartTime() + " - " + $schedule.getRealEndTime());
end
rule "Add control exam third in Build"
salience 14
when
$check : Check( )
eval( $check.getInBuildState() && $check.getThirdControlState() )
$scheduleCheck : Schedule( )
$controlExamCondition : Control_Exam( max > 0 )
$room : Room( build == $controlExamCondition.getBuild() )
eval($room.getCapacity() > $check.getAmountThirdControl())
$subject : Subject( educator1 not in( $controlExamCondition.getCode() ),
educator2 not in( $controlExamCondition.getCode() ),
educator3 not in( $controlExamCondition.getCode() ),
educator4 not in( $controlExamCondition.getCode() ),
educator5 not in( $controlExamCondition.getCode() ) )
$schedule : Schedule( room == $room.getCode() ,
subject == $subject.getCode() ,
date == $scheduleCheck.getDate() &&
starttime <= $scheduleCheck.getStarttime() && endtime > $scheduleCheck.getStarttime() )
$controlExamList : Data_List( ) from accumulate( $scheduleCECheck : Schedule( date == $scheduleCheck.getDate() ,
starttime == $scheduleCheck.getStarttime() || endtime == $scheduleCheck.getStarttime() ) ,
init( Data_List DataList = new Data_List(); ),
action( DataList.addData($scheduleCECheck.getControl1()); DataList.addData($scheduleCECheck.getControl2()); DataList.addData($scheduleCECheck.getControl3()); ),
result( DataList ) )
$controlExam : Control_Exam( code not memberOf ( $controlExamList.getArrayCode() ) ) from $controlExamCondition
eval( !$schedule.getStateEmptyCE1() && !$schedule.getStateEmptyCE2() && $schedule.getStateEmptyCE3() )
then
modify( $schedule ) { setControlExam3( $controlExam.getCode() ) };
modify( $controlExam ) { checkMax( $schedule.getDate() ) };
$check.setTextState("เพิ่มผู้คุมสอบที่ 3: "+$controlExam.getCode() + " ในห้องสอบ: " + $schedule.getRoom() + " วันที่: " + $schedule.getDate() + " เวลา: " + $schedule.getRealStartTime() + " - " + $schedule.getRealEndTime());
end
rule "Add control exam third nearby Build"
salience 11
when
$check : Check( )
eval( $check.getNearbyBuildState() && $check.getThirdControlState() )
$scheduleCheck : Schedule( )
$near : Nearby( )
$room : Room( build == $near.getBuild() )
eval($room.getCapacity() > $check.getAmountThirdControl())
$controlExamCondition : Control_Exam( build memberOf ( $near.getArrayNearBy() ) , max > 0 )
$subject : Subject( educator1 not in( $controlExamCondition.getCode() ),
educator2 not in( $controlExamCondition.getCode() ),
educator3 not in( $controlExamCondition.getCode() ),
educator4 not in( $controlExamCondition.getCode() ),
educator5 not in( $controlExamCondition.getCode() ) )
$schedule : Schedule( room == $room.getCode() ,
subject == $subject.getCode() ,
date == $scheduleCheck.getDate() &&
starttime <= $scheduleCheck.getStarttime() && endtime > $scheduleCheck.getStarttime() )
$controlExamList : Data_List( ) from accumulate( $scheduleCECheck : Schedule( date == $scheduleCheck.getDate() ,
starttime == $scheduleCheck.getStarttime() || endtime == $scheduleCheck.getStarttime() ) ,
init( Data_List DataList = new Data_List(); ),
action( DataList.addData($scheduleCECheck.getControl1()); DataList.addData($scheduleCECheck.getControl2()); DataList.addData($scheduleCECheck.getControl3()); ),
result( DataList ) )
$controlExam : Control_Exam( code not memberOf ( $controlExamList.getArrayCode() ) ) from $controlExamCondition
eval( !$schedule.getStateEmptyCE1() && !$schedule.getStateEmptyCE2() && $schedule.getStateEmptyCE3() )
then
modify( $schedule ) { setControlExam3( $controlExam.getCode() ) };
modify( $controlExam ) { checkMax( $schedule.getDate() ) };
$check.setTextState("เพิ่มผู้คุมสอบที่ 3: "+$controlExam.getCode() + " ในห้องสอบ: " + $schedule.getRoom() + " วันที่: " + $schedule.getDate() + " เวลา: " + $schedule.getRealStartTime() + " - " + $schedule.getRealEndTime());
end
rule "Add control exam third out Build"
salience 0
when
$check : Check( )
eval( $check.getOutBuildState() && $check.getThirdControlState() )
$scheduleCheck : Schedule( )
$controlExamCondition : Control_Exam( max > 0 )
$room : Room( )
eval($room.getCapacity() > $check.getAmountThirdControl())
$subject : Subject( educator1 not in( $controlExamCondition.getCode() ),
educator2 not in( $controlExamCondition.getCode() ),
educator3 not in( $controlExamCondition.getCode() ),
educator4 not in( $controlExamCondition.getCode() ),
educator5 not in( $controlExamCondition.getCode() ) )
$schedule : Schedule( room == $room.getCode() ,
subject == $subject.getCode() ,
date == $scheduleCheck.getDate() &&
starttime <= $scheduleCheck.getStarttime() && endtime > $scheduleCheck.getStarttime() )
$controlExamList : Data_List( ) from accumulate( $scheduleCECheck : Schedule( date == $scheduleCheck.getDate() ,
starttime == $scheduleCheck.getStarttime() || endtime == $scheduleCheck.getStarttime() ) ,
init( Data_List DataList = new Data_List(); ),
action( DataList.addData($scheduleCECheck.getControl1()); DataList.addData($scheduleCECheck.getControl2()); DataList.addData($scheduleCECheck.getControl3()); ),
result( DataList ) )
$controlExam : Control_Exam( code not memberOf ( $controlExamList.getArrayCode() ) ) from $controlExamCondition
eval( !$schedule.getStateEmptyCE1() && !$schedule.getStateEmptyCE2() && $schedule.getStateEmptyCE3() )
then
modify( $schedule ) { setControlExam3( $controlExam.getCode() ) };
modify( $controlExam ) { checkMax( $schedule.getDate() ) };
$check.setTextState("เพิ่มผู้คุมสอบที่ 3: "+$controlExam.getCode() + " ในห้องสอบ: " + $schedule.getRoom() + " วันที่: " + $schedule.getDate() + " เวลา: " + $schedule.getRealStartTime() + " - " + $schedule.getRealEndTime());
end
抱歉我的英语不好。
答案 0 :(得分:1)
对我而言,它看起来不像是流口水问题。
由于项目中有大量对象,因此内存不足。如果您有超过10k的事实,那么仅仅因为System.out.println(new Date().toLocaleString().....
日志而创建了超过10k的对象。记住String不是原始数据类型。
您必须调整代码并增加JVM的最大堆大小(默认值大约为64mb)。
答案 1 :(得分:1)
您将无法使用Control_Exam
的可能数量的事实来运行这些规则,
Room
(即使仅限于建筑物),Subject
和Schedule
。在左侧考虑这些模式:
$scheduleCheck : Schedule( )
$controlExamCondition : Control_Exam()
$room : Room( build == $controlExamCondition.getBuild() )
$subject : Subject( educator1 not in( $controlExamCondition.getCode() ),
educator2 not in( $controlExamCondition.getCode() ),
educator3 not in( $controlExamCondition.getCode() ),
educator4 not in( $controlExamCondition.getCode() ),
educator5 not in( $controlExamCondition.getCode() ) )
您正在创建一系列激活,这些激活源自所有Schedule
,Control_Exam
,Room
(仅限于建筑物)和Subject
的某个子集的笛卡尔积事实。
你有大约50条这样的规则,并且写得不好,例如规则“在构建中首先在日期/便利状态1-5中添加控制检查”:
Schedule()
出现两次Control_Exam
出现两次Data_List()
作为集合(数组或列表)的包装器会增加不必要的开销我必须尝试全面了解数据模型以提出改进建议。
我认为这是为了解决规划问题。通常情况下,这些问题有一个很大的,甚至是巨大的搜索空间,如果你不能很快地减少这个问题,那么资源需求(时间和空间)就会爆炸。
Drools Planner是为解决此类问题而开发的,但这种方法(虽然仍在使用规则)却截然不同。
答案 2 :(得分:0)
查看OptaPlanner(= Drools Planner的新名称)考试时间表问题。
Here's a video on exam timetabling with OptaPlanner and Drools.
Here is a list of the exam score rules.请注意,它们不仅包含评分要求,也不包含搜索要求。
要理解为什么创建/评估所有可能的解决方案组合是疯狂的(它们以指数方式扩展),read this blog article about search space size。