如何使用OptaPlanner解决多对多关系? [英] How to solve many to many relationship using OptaPlanner?

查看:107
本文介绍了如何使用OptaPlanner解决多对多关系?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们如何使用OptaPlanner 6解决许多问题?例如,在云平衡示例中,如果要将每个进程放在多台计算机/线程上怎么办?更像是并行执行过程.

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.

推荐答案

如果要在关系数据库中存储many2many关系,则与解决问题的方法相同:创建一个额外的Class.

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

例如:在云平衡中,创建一个类Assignment,该类与Process具有many2one关系,并且与Computer具有many2one关系.在课程安排中,情况已经如此:CoursePeriod/Room之间存在很多很多的关系,这由类Lecture实现.

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.

现在,有趣的是,在计划期间,许多类实例的数目是否可变,因为这意味着您的计划实体的数目是可变的.在课程安排中,情况并非如此:每个课程都有固定数量的讲座(每个讲座都有indexInCourse),并且这些课程在调用solve()之前初始化.

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.

如果计划实体的数量是可变的:OptaPlanner 6.0是为此目的而设计的(ScoreDirectorSelector,...中有管道),但尚未经过测试.在将来的版本中,我们将添加这样的示例以及集成测试和压力测试...

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...

这篇关于如何使用OptaPlanner解决多对多关系?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆