我尝试在Optaplanner手册中重现Project Job Scheduling的示例,如下图所示:
以下是xml示例数据:
<PjsSchedule id="0">
<id>0</id>
<projectList id="1">
<PjsProject id="book1">
<id>0</id>
<releaseDate>0</releaseDate>
<criticalPathDuration>7</criticalPathDuration>
<localResourceList id="2" />
<jobList id="3">
<PjsJob id="119">
<id>0</id>
<project reference="book1"/>
<jobType>SOURCE</jobType>
<executionModeList id="11910">
<PjsExecutionMode id="11911">
<id>0</id>
<job reference="119"/>
<duration>0</duration>
<resourceRequirementList id="1192"/>
</PjsExecutionMode>
</executionModeList>
<successorJobList id="11913">
<PjsJob id="design1">
<id>1</id>
<project reference="book1"/>
<jobType>STANDARD</jobType>
<executionModeList id="4">
<PjsExecutionMode id="5">
<id>0</id>
<job reference="design1"/>
<duration>2</duration>
<resourceRequirementList id="6">
<PjsResourceRequirement id="7">
<id>0</id>
<executionMode reference="5"/>
<resource class="PjsGlobalResource" id="designer">
<id>0</id>
<capacity>1</capacity>
</resource>
<requirement>1</requirement>
</PjsResourceRequirement>
</resourceRequirementList>
</PjsExecutionMode>
</executionModeList>
<successorJobList id="8">
<PjsJob id="cover1">
<id>2</id>
<project reference="book1"/>
<jobType>STANDARD</jobType>
<executionModeList id="9">
<PjsExecutionMode id="10">
<id>1</id>
<job reference="cover1"/>
<duration>3</duration>
<resourceRequirementList id="11">
<PjsResourceRequirement id="12">
<id>1</id>
<executionMode reference="10"/>
<resource class="PjsGlobalResource" id="worker1">
<id>1</id>
<capacity>1</capacity>
</resource>
<requirement>1</requirement>
</PjsResourceRequirement>
</resourceRequirementList>
</PjsExecutionMode>
<PjsExecutionMode id="101">
<id>1011</id>
<job reference="cover1"/>
<duration>3</duration>
<resourceRequirementList id="10111">
<PjsResourceRequirement id="10112">
<id>1011</id>
<executionMode reference="101"/>
<resource class="PjsGlobalResource" id="worker2">
<id>2</id>
<capacity>1</capacity>
</resource>
<requirement>1</requirement>
</PjsResourceRequirement>
</resourceRequirementList>
</PjsExecutionMode>
</executionModeList>
<successorJobList id="14">
<PjsJob id="assembly1">
<id>4</id>
<project reference="book1"/>
<jobType>STANDARD</jobType>
<executionModeList id="15">
<PjsExecutionMode id="16">
<id>2</id>
<job reference="assembly1"/>
<duration>1</duration>
<resourceRequirementList id="17">
<PjsResourceRequirement id="18">
<id>3</id>
<executionMode reference="16"/>
<resource class="PjsGlobalResource" reference="worker1"/>
<requirement>1</requirement>
</PjsResourceRequirement>
</resourceRequirementList>
</PjsExecutionMode>
<PjsExecutionMode id="161">
<id>1612</id>
<job reference="assembly1"/>
<duration>1</duration>
<resourceRequirementList id="16117">
<PjsResourceRequirement id="16118">
<id>1613</id>
<executionMode reference="161"/>
<resource class="PjsGlobalResource" reference="worker2"/>
<requirement>1</requirement>
</PjsResourceRequirement>
</resourceRequirementList>
</PjsExecutionMode>
</executionModeList>
<successorJobList id="20">
<PjsJob id="175">
<id>5</id>
<project reference="book1"/>
<jobType>SINK</jobType>
<executionModeList id="17576">
<PjsExecutionMode id="17577">
<id>17531</id>
<job reference="175"/>
<duration>0</duration>
<resourceRequirementList id="17578"/>
</PjsExecutionMode>
</executionModeList>
<successorJobList id="17579"/>
</PjsJob>
</successorJobList>
</PjsJob>
</successorJobList>
</PjsJob>
<PjsJob id="pages400">
<id>3</id>
<project reference="book1"/>
<jobType>STANDARD</jobType>
<executionModeList id="21">
<PjsExecutionMode id="22">
<id>3</id>
<job reference="pages400"/>
<duration>4</duration>
<resourceRequirementList id="23">
<PjsResourceRequirement id="24">
<id>5</id>
<executionMode reference="22"/>
<resource class="PjsGlobalResource" reference="worker1"/>
<requirement>1</requirement>
</PjsResourceRequirement>
</resourceRequirementList>
</PjsExecutionMode>
<PjsExecutionMode id="221">
<id>2213</id>
<job reference="pages400"/>
<duration>4</duration>
<resourceRequirementList id="22123">
<PjsResourceRequirement id="22124">
<id>2215</id>
<executionMode reference="221"/>
<resource class="PjsGlobalResource" reference="worker2"/>
<requirement>1</requirement>
</PjsResourceRequirement>
</resourceRequirementList>
</PjsExecutionMode>
</executionModeList>
<successorJobList id="26">
<PjsJob reference="assembly1"/>
</successorJobList>
</PjsJob>
</successorJobList>
</PjsJob>
</successorJobList>
</PjsJob>
<PjsJob reference="design1"/>
<PjsJob reference="cover1"/>
<PjsJob reference="pages400"/>
<PjsJob reference="assembly1"/>
<PjsJob reference="175"/>
</jobList>
</PjsProject>
<PjsProject id="book2">
<id>1</id>
<releaseDate>0</releaseDate>
<criticalPathDuration>8</criticalPathDuration>
<localResourceList id="27" />
<jobList id="28">
<PjsJob id="219">
<id>6</id>
<project reference="book2"/>
<jobType>SOURCE</jobType>
<executionModeList id="21910">
<PjsExecutionMode id="21911">
<id>0</id>
<job reference="219"/>
<duration>0</duration>
<resourceRequirementList id="2192"/>
</PjsExecutionMode>
</executionModeList>
<successorJobList id="21913">
<PjsJob id="design2">
<id>7</id>
<project reference="book2"/>
<jobType>STANDARD</jobType>
<executionModeList id="29">
<PjsExecutionMode id="30">
<id>5</id>
<job reference="design2"/>
<duration>2</duration>
<resourceRequirementList id="31">
<PjsResourceRequirement id="32">
<id>7</id>
<executionMode reference="30"/>
<resource class="PjsGlobalResource" reference="designer"/>
<requirement>1</requirement>
</PjsResourceRequirement>
</resourceRequirementList>
</PjsExecutionMode>
</executionModeList>
<successorJobList id="31">
<PjsJob id="cover2">
<id>8</id>
<project reference="book2"/>
<jobType>STANDARD</jobType>
<executionModeList id="32">
<PjsExecutionMode id="33">
<id>5</id>
<job reference="cover2"/>
<duration>3</duration>
<resourceRequirementList id="34">
<PjsResourceRequirement id="35">
<id>8</id>
<executionMode reference="33"/>
<resource class="PjsGlobalResource" reference="worker1"/>
<requirement>1</requirement>
</PjsResourceRequirement>
</resourceRequirementList>
</PjsExecutionMode>
<PjsExecutionMode id="331">
<id>3315</id>
<job reference="cover2"/>
<duration>3</duration>
<resourceRequirementList id="33134">
<PjsResourceRequirement id="33135">
<id>3318</id>
<executionMode reference="331"/>
<resource class="PjsGlobalResource" reference="worker2"/>
<requirement>1</requirement>
</PjsResourceRequirement>
</resourceRequirementList>
</PjsExecutionMode>
</executionModeList>
<successorJobList id="34">
<PjsJob id="assembly2">
<id>10</id>
<project reference="book2"/>
<jobType>STANDARD</jobType>
<executionModeList id="35">
<PjsExecutionMode id="36">
<id>366</id>
<job reference="assembly2"/>
<duration>1</duration>
<resourceRequirementList id="37">
<PjsResourceRequirement id="38">
<id>383</id>
<executionMode reference="36"/>
<resource class="PjsGlobalResource" reference="worker1"/>
<requirement>1</requirement>
</PjsResourceRequirement>
</resourceRequirementList>
</PjsExecutionMode>
<PjsExecutionMode id="361">
<id>3661</id>
<job reference="assembly2"/>
<duration>1</duration>
<resourceRequirementList id="371">
<PjsResourceRequirement id="381">
<id>3831</id>
<executionMode reference="361"/>
<resource class="PjsGlobalResource" reference="worker2"/>
<requirement>1</requirement>
</PjsResourceRequirement>
</resourceRequirementList>
</PjsExecutionMode>
</executionModeList>
<successorJobList id="39">
<PjsJob id="275">
<id>11</id>
<project reference="book2"/>
<jobType>SINK</jobType>
<executionModeList id="27576">
<PjsExecutionMode id="27577">
<id>27531</id>
<job reference="275"/>
<duration>0</duration>
<resourceRequirementList id="27578"/>
</PjsExecutionMode>
</executionModeList>
<successorJobList id="27579"/>
</PjsJob>
</successorJobList>
</PjsJob>
</successorJobList>
</PjsJob>
<PjsJob id="pages500">
<id>9</id>
<project reference="book2"/>
<jobType>STANDARD</jobType>
<executionModeList id="40">
<PjsExecutionMode id="41">
<id>413</id>
<job reference="pages500"/>
<duration>5</duration>
<resourceRequirementList id="42">
<PjsResourceRequirement id="43">
<id>435</id>
<executionMode reference="41"/>
<resource class="PjsGlobalResource" reference="worker1"/>
<requirement>1</requirement>
</PjsResourceRequirement>
</resourceRequirementList>
</PjsExecutionMode>
<PjsExecutionMode id="411">
<id>4131</id>
<job reference="pages500"/>
<duration>5</duration>
<resourceRequirementList id="421">
<PjsResourceRequirement id="431">
<id>4351</id>
<executionMode reference="411"/>
<resource class="PjsGlobalResource" reference="worker2"/>
<requirement>1</requirement>
</PjsResourceRequirement>
</resourceRequirementList>
</PjsExecutionMode>
</executionModeList>
<successorJobList id="44">
<PjsJob reference="assembly2"/>
</successorJobList>
</PjsJob>
</successorJobList>
</PjsJob>
</successorJobList>
</PjsJob>
<PjsJob reference="design2"/>
<PjsJob reference="cover2"/>
<PjsJob reference="pages500"/>
<PjsJob reference="assembly2"/>
<PjsJob reference="275"/>
</jobList>
</PjsProject>
</projectList>
<jobList id="366">
<PjsJob reference="119"/>
<PjsJob reference="design1"/>
<PjsJob reference="cover1"/>
<PjsJob reference="pages400"/>
<PjsJob reference="assembly1"/>
<PjsJob reference="175"/>
<PjsJob reference="219"/>
<PjsJob reference="design2"/>
<PjsJob reference="cover2"/>
<PjsJob reference="pages500"/>
<PjsJob reference="assembly2"/>
<PjsJob reference="275"/>
</jobList>
<executionModeList id="367">
<PjsExecutionMode reference="11910"/>
<PjsExecutionMode reference="21910"/>
<PjsExecutionMode reference="17577"/>
<PjsExecutionMode reference="27577"/>
<PjsExecutionMode reference="5"/>
<PjsExecutionMode reference="10"/>
<PjsExecutionMode reference="101"/>
<PjsExecutionMode reference="16"/>
<PjsExecutionMode reference="161"/>
<PjsExecutionMode reference="22"/>
<PjsExecutionMode reference="221"/>
<PjsExecutionMode reference="30"/>
<PjsExecutionMode reference="33"/>
<PjsExecutionMode reference="331"/>
<PjsExecutionMode reference="36"/>
<PjsExecutionMode reference="361"/>
<PjsExecutionMode reference="41"/>
<PjsExecutionMode reference="411"/>
</executionModeList>
<resourceList id="368">
<PjsGlobalResource reference="designer"/>
<PjsGlobalResource reference="worker1"/>
<PjsGlobalResource reference="worker2"/>
</resourceList>
<resourceRequirementList id="369">
<PjsResourceRequirement reference="7"/>
<PjsResourceRequirement reference="12"/>
<PjsResourceRequirement reference="10112"/>
<PjsResourceRequirement reference="18"/>
<PjsResourceRequirement reference="16118"/>
<PjsResourceRequirement reference="24"/>
<PjsResourceRequirement reference="22124"/>
<PjsResourceRequirement reference="32"/>
<PjsResourceRequirement reference="35"/>
<PjsResourceRequirement reference="33135"/>
<PjsResourceRequirement reference="38"/>
<PjsResourceRequirement reference="381"/>
<PjsResourceRequirement reference="43"/>
<PjsResourceRequirement reference="431"/>
</resourceRequirementList>
<allocationList id="370">
<PjsAllocation id="a1">
<id>0</id>
<job reference="119"/>
<sourceAllocation reference="a1"/>
<sinkAllocation id="a2">
<id>5</id>
<job reference="175"/>
<sourceAllocation reference="a1"/>
<sinkAllocation reference="a2"/>
<predecessorAllocationList id="373">
<PjsAllocation id="a3">
<id>4</id>
<job reference="assembly1"/>
<sourceAllocation reference="a1"/>
<sinkAllocation reference="a2"/>
<predecessorAllocationList id="4051">
<PjsAllocation id="a4">
<id>2</id>
<job reference="cover1"/>
<sourceAllocation reference="a1"/>
<sinkAllocation reference="a2"/>
<predecessorAllocationList id="4251">
<PjsAllocation id="a5">
<id>1</id>
<job reference="design1"/>
<sourceAllocation reference="a1"/>
<sinkAllocation reference="a2"/>
<predecessorAllocationList id="4252">
<PjsAllocation reference="a1"/>
</predecessorAllocationList>
<successorAllocationList id="4261">
<PjsAllocation reference="a4"/>
<PjsAllocation id="a6">
<id>3</id>
<job reference="pages400"/>
<sourceAllocation reference="a1"/>
<sinkAllocation reference="a2"/>
<predecessorAllocationList id="4253">
<PjsAllocation reference="a5"/>
</predecessorAllocationList>
<successorAllocationList id="4263">
<PjsAllocation reference="a3"/>
</successorAllocationList>
<predecessorsDoneDate>0</predecessorsDoneDate>
</PjsAllocation>
</successorAllocationList>
<predecessorsDoneDate>0</predecessorsDoneDate>
</PjsAllocation>
</predecessorAllocationList>
<successorAllocationList id="4262">
<PjsAllocation reference="a3"/>
</successorAllocationList>
<predecessorsDoneDate>0</predecessorsDoneDate>
</PjsAllocation>
<PjsAllocation reference="a6"/>
</predecessorAllocationList>
<successorAllocationList id="4061">
<PjsAllocation reference="a2"/>
</successorAllocationList>
<predecessorsDoneDate>0</predecessorsDoneDate>
</PjsAllocation>
</predecessorAllocationList>
<successorAllocationList id="4161"/>
<executionMode reference="17577"/>
<delay>0</delay>
<predecessorsDoneDate>0</predecessorsDoneDate>
</sinkAllocation>
<predecessorAllocationList id="405"/>
<successorAllocationList id="406">
<PjsAllocation reference="a5"/>
</successorAllocationList>
<executionMode reference="11911"/>
<delay>0</delay>
<predecessorsDoneDate>0</predecessorsDoneDate>
</PjsAllocation>
<PjsAllocation reference="a5"/>
<PjsAllocation reference="a4"/>
<PjsAllocation reference="a6"/>
<PjsAllocation reference="a3"/>
<PjsAllocation reference="a2"/>
<PjsAllocation id="b1">
<id>6</id>
<job reference="219"/>
<sourceAllocation reference="b1"/>
<sinkAllocation id="b2">
<id>11</id>
<job reference="275"/>
<sourceAllocation reference="b1"/>
<sinkAllocation reference="b2"/>
<predecessorAllocationList id="273">
<PjsAllocation id="b3">
<id>10</id>
<job reference="assembly2"/>
<sourceAllocation reference="b1"/>
<sinkAllocation reference="b2"/>
<predecessorAllocationList id="2051">
<PjsAllocation id="b4">
<id>8</id>
<job reference="cover2"/>
<sourceAllocation reference="b1"/>
<sinkAllocation reference="b2"/>
<predecessorAllocationList id="2251">
<PjsAllocation id="b5">
<id>7</id>
<job reference="design2"/>
<sourceAllocation reference="b1"/>
<sinkAllocation reference="b2"/>
<predecessorAllocationList id="2252">
<PjsAllocation reference="b1"/>
</predecessorAllocationList>
<successorAllocationList id="2261">
<PjsAllocation reference="b4"/>
<PjsAllocation id="b6">
<id>9</id>
<job reference="pages500"/>
<sourceAllocation reference="b1"/>
<sinkAllocation reference="b2"/>
<predecessorAllocationList id="2253">
<PjsAllocation reference="b5"/>
</predecessorAllocationList>
<successorAllocationList id="2263">
<PjsAllocation reference="b3"/>
</successorAllocationList>
<predecessorsDoneDate>0</predecessorsDoneDate>
</PjsAllocation>
</successorAllocationList>
<predecessorsDoneDate>0</predecessorsDoneDate>
</PjsAllocation>
</predecessorAllocationList>
<successorAllocationList id="2262">
<PjsAllocation reference="b3"/>
</successorAllocationList>
<predecessorsDoneDate>0</predecessorsDoneDate>
</PjsAllocation>
<PjsAllocation reference="b6"/>
</predecessorAllocationList>
<successorAllocationList id="2061">
<PjsAllocation reference="b2"/>
</successorAllocationList>
<predecessorsDoneDate>0</predecessorsDoneDate>
</PjsAllocation>
</predecessorAllocationList>
<successorAllocationList id="2161"/>
<executionMode reference="27577"/>
<delay>0</delay>
<predecessorsDoneDate>0</predecessorsDoneDate>
</sinkAllocation>
<predecessorAllocationList id="205"/>
<successorAllocationList id="206">
<PjsAllocation reference="b5"/>
</successorAllocationList>
<executionMode reference="21911"/>
<delay>0</delay>
<predecessorsDoneDate>0</predecessorsDoneDate>
</PjsAllocation>
<PjsAllocation reference="b5"/>
<PjsAllocation reference="b4"/>
<PjsAllocation reference="b6"/>
<PjsAllocation reference="b3"/>
<PjsAllocation reference="b2"/>
</allocationList>
</PjsSchedule>
当我尝试使用Optaplanner示例应用程序解决它时的结果与图片中的结果不同,而是看起来像这样:
从结果中可以看出,项目0(作业1)和项目1(作业7)的设计作业并行执行,而设计师资源只有1个人。请帮帮我,我做错了什么?以及如何解决它?
谢谢&amp;问候。
答案 0 :(得分:0)
我发布此答案,以防有人可能遇到与我相同或类似的问题。首先,我运行xml输入文件(在我的问题中发布)使用我从eclipse运行的Optaplanner示例(源代码是从导入代码拉出来的,完全未编辑),它在我的问题帖子中给出了我的第一个结果。 然后我尝试从分发zip运行Optaplanner(使用runExamples.bat)并尝试解决xml输入文件,它给了我预期的结果:
当我深入挖掘时,结果是projectJobSchedulingScoreRules.drl可能有错误。我试图将得分计算器从scoreDrl更改为incrementalScoreCalculatorClass,现在它给了我预期的结果。我希望Optaplanner团队意识到这个问题。