简体   繁体   English

Drools Planner考试示例只有一个主题

[英]Drools Planner examination example has only one Topic

I tested out the examination example of Drools Planner. 我测试了Drools Planner的考试例子。 After a while I wanted to solve a unsolved problem. 过了一会儿,我想解决一个未解决的问题。 I started the app, selected an xml-file and hit the solve button. 我启动了应用程序,选择了一个xml文件并点击了解决按钮。 In my XML file were 5 exams with 5 different topics (t1, t2, t3, t4, t5). 在我的XML文件中有5个不同主题的考试(t1,t2,t3,t4,t5)。

Drools generated a solution. Drools产生了一个解决方案。 In this solution are 5 exams but all of them have the same type of topic (t1). 在这个解决方案中有5个考试但是所有考试都有相同类型的主题(t1)。 I don't find the failure why drools give me 5 exams with the same topic. 我没有找到为什么drools给我5个相同主题的考试的失败。 At the beginning (before solving) the debugger tells me that all exams have different topic. 在开始时(解决之前),调试器告诉我所有考试都有不同的主题。

Normally the topic of an exam shouldn't be changed. 通常,不应更改考试主题。

In my ExaminationSolutionInitializer.java the methhod " changeWorkingSolution " returns a the wrong Solution. 在我的ExaminationSolutionInitializer.java中 ,methhod“ changeWorkingSolution ”返回错误的解决方案。 scoreDirector.getWorkingSolution() generated the exams with only one topic. scoreDirector.getWorkingSolution()仅使用一个主题生成考试。

Could anybody help me? 有人能帮助我吗?

There's probably a bug in your XML input file. 您的XML输入文件中可能存在错误。 Can you copy paste it here or on gist.github.com and link it? 你可以在这里或gist.github.com上复制粘贴并链接吗?

In Drools Planner's examination example, each Exam instance has exactly 1 field Topic and it is never changed by Planner. 在Drools Planner的考试示例中,每个考试实例都有1个字段主题,并且Planner永远不会更改它。 It's the Exam's field Room and Period that are changed by Planner. 这是由Planner更改的考试现场房间和期间。

public class Exam ... {

    private Topic topic;
    ...

    // Planning variables: changes during planning, between score calculations.
    private Period period;
    private Room room;
    ...
}

Also, the Exam to Topic relation is a 1 to 1 relation. 此外,Exam to Topic关系是1对1的关系。 They could have been designed as 1 class, but haven't. 它们可以被设计为1类,但没有。 The Topic class holds all the exam info that don't change during planning, the Exam class links each Topic which it's Room and Period. Topic类包含在计划期间不会更改的所有考试信息,Exam类将每个主题链接到它的Room和Period。

检查域图

As for the ExaminationSolutionInitializer.java: That was written before the construction heuristics were added in Planner. 至于ExaminationSolutionInitializer.java:这是在Planner中添加构造启发式之前编写的。 Now, it's usually better to just use first fit or first fit decreasing instead. 现在,通常最好只使用第一次拟合或第一次拟合减少。 The only reason it's still there in the examination example, is because it has domain specific code to deal with the Exam.isCoincidenceLeader() case when multiple exams need to be scheduled at the same period and therefore need to be moved together. 在测试示例中它仍然存在的唯一原因是因为它具有特定于域的代码来处理Exam.isCoincidenceLeader()情况,因为需要在同一时间段安排多个考试,因此需要将它们一起移动。

问题是我在exam.java中将主题声明为@PlanningVariable

Maybe the problem is my new planningVariable "day". 也许问题是我的新计划变量“日”。 I didn't want to have a day index in the period. 我不想在这个时期有一个日期指数。 So I copied the period classes and made them to day classes. 所以我复制了期间课程并将它们变成了日课程。 In my ExaminationSolutionInitializer I have the inititalizeExamList. 在我的ExaminationSolutionInitializer中,我有inititalizeExamList。 Before looping over every period and every ExamToHandle, I loop over the days. 在循环每个句点和每个ExamToHandle之前,我循环了几天。 But I think the problem could be scheduleLeader(). 但我认为问题可能是scheduleLeader()。 In this method I figure out the bestRoom and the bestPeriod, but no bestDay. 在这个方法中,我找出了bestRoom和bestPeriod,但没有bestDay。 What do you think? 你怎么看?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM