简体   繁体   中英

Optaplanner: Can we use two planning variables with (nullable = true)?

Can we use two planning variables with (nullable = true) for each of them?

If so, how can we deal with them in the Drools rule file?

I know that when we use one planning variable we define it with (nullable = true) and then in the rule we use $planningVariable != null as in the " pas " example, I tried this and it worked well, but what about using two planning variables?

Can we apply this on the curriculumCourse ? and if so, the over constrained data should appear in the output as unassigned for the two planning variables or appear in only one of them?

Yes, of course you can. But as usual, you 'll have to make sure your score constraints (= score rules) penalize/reward what you want to achieve.

For example on CurriculumCourse, I presume you 'd have a negative medium constraint that penalizes a Lecture if either room or period is null . If both are null , don't penalize it more, or you'll end up with a lot semi assigned entities. But despite that, you'll still probably end up with a few semi assigned entities, so to fix that:

  • Either do some post-processing to make all those not assigned at all (= both vars null ) as a semi-assignment is useless.
  • Or add a hard constraint against semi assignments to avoid them entirely (even in intermediate solution states).

Additional solving efficiently can be gained from:

  • A ChangeMove selector that moves both room and period, as changing just one to/from null will never yield a better solution.

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