<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Run with the VM argument -Xmx512m<br>
<br>
Use VisualVM to monitor a graph of how the memory evolves.<br>
Read this too:
<a class="moz-txt-link-freetext" href="http://blog.athico.com/2012/07/scaling-planner-with-jit-selectors-in.html">http://blog.athico.com/2012/07/scaling-planner-with-jit-selectors-in.html</a><br>
<br>
<div class="moz-cite-prefix">Op 28-01-13 20:19, André Fróes schreef:<br>
</div>
<blockquote
cite="mid:CAC8f_wWdE4B1x7XY-yqjEAY0Hk3oYi_i9hLJDQp+OeVjf5UCFQ@mail.gmail.com"
type="cite">
<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
= "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"</div>
<div><span class="" style="white-space:pre"> </span>+
"<solver>"</div>
<div><span class="" style="white-space:pre"> </span>+ "
<solutionClass>com.swa.planner.domain.Distributor</solutionClass>"</div>
<div><span class="" style="white-space:pre"> </span>+ "
<planningEntityClass>com.swa.planner.domain.Engineer</planningEntityClass>"</div>
<div><span class="" style="white-space:pre"> </span>+ "
<scoreDirectorFactory>"</div>
<div><span class="" style="white-space:pre"> </span>+ "
<scoreDefinitionType>HARD_AND_SOFT</scoreDefinitionType>"</div>
<div><span class="" style="white-space:pre"> </span>+ "
<scoreDrl>/com/swa/planner/domain/rule/distributorScoreRules.drl</scoreDrl>"</div>
<div><span class="" style="white-space:pre"> </span>+ "
</scoreDirectorFactory>"</div>
<div>//<span class="" style="white-space:pre"> </span>+ "
<termination>"</div>
<div>//<span class="" style="white-space:pre"> </span>+ "
<maximumSecondsSpend>120</maximumSecondsSpend>"</div>
<div>//<span class="" style="white-space:pre"> </span>+ "
</termination>"</div>
<div><span class="" style="white-space:pre"> </span>+ "
<constructionHeuristic>"</div>
<div><span class="" style="white-space:pre"> </span>+ "
<constructionHeuristicType>FIRST_FIT_DECREASING</constructionHeuristicType>"</div>
<div><span class="" style="white-space:pre"> </span>+ "
<constructionHeuristicPickEarlyType>FIRST_LAST_STEP_SCORE_EQUAL_OR_IMPROVING</constructionHeuristicPickEarlyType>"</div>
<div><span class="" style="white-space:pre"> </span>+ "
</constructionHeuristic>"</div>
<div><span class="" style="white-space:pre"> </span>+ "
<localSearch>"</div>
<div><span class="" style="white-space:pre"> </span>+ "
<acceptor>"</div>
<div><span class="" style="white-space:pre"> </span>+ "
<planningEntityTabuSize>7</planningEntityTabuSize>"</div>
<div><span class="" style="white-space:pre"> </span>+ "
</acceptor>"</div>
<div><span class="" style="white-space:pre"> </span>+ "
<forager>"</div>
<div><span class="" style="white-space:pre"> </span>+ "
<minimalAcceptedSelection>1000</minimalAcceptedSelection>"</div>
<div><span class="" style="white-space:pre"> </span>+ "
</forager>" + " </localSearch>" +
"</solver>";</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<Engineer>
engineerList = new ArrayList<Engineer>();</div>
<div><span class="" style="white-space:pre"> </span>engineerList.add(new
Engineer(1L, "Aladin", 8));</div>
<div><span class="" style="white-space:pre"> </span>engineerList.add(new
Engineer(2L, "Chuck Norris", 8));</div>
<div><span class="" style="white-space:pre"> </span>engineerList.add(new
Engineer(3L, "Rambo", 8));</div>
<div><span class="" style="white-space:pre"> </span>engineerList.add(new
Engineer(4L, "Mr. Miyagi", 8));</div>
<div><span class="" style="white-space:pre"> </span>engineerList.add(new
Engineer(5L, "Monkey D. Ruffy", 8));</div>
<div><span class="" style="white-space:pre"> </span></div>
<div><span class="" style="white-space:pre"> </span>List<WorkOrder>
workOrderList = new ArrayList<WorkOrder>();</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("\nSolved
distribution with %d work orders and %d engineers:\n%s",</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("
").append(engineer.getLabel()).append(" : ")</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("\n");</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"><<a
moz-do-not-send="true" href="mailto:arfmoraes@gmail.com"
target="_blank">arfmoraes@gmail.com</a>></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'm
trying to implement my own schedule distributor, but now
i'm facing heap space error, but i see that it does
distribute some work orders. Here'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] =>
[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] =>
[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] =>
[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] =>
[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] =>
[WorkOrder-9]).</div>
<div>Exception in thread "main"
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 "requiredTimeToFinish"</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 > $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("requiredTimeToFinish",
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 "hardConstraintBroken"</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'm missing
when doing the strenght and difficulty comparators dince
i didn't really understood the getMultiplicand thing of
CloudComputer.</div>
<div><br>
</div>
<div>here'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<WorkOrder> {</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<Engineer> {</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'm missing something at these comparators ain't I?</div>
</div>
</blockquote>
</div>
<br>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
rules-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a>
<a class="moz-txt-link-freetext" href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a>
</pre>
</blockquote>
<br>
</body>
</html>