[rules-users] Heap space
André Fróes
arfmoraes at gmail.com
Tue Jan 29 07:16:53 EST 2013
i've set the xmx even to 1024m and still heap space. Enabling the
VisualVM, I couldn't get my main method to be displayed there, it just
doesn't show up there at visualvm local, but I can see the graphic
increasing significantly. Here's how it is before and after i run the main
method:
Before start:
[image: Imagem inline 1]
After it ends:
[image: Imagem inline 2]
I'm missing something when constructing my logic or comparator, even when
reducing the number of workorders it still happening:
WorkOrder now (graphic):
List<WorkOrder> workOrderList = new ArrayList<WorkOrder>();
workOrderList.add(new WorkOrder(6L, 1, 2));
workOrderList.add(new WorkOrder(7L, 2, 6));
workOrderList.add(new WorkOrder(8L, 3, 3));
workOrderList.add(new WorkOrder(9L, 4, 3));
workOrderList.add(new WorkOrder(10L, 5, 2));
total: 16 hours (last attribute)
Engineers now (graphic)
List<Engineer> engineerList = new ArrayList<Engineer>();
engineerList.add(new Engineer(1L, "Aladin", 8));
engineerList.add(new Engineer(2L, "Chuck Norris", 8));
engineerList.add(new Engineer(3L, "Rambo", 8));
engineerList.add(new Engineer(4L, "Mr. Miyagi", 8));
engineerList.add(new Engineer(5L, "Monkey D. Ruffy", 8));
total: 40 hour (here will be done the schedule of the 16 hours above)
2013/1/29 Geoffrey De Smet <ge0ffrey.spam at gmail.com>
> Run with the VM argument -Xmx512m
>
> Use VisualVM to monitor a graph of how the memory evolves.
> Read this too:
> http://blog.athico.com/2012/07/scaling-planner-with-jit-selectors-in.html
>
> Op 28-01-13 20:19, André Fróes schreef:
>
> i forgot adding the main class:
> -----------------
>
> public static void main(String[] args) {
> String t = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
> + "<solver>"
> + " <solutionClass>com.swa.planner.domain.Distributor</solutionClass>"
> + "
> <planningEntityClass>com.swa.planner.domain.Engineer</planningEntityClass>"
> + " <scoreDirectorFactory>"
> + " <scoreDefinitionType>HARD_AND_SOFT</scoreDefinitionType>"
> + "
> <scoreDrl>/com/swa/planner/domain/rule/distributorScoreRules.drl</scoreDrl>"
> + " </scoreDirectorFactory>"
> // + " <termination>"
> // + " <maximumSecondsSpend>120</maximumSecondsSpend>"
> // + " </termination>"
> + " <constructionHeuristic>"
> + "
> <constructionHeuristicType>FIRST_FIT_DECREASING</constructionHeuristicType>"
> + "
> <constructionHeuristicPickEarlyType>FIRST_LAST_STEP_SCORE_EQUAL_OR_IMPROVING</constructionHeuristicPickEarlyType>"
> + " </constructionHeuristic>"
> + " <localSearch>"
> + " <acceptor>"
> + " <planningEntityTabuSize>7</planningEntityTabuSize>"
> + " </acceptor>"
> + " <forager>"
> + " <minimalAcceptedSelection>1000</minimalAcceptedSelection>"
> + " </forager>" + " </localSearch>" + "</solver>";
>
> byte b[] = t.getBytes();
> ByteArrayInputStream bt = new ByteArrayInputStream(b);
> SolverFactory solverFactory = new XmlSolverFactory().configure(bt);
> Solver solver = solverFactory.buildSolver();
> List<Engineer> engineerList = new ArrayList<Engineer>();
> engineerList.add(new Engineer(1L, "Aladin", 8));
> engineerList.add(new Engineer(2L, "Chuck Norris", 8));
> engineerList.add(new Engineer(3L, "Rambo", 8));
> engineerList.add(new Engineer(4L, "Mr. Miyagi", 8));
> engineerList.add(new Engineer(5L, "Monkey D. Ruffy", 8));
> List<WorkOrder> workOrderList = new ArrayList<WorkOrder>();
> workOrderList.add(new WorkOrder(6L, 1, 2));
> workOrderList.add(new WorkOrder(7L, 1, 6));
> workOrderList.add(new WorkOrder(8L, 1, 3));
> workOrderList.add(new WorkOrder(9L, 1, 3));
> workOrderList.add(new WorkOrder(10L, 1, 2));
> workOrderList.add(new WorkOrder(11L, 1, 8));
> workOrderList.add(new WorkOrder(12L, 1, 8));
> workOrderList.add(new WorkOrder(13L, 1, 2));
> workOrderList.add(new WorkOrder(14L, 1, 2));
> workOrderList.add(new WorkOrder(15L, 1, 4));
>
> Distributor distributor = new Distributor();
> distributor.setId(0L);
> distributor.setEngineerList(engineerList);
> distributor.setWorkOrderList(workOrderList);
>
> solver.setPlanningProblem(distributor);
> solver.solve();
> Distributor solvedWorkOrderDistribution = (Distributor)
> solver.getBestSolution();
>
> System.out.printf("\nSolved distribution with %d work orders and %d
> engineers:\n%s",
> workOrderList.size(), engineerList.size(),
> toDisplayString(solvedWorkOrderDistribution));
> }
>
> public static String toDisplayString(Distributor distributor) {
> StringBuilder displayString = new StringBuilder();
> for (Engineer engineer : distributor.getEngineerList()) {
> WorkOrder order = engineer.getWorkOrder();
> displayString.append(" ").append(engineer.getLabel()).append(" : ")
> .append(order == null ? null : order.getLabel())
> .append("\n");
> }
> return displayString.toString();
> }
>
>
>
> 2013/1/28 André Fróes <arfmoraes at gmail.com>
>
>> 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:
>>
>> -------------------
>> 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).
>> 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]).
>> 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]).
>> 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]).
>> 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]).
>> 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]).
>> 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).
>> 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]).
>> 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]).
>> 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]).
>> 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]).
>> 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]).
>> Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
>> at java.util.Arrays.copyOf(Unknown Source)
>> at java.util.Arrays.copyOf(Unknown Source)
>> at java.util.ArrayList.grow(Unknown Source)
>> at java.util.ArrayList.ensureCapacityInternal(Unknown Source)
>> at java.util.ArrayList.add(Unknown Source)
>> at
>> org.drools.planner.core.localsearch.decider.forager.AcceptedForager.addToMaxScoreUnacceptedList(AcceptedForager.java:143)
>> at
>> org.drools.planner.core.localsearch.decider.forager.AcceptedForager.addMove(AcceptedForager.java:101)
>> at
>> org.drools.planner.core.localsearch.decider.DefaultDecider.processMove(DefaultDecider.java:164)
>> at
>> org.drools.planner.core.localsearch.decider.DefaultDecider.doMove(DefaultDecider.java:144)
>> at
>> org.drools.planner.core.localsearch.decider.DefaultDecider.decideNextStep(DefaultDecider.java:116)
>> at
>> org.drools.planner.core.localsearch.DefaultLocalSearchSolverPhase.solve(DefaultLocalSearchSolverPhase.java:62)
>> at
>> org.drools.planner.core.solver.DefaultSolver.runSolverPhases(DefaultSolver.java:190)
>> at
>> org.drools.planner.core.solver.DefaultSolver.solve(DefaultSolver.java:155)
>> at com.swa.planner.domain.WorkOrderTest.main(WorkOrderTest.java:66)
>> ------------------------
>>
>> it does distribute some engineers to work orders, but after a while, it
>> just show the error.
>>
>> The drl is very simple:
>>
>> --------------------------
>> import
>> org.drools.planner.core.score.buildin.hardandsoft.HardAndSoftScoreHolder;
>> import org.drools.planner.core.score.constraint.IntConstraintOccurrence;
>> import org.drools.planner.core.score.constraint.ConstraintType;
>>
>> import com.swa.planner.domain.Distributor;
>> import com.swa.planner.domain.Engineer;
>> import com.swa.planner.domain.WorkOrder;
>>
>> global HardAndSoftScoreHolder scoreHolder;
>>
>> rule "requiredTimeToFinish"
>> when
>> $workOrder : WorkOrder($time : time)
>> $requiredTimeTotal : Number(intValue > $time) from accumulate(
>> Engineer (
>> workOrder == $workOrder,
>> $requiredTime : worktime),
>> sum($requiredTime)
>> )
>> then
>> insertLogical(new IntConstraintOccurrence("requiredTimeToFinish",
>> ConstraintType.NEGATIVE_HARD,
>> $requiredTimeTotal.intValue() - $time,
>> $workOrder));
>> end
>>
>> rule "hardConstraintBroken"
>> salience -1
>> when
>> $hardTotal : Number() from accumulate(
>> IntConstraintOccurrence(constraintType == ConstraintType.NEGATIVE_HARD,
>> $weight : weight)
>> sum($weight)
>> )
>> then
>> scoreHolder.setHardConstraintsBroken($hardTotal.intValue());
>> end
>> --------------------------
>>
>> 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.
>>
>> here's the implementation, also kept as simple as possible (and
>> probably wrong):
>>
>> ------------
>> public class WorkOrderStrengthComparator implements
>> Comparator<WorkOrder> {
>>
>> public int compare(WorkOrder a, WorkOrder b) {
>> return new CompareToBuilder().append(a.getTime(), b.getTime())
>> .append(b.getId(), a.getId())
>> .toComparison();
>> }
>>
>> }
>> ------------
>> public class EngineerDifficultyComparator implements
>> Comparator<Engineer> {
>>
>> public int compare(Engineer a, Engineer b) {
>> return new CompareToBuilder().append(a.getWorktime(), b.getWorktime())
>> .append(a.getId(), b.getId())
>> .toComparison();
>> }
>>
>> }
>> ------------
>>
>> i'm missing something at these comparators ain't I?
>>
>
>
>
> _______________________________________________
> rules-users mailing listrules-users at lists.jboss.orghttps://lists.jboss.org/mailman/listinfo/rules-users
>
>
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20130129/30dd30a0/attachment-0001.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/png
Size: 24407 bytes
Desc: not available
Url : http://lists.jboss.org/pipermail/rules-users/attachments/20130129/30dd30a0/attachment-0002.png
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/png
Size: 25878 bytes
Desc: not available
Url : http://lists.jboss.org/pipermail/rules-users/attachments/20130129/30dd30a0/attachment-0003.png
More information about the rules-users
mailing list