How to solve many to many relationship using OptaPlanner?

旧城冷巷雨未停 提交于 2019-12-11 08:22:55

问题


How do we solve many to many problems using OptaPlanner 6? For example, in cloud balancing example, what do we need to do if we want to put each process on multiple computers/threads? More like parallel execution of the process.


回答1:


The same way as you solve it if you want to store a many2many relationship in a relational database: create an extra Class.

For example: In cloud balancing, create a class Assignment that has a many2one relationship to Process and a many2one relationship to Computer. In curriculum course scheduling, this is already the case: there is a many2many relationship between Course and Period/Room, which is implemented by the class Lecture.

Now, where it becomes interesting is if the number of that many2many-class instances is variable during planning, because that means that your number of planning entities is variable. In curriculum course scheduling, this is not the case: each Course has a fixed amount of lectures (and each Lecture has an indexInCourse) and those lectures are initialized before solve() is called.

If the number of planning entities is variable: OptaPlanner 6.0 is designed for that (there is plumbing in ScoreDirector, Selector, ...), but not tested yet. In a future version we'll add such an example and integration tests and stress tests...



来源:https://stackoverflow.com/questions/21717109/how-to-solve-many-to-many-relationship-using-optaplanner

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!