简体   繁体   中英

Drools Planner examination example has only one Topic

I tested out the examination example of 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. In my XML file were 5 exams with 5 different topics (t1, t2, t3, t4, t5).

Drools generated a solution. In this solution are 5 exams but all of them have the same type of topic (t1). I don't find the failure why drools give me 5 exams with the same topic. 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. scoreDirector.getWorkingSolution() generated the exams with only one topic.

Could anybody help me?

There's probably a bug in your XML input file. Can you copy paste it here or on gist.github.com and link it?

In Drools Planner's examination example, each Exam instance has exactly 1 field Topic and it is never changed by Planner. It's the Exam's field Room and Period that are changed by 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. They could have been designed as 1 class, but haven't. 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.

检查域图

As for the ExaminationSolutionInitializer.java: That was written before the construction heuristics were added in 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.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. Before looping over every period and every ExamToHandle, I loop over the days. But I think the problem could be scheduleLeader(). In this method I figure out the bestRoom and the bestPeriod, but no bestDay. What do you think?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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