<div dir="ltr">i forgot adding the main class:<div>-----------------</div><div><br></div><div><div>public static void main(String[] args) {</div><div><span class="" style="white-space:pre">                </span>String t = &quot;&lt;?xml version=\&quot;1.0\&quot; encoding=\&quot;UTF-8\&quot;?&gt;&quot;</div>
<div><span class="" style="white-space:pre">                                </span>+ &quot;&lt;solver&gt;&quot;</div><div><span class="" style="white-space:pre">                                </span>+ &quot;  &lt;solutionClass&gt;com.swa.planner.domain.Distributor&lt;/solutionClass&gt;&quot;</div>
<div><span class="" style="white-space:pre">                                </span>+ &quot;  &lt;planningEntityClass&gt;com.swa.planner.domain.Engineer&lt;/planningEntityClass&gt;&quot;</div><div><span class="" style="white-space:pre">                                </span>+ &quot;  &lt;scoreDirectorFactory&gt;&quot;</div>
<div><span class="" style="white-space:pre">                                </span>+ &quot;    &lt;scoreDefinitionType&gt;HARD_AND_SOFT&lt;/scoreDefinitionType&gt;&quot;</div><div><span class="" style="white-space:pre">                                </span>+ &quot;    &lt;scoreDrl&gt;/com/swa/planner/domain/rule/distributorScoreRules.drl&lt;/scoreDrl&gt;&quot;</div>
<div><span class="" style="white-space:pre">                                </span>+ &quot;  &lt;/scoreDirectorFactory&gt;&quot;</div><div>//<span class="" style="white-space:pre">                                </span>+ &quot;  &lt;termination&gt;&quot;</div><div>//<span class="" style="white-space:pre">                                </span>+ &quot;    &lt;maximumSecondsSpend&gt;120&lt;/maximumSecondsSpend&gt;&quot;</div>
<div>//<span class="" style="white-space:pre">                                </span>+ &quot;  &lt;/termination&gt;&quot;</div><div><span class="" style="white-space:pre">                                </span>+ &quot;  &lt;constructionHeuristic&gt;&quot;</div><div><span class="" style="white-space:pre">                                </span>+ &quot;    &lt;constructionHeuristicType&gt;FIRST_FIT_DECREASING&lt;/constructionHeuristicType&gt;&quot;</div>
<div><span class="" style="white-space:pre">                                </span>+ &quot;    &lt;constructionHeuristicPickEarlyType&gt;FIRST_LAST_STEP_SCORE_EQUAL_OR_IMPROVING&lt;/constructionHeuristicPickEarlyType&gt;&quot;</div><div><span class="" style="white-space:pre">                                </span>+ &quot;  &lt;/constructionHeuristic&gt;&quot;</div>
<div><span class="" style="white-space:pre">                                </span>+ &quot;  &lt;localSearch&gt;&quot;</div><div><span class="" style="white-space:pre">                                </span>+ &quot;    &lt;acceptor&gt;&quot;</div><div><span class="" style="white-space:pre">                                </span>+ &quot;      &lt;planningEntityTabuSize&gt;7&lt;/planningEntityTabuSize&gt;&quot;</div>
<div><span class="" style="white-space:pre">                                </span>+ &quot;    &lt;/acceptor&gt;&quot;</div><div><span class="" style="white-space:pre">                                </span>+ &quot;    &lt;forager&gt;&quot;</div><div><span class="" style="white-space:pre">                                </span>+ &quot;      &lt;minimalAcceptedSelection&gt;1000&lt;/minimalAcceptedSelection&gt;&quot;</div>
<div><span class="" style="white-space:pre">                                </span>+ &quot;    &lt;/forager&gt;&quot; + &quot;  &lt;/localSearch&gt;&quot; + &quot;&lt;/solver&gt;&quot;;</div><div><br></div><div><span class="" style="white-space:pre">                </span>byte b[] = t.getBytes();</div>
<div><span class="" style="white-space:pre">                </span>ByteArrayInputStream bt = new ByteArrayInputStream(b);</div><div><span class="" style="white-space:pre">                </span>SolverFactory solverFactory = new XmlSolverFactory().configure(bt);</div>
<div><span class="" style="white-space:pre">                </span>Solver solver = solverFactory.buildSolver();</div><div><span class="" style="white-space:pre">                </span></div><div><span class="" style="white-space:pre">                </span>List&lt;Engineer&gt; engineerList = new ArrayList&lt;Engineer&gt;();</div>
<div><span class="" style="white-space:pre">                </span>engineerList.add(new Engineer(1L, &quot;Aladin&quot;, 8));</div><div><span class="" style="white-space:pre">                </span>engineerList.add(new Engineer(2L, &quot;Chuck Norris&quot;, 8));</div>
<div><span class="" style="white-space:pre">                </span>engineerList.add(new Engineer(3L, &quot;Rambo&quot;, 8));</div><div><span class="" style="white-space:pre">                </span>engineerList.add(new Engineer(4L, &quot;Mr. Miyagi&quot;, 8));</div>
<div><span class="" style="white-space:pre">                </span>engineerList.add(new Engineer(5L, &quot;Monkey D. Ruffy&quot;, 8));</div><div><span class="" style="white-space:pre">                </span></div><div><span class="" style="white-space:pre">                </span>List&lt;WorkOrder&gt; workOrderList = new ArrayList&lt;WorkOrder&gt;();</div>
<div><span class="" style="white-space:pre">                </span>workOrderList.add(new WorkOrder(6L, 1, 2));</div><div><span class="" style="white-space:pre">                </span>workOrderList.add(new WorkOrder(7L, 1, 6));</div><div><span class="" style="white-space:pre">                </span>workOrderList.add(new WorkOrder(8L, 1, 3));</div>
<div><span class="" style="white-space:pre">                </span>workOrderList.add(new WorkOrder(9L, 1, 3));</div><div><span class="" style="white-space:pre">                </span>workOrderList.add(new WorkOrder(10L, 1, 2));</div><div><span class="" style="white-space:pre">                </span>workOrderList.add(new WorkOrder(11L, 1, 8));</div>
<div><span class="" style="white-space:pre">                </span>workOrderList.add(new WorkOrder(12L, 1, 8));</div><div><span class="" style="white-space:pre">                </span>workOrderList.add(new WorkOrder(13L, 1, 2));</div><div><span class="" style="white-space:pre">                </span>workOrderList.add(new WorkOrder(14L, 1, 2));</div>
<div><span class="" style="white-space:pre">                </span>workOrderList.add(new WorkOrder(15L, 1, 4));</div><div><br></div><div><span class="" style="white-space:pre">                </span>Distributor distributor = new Distributor();</div>
<div><span class="" style="white-space:pre">                </span>distributor.setId(0L);</div><div><span class="" style="white-space:pre">                </span>distributor.setEngineerList(engineerList);</div><div><span class="" style="white-space:pre">                </span>distributor.setWorkOrderList(workOrderList);</div>
<div><br></div><div><span class="" style="white-space:pre">                </span>solver.setPlanningProblem(distributor);</div><div><span class="" style="white-space:pre">                </span>solver.solve();</div><div><span class="" style="white-space:pre">                </span>Distributor solvedWorkOrderDistribution = (Distributor) solver.getBestSolution();</div>
<div><br></div><div><span class="" style="white-space:pre">                </span>System.out.printf(&quot;\nSolved distribution with %d work orders and %d engineers:\n%s&quot;,</div><div><span class="" style="white-space:pre">                                                </span>workOrderList.size(), engineerList.size(),</div>
<div><span class="" style="white-space:pre">                                                </span>toDisplayString(solvedWorkOrderDistribution));</div><div><span class="" style="white-space:pre">        </span>}</div><div><br></div><div><span class="" style="white-space:pre">        </span>public static String toDisplayString(Distributor distributor) {</div>
<div><span class="" style="white-space:pre">                </span>StringBuilder displayString = new StringBuilder();</div><div><span class="" style="white-space:pre">                </span>for (Engineer engineer : distributor.getEngineerList()) {</div>
<div><span class="" style="white-space:pre">                        </span>WorkOrder order = engineer.getWorkOrder();</div><div><span class="" style="white-space:pre">                        </span>displayString.append(&quot;  &quot;).append(engineer.getLabel()).append(&quot; : &quot;)</div>
<div><span class="" style="white-space:pre">                                        </span>.append(order == null ? null : order.getLabel())</div><div><span class="" style="white-space:pre">                                        </span>.append(&quot;\n&quot;);</div><div><span class="" style="white-space:pre">                </span>}</div>
<div><span class="" style="white-space:pre">                </span>return displayString.toString();</div><div><span class="" style="white-space:pre">        </span>}</div></div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">
2013/1/28 André Fróes <span dir="ltr">&lt;<a href="mailto:arfmoraes@gmail.com" target="_blank">arfmoraes@gmail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">Hello! After trying cloudComputer example i&#39;m trying to implement my own schedule distributor, but now i&#39;m facing heap space error, but i see that it does distribute some work orders. Here&#39;s the console error:<div>

<br></div><div>-------------------</div><div><div>17:05:02.776 [main] INFO  o.d.p.core.solver.DefaultSolver - Solving started: time spend (255), score (null), new best score (null), random seed (0).</div><div>17:05:02.821 [main] DEBUG o.d.p.c.c.g.DefaultGreedyFitSolverPhase -     Step index (0), time spend (309), score (0hard/0soft), initialized planning entity ([Engineer-5]).</div>

<div>17:05:02.822 [main] DEBUG o.d.p.c.c.g.DefaultGreedyFitSolverPhase -     Step index (1), time spend (310), score (0hard/0soft), initialized planning entity ([Engineer-4]).</div><div>17:05:02.824 [main] DEBUG o.d.p.c.c.g.DefaultGreedyFitSolverPhase -     Step index (2), time spend (311), score (0hard/0soft), initialized planning entity ([Engineer-3]).</div>

<div>17:05:02.824 [main] DEBUG o.d.p.c.c.g.DefaultGreedyFitSolverPhase -     Step index (3), time spend (312), score (0hard/0soft), initialized planning entity ([Engineer-2]).</div><div>17:05:02.825 [main] DEBUG o.d.p.c.c.g.DefaultGreedyFitSolverPhase -     Step index (4), time spend (313), score (0hard/0soft), initialized planning entity ([Engineer-1]).</div>

<div>17:05:02.825 [main] INFO  o.d.p.c.c.g.DefaultGreedyFitSolverPhase - Phase constructionHeuristic ended: step total (5), time spend (313), best score (0hard/0soft).</div><div>17:05:03.020 [main] DEBUG o.d.p.c.l.DefaultLocalSearchSolverPhase -     Step index (0), time spend (508), score (0hard/0soft),     best score (0hard/0soft), accepted/selected move count (1000/1000) for picked step ([Engineer-3] =&gt; [WorkOrder-12]).</div>

<div>17:05:03.315 [main] DEBUG o.d.p.c.l.DefaultLocalSearchSolverPhase -     Step index (1), time spend (803), score (0hard/0soft),     best score (0hard/0soft), accepted/selected move count (1000/1703) for picked step ([Engineer-4] =&gt; [WorkOrder-8]).</div>

<div>17:05:03.736 [main] DEBUG o.d.p.c.l.DefaultLocalSearchSolverPhase -     Step index (2), time spend (1224), score (0hard/0soft),     best score (0hard/0soft), accepted/selected move count (1000/2657) for picked step ([Engineer-1] =&gt; [WorkOrder-8]).</div>

<div>17:05:03.951 [main] DEBUG o.d.p.c.l.DefaultLocalSearchSolverPhase -     Step index (3), time spend (1439), score (0hard/0soft),     best score (0hard/0soft), accepted/selected move count (1000/4315) for picked step ([Engineer-5] =&gt; [WorkOrder-9]).</div>

<div>17:05:04.251 [main] DEBUG o.d.p.c.l.DefaultLocalSearchSolverPhase -     Step index (4), time spend (1739), score (0hard/0soft),     best score (0hard/0soft), accepted/selected move count (1000/9309) for picked step ([Engineer-2] =&gt; [WorkOrder-9]).</div>

<div>Exception in thread &quot;main&quot; java.lang.OutOfMemoryError: Java heap space</div><div><span style="white-space:pre-wrap">        </span>at java.util.Arrays.copyOf(Unknown Source)</div><div><span style="white-space:pre-wrap">        </span>at java.util.Arrays.copyOf(Unknown Source)</div>

<div><span style="white-space:pre-wrap">        </span>at java.util.ArrayList.grow(Unknown Source)</div><div><span style="white-space:pre-wrap">        </span>at java.util.ArrayList.ensureCapacityInternal(Unknown Source)</div><div>
<span style="white-space:pre-wrap">        </span>at java.util.ArrayList.add(Unknown Source)</div><div><span style="white-space:pre-wrap">        </span>at org.drools.planner.core.localsearch.decider.forager.AcceptedForager.addToMaxScoreUnacceptedList(AcceptedForager.java:143)</div>

<div><span style="white-space:pre-wrap">        </span>at org.drools.planner.core.localsearch.decider.forager.AcceptedForager.addMove(AcceptedForager.java:101)</div><div><span style="white-space:pre-wrap">        </span>at org.drools.planner.core.localsearch.decider.DefaultDecider.processMove(DefaultDecider.java:164)</div>

<div><span style="white-space:pre-wrap">        </span>at org.drools.planner.core.localsearch.decider.DefaultDecider.doMove(DefaultDecider.java:144)</div><div><span style="white-space:pre-wrap">        </span>at org.drools.planner.core.localsearch.decider.DefaultDecider.decideNextStep(DefaultDecider.java:116)</div>

<div><span style="white-space:pre-wrap">        </span>at org.drools.planner.core.localsearch.DefaultLocalSearchSolverPhase.solve(DefaultLocalSearchSolverPhase.java:62)</div><div><span style="white-space:pre-wrap">        </span>at org.drools.planner.core.solver.DefaultSolver.runSolverPhases(DefaultSolver.java:190)</div>

<div><span style="white-space:pre-wrap">        </span>at org.drools.planner.core.solver.DefaultSolver.solve(DefaultSolver.java:155)</div><div><span style="white-space:pre-wrap">        </span>at com.swa.planner.domain.WorkOrderTest.main(WorkOrderTest.java:66)</div>

</div><div>------------------------</div><div><br></div><div>it does distribute some engineers to work orders, but after a while, it just show the error.</div><div><br></div><div>The drl is very simple:</div>
<div><br></div><div>--------------------------</div><div><div>import org.drools.planner.core.score.buildin.hardandsoft.HardAndSoftScoreHolder;</div><div>import org.drools.planner.core.score.constraint.IntConstraintOccurrence;</div>

<div>import org.drools.planner.core.score.constraint.ConstraintType;</div><div><br></div><div>import com.swa.planner.domain.Distributor;</div><div>import com.swa.planner.domain.Engineer;</div><div>import com.swa.planner.domain.WorkOrder;</div>

<div><br></div><div>global HardAndSoftScoreHolder scoreHolder;</div><div><br></div><div>rule &quot;requiredTimeToFinish&quot;</div><div><span style="white-space:pre-wrap">        </span>when</div><div><span style="white-space:pre-wrap">                </span>$workOrder : WorkOrder($time : time)</div>

<div><span style="white-space:pre-wrap">                </span>$requiredTimeTotal : Number(intValue &gt; $time) from accumulate(</div><div><span style="white-space:pre-wrap">                        </span>Engineer (</div><div><span style="white-space:pre-wrap">                                </span>workOrder == $workOrder, </div>

<div><span style="white-space:pre-wrap">                                </span>$requiredTime : worktime),</div><div><span style="white-space:pre-wrap">                        </span>sum($requiredTime)</div><div><span style="white-space:pre-wrap">                </span>)</div>
<div><span style="white-space:pre-wrap">        </span>then</div><div><span style="white-space:pre-wrap">                </span>insertLogical(new IntConstraintOccurrence(&quot;requiredTimeToFinish&quot;, ConstraintType.NEGATIVE_HARD,</div>
<div><span style="white-space:pre-wrap">                                </span>$requiredTimeTotal.intValue() - $time,</div><div><span style="white-space:pre-wrap">                                </span>$workOrder));</div><div>end</div><div><br></div><div>rule &quot;hardConstraintBroken&quot;</div>

<div><span style="white-space:pre-wrap">                </span>salience -1</div><div><span style="white-space:pre-wrap">        </span>when</div><div><span style="white-space:pre-wrap">                </span>$hardTotal : Number() from accumulate(</div>
<div><span style="white-space:pre-wrap">                        </span>IntConstraintOccurrence(constraintType == ConstraintType.NEGATIVE_HARD, $weight : weight)</div><div><span style="white-space:pre-wrap">                        </span>sum($weight)</div>
<div><span style="white-space:pre-wrap">                        </span>)</div><div><span style="white-space:pre-wrap">        </span>then</div><div><span style="white-space:pre-wrap">                </span>scoreHolder.setHardConstraintsBroken($hardTotal.intValue());</div>

<div>end</div></div><div>--------------------------<br></div><div><br></div><div>i guess no error there, i believe that i&#39;m missing when doing the strenght and difficulty comparators dince i didn&#39;t really understood the getMultiplicand thing of CloudComputer.</div>

<div><br></div><div>here&#39;s the implementation, also kept as simple as possible (and probably wrong):</div><div><br></div><div>------------</div><div><div>public class WorkOrderStrengthComparator implements Comparator&lt;WorkOrder&gt; {</div>

<div><br></div><div><span style="white-space:pre-wrap">        </span>public int compare(WorkOrder a, WorkOrder b) {</div><div><span style="white-space:pre-wrap">                </span>return new CompareToBuilder().append(a.getTime(), b.getTime())</div>

<div><span style="white-space:pre-wrap">                                </span>.append(b.getId(), a.getId())</div><div><span style="white-space:pre-wrap">                                </span>.toComparison();</div><div><span style="white-space:pre-wrap">        </span>}</div>
<div><br></div><div>}</div></div><div>------------</div><div><div>public class EngineerDifficultyComparator implements Comparator&lt;Engineer&gt; {</div><div><br></div><div><span style="white-space:pre-wrap">        </span>public int compare(Engineer a, Engineer b) {</div>

<div><span style="white-space:pre-wrap">                </span>return new CompareToBuilder().append(a.getWorktime(), b.getWorktime())</div><div><span style="white-space:pre-wrap">                                </span>.append(a.getId(), b.getId())</div><div>
<span style="white-space:pre-wrap">                                </span>.toComparison();</div><div><span style="white-space:pre-wrap">        </span>}</div><div><br></div><div>}</div></div><div>------------</div><div><br></div><div>
i&#39;m missing something at these comparators ain&#39;t I?</div></div>
</blockquote></div><br></div>