[rules-users] Heap space [Planner]
André Fróes
arfmoraes at gmail.com
Tue Jan 29 11:06:52 EST 2013
I changed the palnning variable to workorder since engineer woul never
(most of them) change from 8h/day, so I transformed WorkOrder into planning
entity, i no longer get heap space anymore, but 1 engineer receives every
workorder.
---------------
13:54:12.785 [main] INFO ... - ... (249), score (null), new best score
(null), random seed (0).
13:54:12.850 [main] DEBUG ... - ... spend (318), score (0hard/0soft),
initialized planning entity ([WorkOrder-7]).
13:54:12.851 [main] DEBUG ... - ... spend (320), score (0hard/0soft),
initialized planning entity ([WorkOrder-9]).
13:54:12.852 [main] DEBUG ... - ... spend (321), score (0hard/0soft),
initialized planning entity ([WorkOrder-8]).
13:54:12.853 [main] DEBUG ... - ... spend (322), score (0hard/0soft),
initialized planning entity ([WorkOrder-6]).
13:54:12.853 [main] INFO ... - ... ended: step total (4), time
spend (322), best score (0hard/0soft).
13:54:13.074 [main] DEBUG ... - ... move count (1000/1000) for picked
step ([WorkOrder-7] => [Engineer-5]).
13:54:13.395 [main] DEBUG ... - ... move count (1000/1926) for picked
step ([WorkOrder-8] => [Engineer-3]).
13:54:13.783 [main] DEBUG ... - ... move count (1000/3686) for picked
step ([WorkOrder-6] => [Engineer-2]).
13:54:14.263 [main] DEBUG ... - ... move count (1000/7516) for picked
step ([WorkOrder-9] => [Engineer-2]).
13:55:05.169 [main] DEBUG ... - ... move count (0/3094018) for picked
step ([WorkOrder-6] => [Engineer-5]).
13:55:05.169 [main] INFO ... - ... Phase localSearch ended: step
total (5), time spend (52638), best score (0hard/0soft).
13:55:05.169 [main] INFO ... - ... (52638), best score
(0hard/0soft), average calculate count per second (59047).
Solved distribution with 4 work orders and 5 engineers:
Work Order 1 : Engineer Aladin
Work Order 2 : Engineer Aladin
Work Order 3 : Engineer Aladin
Work Order 4 : Engineer Aladin
------------
as you can see, i guess, at the debug the sorting is made correctly, but
when displaying it is not being showed right, I also added this to my xml
config:
<termination>"
<maximumSecondsSpend>20</maximumSecondsSpend>
</termination>
-------------
now i'm trying to figure the result why is it not being displayed right.
2013/1/29 André Fróes <arfmoraes at gmail.com>
> I didn't find about it there. But I still have to find the fail in my
> project, i put 1 workorder and 1 engineer and i'm still getting heapspace.
> Since i'm taking base on cloudcomputer example, this is looking very odd,
> when running the 400/1200 computer/process, it did it without any problem.
> Checking here the VisualVM, i noticed also that it is kept to, relatively,
> low usage of memory, that's why i'm lost here, even if this did use the
> base memory of planner init (don't really know if this is right, is just a
> guess that planner requires a memory to init), to maintain the planner
> running in my problematics shouldn't take that amount of memory if compared
> to the example.
>
>
> 2013/1/29 Geoffrey De Smet <ge0ffrey.spam at gmail.com>
>
>> So loading your dataset costs you 1400 MB already, before doing anything
>> with Planner?
>> Starting from that, the space that Planner uses on top of that, looks
>> relatively normal.
>>
>> I had a similar case a couple of months ago on machinereassignment and
>> posted about in on G+:
>> https://plus.google.com/112811208792575157490 (maybe you find it in
>> the archive)
>> My domain model was taking far more space than needed.
>> After loading the dataset (before calling planner), do a memory heap
>> profile with VisualVM.
>>
>>
>> Op 29-01-13 13:16, André Fróes schreef:
>>
>> 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
>>>
>>>
>>
>>
>> _______________________________________________
>> 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/dd3e24bd/attachment-0001.html
-------------- 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/dd3e24bd/attachment-0002.png
-------------- 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/dd3e24bd/attachment-0003.png
More information about the rules-users
mailing list