Opta Planner How could I arrange courses lecture in 2 periods sequential

351 Views Asked by At

I' developing a auto time table software at the Ataturk University in Turkey using Optaplanner. Optalanner has met all the requirements. But in addition there are a few requirements. One of them: ->When i want to put a course on time table, how could i arrange it in 2 periods sequential. And should not be a lecture in three sequential periods. For Example three hours consider the math lesson:

                      IN MONDAY
      -----------------------------------------------

      0.P     Math              Math           Math

      1.P     Math              Math           Another

      2.P     Another           Math           Another

      3.P     Another           Another        Math

      4.P     Math              Another        Another
         (or another day)
      5.P     Another           Another        Another

      6.P     Another           Another        Math
              -----             -----          ----- 
             CORRECT            WRONG          WRONG

I want to be my time table look like first column and I need to prevent other cases.

1

There are 1 best solutions below

0
On BEST ANSWER

something like this should work:

rule "twoInARowIsgood"
when
    CourseSequentialRequirement($c : course)
    Lecture (course == $c, $firstP : period)
    Lecture (course == $c, period.isImmediatlyAfter($firstP))
then
    scoreHolder.add...(kcontext, 100); // Positive constraint
end

rule "threeInARowIsBad"
when
    CourseSequentialRequirement($c : course)
    Lecture (course == $c, $firstP : period)
    Lecture (course == $c, period.isImmediatlyAfter($firstP), $secondP : period)
    Lecture (course == $c, period.isImmediatlyAfter($secondP))
then
    scoreHolder.add...(kcontext, -500); // Negative constraint and higher than twice the positive one
end