Op 03-09-12 10:21, Michiel Vermandel schreef:
> Hi Geoffrey,
>
> Thanks for the support so far.
> I understand that you do not provide full support on
this level.
> Though I have the feeling that this is really
> - a very basic solution setup
> - a beginners-mistake and since I'm looking into it now
for about 3 days
> (since I started with planner) it seems to be not
obvious to find for a
> beginner.
> So I was trying my luck in offering the code.
> It could be an opportunity to enrich the documentation
;-) ;-)
Good point, the score corruption problem is often a beginner
problem and
it's a PITA. I 'll write some more docs about.
Do note that your 3 day implementation should be able to
scale out to
10000 planes pretty easily, so hang in there :)
I fear you might have started copying from the wrong example
nqueens (if
you did that) :/ Nurse rostering is a far more similar to
this kind of
problem. I am not sure which example to promote in the docs:
the nqueens
is simple enough to explain things on, but it's too simple
to copy from
for real world stuff :/ Feedback welcome.
>
>
> Ok,
>
> 1) adding the $t2 results in the same sort of
exception, only
> planningEntity seems different:
>
> with insertLogical(new
>
UnweightedConstraintOccurrence("tasksInSameJobMustBeInSamePeriod",
$t1,
> $t2));
>
> Exception in thread "main"
java.lang.IllegalStateException: Score
> corruption: the workingScore (-2) is not the
uncorruptedScore (0):
> The workingMemory has 2 ConstraintOccurrence(s) in
excess:
>
tasksInSameJobMustBeInSamePeriod/NEGATIVE_HARD:[Maintenance
of
> Boeing 737 - PJ23.I#1 73111693, Maintenance of Boeing
737 - PJ23.I#2
> 427578167]
>
tasksInSameJobMustBeInSamePeriod/NEGATIVE_HARD:[Maintenance
of
> Boeing 737 - PJ23.I#2 427578167, Maintenance of Boeing
737 - PJ23.I#1
> 73111693]
> Check the score rules who created those
ConstraintOccurrences. Verify
> that each ConstraintOccurrence's causes and weight is
correct.
> at
>
org.drools.planner.core.score.director.AbstractScoreDirector.assertWorkingScore(AbstractScoreDirector.java:101)
> at
>
org.drools.planner.core.constructionheuristic.greedyFit.decider.DefaultGreedyDecider.doMove(DefaultGreedyDecider.java:110)
> at
>
org.drools.planner.core.constructionheuristic.greedyFit.decider.DefaultGreedyDecider.decideNextStep(DefaultGreedyDecider.java:78)
> at
>
org.drools.planner.core.constructionheuristic.greedyFit.DefaultGreedyFitSolverPhase.solve(DefaultGreedyFitSolverPhase.java:63)
> at
>
org.drools.planner.core.solver.DefaultSolver.runSolverPhases(DefaultSolver.java:183)
> at
>
org.drools.planner.core.solver.DefaultSolver.solve(DefaultSolver.java:151)
> at
>
be.axi.planner.domain.MaintenancePlanning.main(MaintenancePlanning.java:27)
>
> with insertLogical(new
>
UnweightedConstraintOccurrence("tasksInSameJobMustBeInSamePeriod",
$t1));
>
> Exception in thread "main"
java.lang.IllegalStateException: Score
> corruption: the workingScore (-2) is not the
uncorruptedScore (0):
> The workingMemory has 2 ConstraintOccurrence(s) in
excess:
>
tasksInSameJobMustBeInSamePeriod/NEGATIVE_HARD:[Maintenance
of
> Airbus A350 - XJ34.I#2 778813475]
>
tasksInSameJobMustBeInSamePeriod/NEGATIVE_HARD:[Maintenance
of
> Airbus A350 - XJ34.I#0 225744121]
> Check the score rules who created those
ConstraintOccurrences. Verify
> that each ConstraintOccurrence's causes and weight is
correct.
> at
>
org.drools.planner.core.score.director.AbstractScoreDirector.assertWorkingScore(AbstractScoreDirector.java:101)
> at
>
org.drools.planner.core.constructionheuristic.greedyFit.decider.DefaultGreedyDecider.doMove(DefaultGreedyDecider.java:110)
> at
>
org.drools.planner.core.constructionheuristic.greedyFit.decider.DefaultGreedyDecider.decideNextStep(DefaultGreedyDecider.java:78)
> at
>
org.drools.planner.core.constructionheuristic.greedyFit.DefaultGreedyFitSolverPhase.solve(DefaultGreedyFitSolverPhase.java:63)
> at
>
org.drools.planner.core.solver.DefaultSolver.runSolverPhases(DefaultSolver.java:183)
> at
>
org.drools.planner.core.solver.DefaultSolver.solve(DefaultSolver.java:151)
> at
>
be.axi.planner.domain.MaintenancePlanning.main(MaintenancePlanning.java:27)
>
>
> 2) You suggested to replace
UnweightedConstraintOccurrence with
> IntConstraintOccurrence. I will.
> UnweightedConstraintOccurrence is used in the very
basic Queens example
> though...
Yep, my mistake.
>
> 3) Where is the best place to read about what
insertLogical and
> IntConstraintOccurrence really do?
> What is the purpose of the Cause -objects, which should
be passed?
> => where is the best place to find explanation about
this?
> (
http://docs.jboss.org/drools/release/5.4.0.Final/drools-planner-docs/html_single/
> doesn't really enlighten me on that part)
Look for "insertLogical" in the Drools Expert guide:
http://docs.jboss.org/drools/release/5.4.0.Final/drools-expert-docs/html_single/index.html
When rules do an insertLogical of an object A, it's
discarded if another
object B in the WorkingMemory equals object A (through
equals() and
through hashcode()). Because the ConstraintOccurrences need
to be unique
so they aren't discarded, they ruleId, constraintType and
causes are
used for equals()/hashcode().
Future work: "compensation action"
Recently, drools introduced something called "compensation
action",
which can probably replace the use
insertLogical(ConstraintOccurrence)
and make the causes parameter obsolete.
It's also faster.
My first experiments look very promising, but I haven't got
time yet to
experiment with it on all examples and make it easy for
users to use.
It would allow us to do something like this in the then part
of a rule:
hardAndSoftScoreHelper.addHardScore(-5);
or
hardAndSoftScoreHelper.addSoftScore(- $sum);
or
simpleScoreHelper.addScore(-7);
No need for causes, insertLogicals, no equals/hashcode()
worries, much
more flexible, ...
4) Does your MaintenanceTask implement equals()/hashcode()
other than
Object's original implementation?
>
> Thanks in advance.
>
yw
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users