0

Is it possible to define a particular day particular hours (example, 5 and 6) are no classes? in opta course curricula planner.

Tried the following approach, doesn't work.

rule "saturdayHalfDay"
    when
        Lecture( period!=null, $day:period.getDay(),
        $day!=null,$time:period.getTimeslot(),
        $time!=null,
        $day.getDayIndex()==5,
        ($time.getTimeslotIndex()==5 || $time.getTimeslotIndex()==4) 
        )   

    then
     System.out.println(" $day " + $day + " $time " + $time);
        scoreHolder.addHardConstraintMatch(kcontext, -1);
end

//assume that $day.getDayIndex()==5 (5 is saturday)

NightShadeQueen
  • 3,284
  • 3
  • 24
  • 37

1 Answers1

0

If you start from the Curriculum Course scheduling example, you'll see that some datasets don't have a Timeslot for 12:00 to 13:00, because there are no classes during lunch. So it's simply a matter of not adding a Timeslot for those hours.

It becomes more interesting if some Courses can't be scheduled during a certain Timeslot. Simply create a TimeslotCoursePenatly object (see the Penatly classes in other examples) to be able to put an unwanted combination in the dataset. Then add a score rules that checks that lowers the hard score for each Penalty that is violated.

Geoffrey De Smet
  • 26,223
  • 11
  • 73
  • 120
  • "Penatly " classes example, unable to find this class in opta planner. could you please provide more detail on this? – user1424130 Sep 24 '15 at 05:29
  • Go to [https://github.com/droolsjbpm/optaplanner](https://github.com/droolsjbpm/optaplanner), press the button "t" and type "Penalty". – Geoffrey De Smet Sep 24 '15 at 06:05
  • I tried the following approach, doesnt work. any suggestions? rule "saturdayHalfDay" when Lecture( period!=null, $day:period.getDay(), $day!=null,$time:period.getTimeslot(), $time!=null, $day.getDayIndex()==5, ($time.getTimeslotIndex()==5 || $time.getTimeslotIndex()==4) ) then System.out.println(" $day " + $day + " $time " + $time); scoreHolder.addHardConstraintMatch(kcontext, -1); end //assume that $day.getDayIndex()==5 (5 is saturday) – user1424130 Sep 24 '15 at 09:33