了解 Drools planner 示例:p‌r‌o‌b‌l‌e‌m 状态在哪里初始化?

发布于 2024-12-28 07:43:30 字数 872 浏览 4 评论 0原文

我试图理解 Drools 的 N QueensCloud Balancer 示例。我深入研究了手册的第 3 章和第 4 章以及两个示例的来源。

我(错误)理解

  1. 问题必须从未分配或非最佳状态开始
  2. 因此,必须实例化问题事实和规划实体(POJO)
  3. 解决方案类,例如CloudBalance或NQueens必须了解问题事实和规划实体

问题1:在示例中,规划实体和问题事实类的对象在哪里初始化

例如,当我加载云平衡时,我看到:

2012 .. INFO  Loaded: data/cloudbalancing/unsolved/cb-0002comp-0006proc.xml

这意味着序列化格式被转换为真实对象并输入到解决方案中,对吗?


问题2:规划实体在哪里处理?

该评论的含义是什么?最初是如何处理的?

public Collection<? extends Object> getProblemFacts() {
    List<Object> facts = new ArrayList<Object>();
    facts.addAll(columnList);
    facts.addAll(rowList);
    // Do not add the planning entity's (queenList) because that will be done automatically 

I am trying to understand the N Queens and Cloud Balancer examples of Drools. I delved into chapter 3 and 4 of the manual and the sources for the two examples.

I (mis)understand that

  1. The problem has to begin from an unassigned or unoptimal state
  2. So then, the problem facts and planning entities, which are POJOs, have to be instantiated
  3. The solution class, such as CloudBalance or NQueens have to be aware of the problem facts and planning entities

Question 1: In the examples, where are the objects of the planning entity and problem fact classes initialized?

For example, when I load the cloud balancing, I see this:

2012 .. INFO  Loaded: data/cloudbalancing/unsolved/cb-0002comp-0006proc.xml

This means that a serialized format is converted to real objects and fed into a solution right?


Question 2: Where are the planning entities handled?

What is the meaning of that comment? How was that handled in the first place?

public Collection<? extends Object> getProblemFacts() {
    List<Object> facts = new ArrayList<Object>();
    facts.addAll(columnList);
    facts.addAll(rowList);
    // Do not add the planning entity's (queenList) because that will be done automatically 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

无所的.畏惧 2025-01-04 07:43:30

Q1:规划实例是在 NQueensGeneratorCurriculumCourseSolutionImporter 中创建的,然后使用 XStream 序列化为 XML 文件。加载按钮只是将它们从 XML 反序列化。如果您想要调试 *SolutionImporter,请使用导入按钮(并非在所有示例中都可用)。

Q2:这意味着 getProblemFacts() 不应该执行facts.addAll(queenList)。
由于此注释,规划器会自动执行此操作:

@PlanningEntityCollectionProperty
public List<Queen> getQueenList() {
    return queenList;
}

Q1: The planning instances where created in NQueensGenerator, CurriculumCourseSolutionImporter, ... and then serialized to an XML file with XStream. The load button just deserializes them from XML. Use the import button (not available in all examples) if you want to debug a *SolutionImporter.

Q2: It means that getProblemFacts() should not do facts.addAll(queenList).
Planner does that automatically due to this annotation:

@PlanningEntityCollectionProperty
public List<Queen> getQueenList() {
    return queenList;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文