Upgrade to 6.0.0.CR5 (follow the upgrade recipe txt)
and take advantage of the new feature called "shadow variables" (see
docs).
Also see the VRP with timewindows example for an implementation that
uses shadow variables :)
On 25-10-13 00:27, Juan Ignacio
Barisich wrote:
Hi again. The problem was a score corruption
issue. When I activate de mode debug:
<environmentMode>DEBUG</environmentMode>
some exceptions appear, like:
java.lang.IllegalStateException: Score corruption:
the workingScore (0hard/-35soft) is not the
uncorruptedScore (0hard/-31soft)...
I had to fix some rules, but I cant fix one in
particular. When I looking at the example rules (with
chained variables), the most are based only on the
previous item of the chain, e.g.:
rule "distanceToPreviousAppearance"
when
$visit : Visit(previousAppearance != null,
$distanceToPreviousAppearance :
distanceToPreviousAppearance)
then
insertLogical(new
IntConstraintOccurrence("distanceToPreviousAppearance",
ConstraintType.NEGATIVE_SOFT,
$distanceToPreviousAppearance,
$visit));
end
When optaplanner do the moves while planning, the
IntConstraintOccurrence works ok, because the drools
engine "retracts" the IntConstraintOccurrence facts
properly. But, in my case the score caculation must be
based on the entire chain. That is:
I have some Doctors, and Cases (medical cases). I have to
write a score rule for consider the delay of attention.
So, each Case has a request time (when the patient calls)
and a approximate duration of the case (in
minutes). So, if I have the next chain:
Doctor1
-> Case1 (requestTime:8am, duration:60minutes) ->
Case2(requestTime:8:30am,
duration:30minutes) -> Case3(requestTime:8:30am,
duration:30minutes)
the
delay time for this solution must be: 30min(for Case2) +
60min(for Case3) = 90 minutes. As yo see, you can't
calculate the delay of one Case only as from
its previous on the chain.
I must to implement a rule to calculate a soft constraint,
to achive less-delay plannings. My first attempt looks
like:
rule "delaySC"
when
$case : Case( )
eval($case.getDelay() > 0)
then
insertLogical(new
IntConstraintOccurrence("delaySC",
ConstraintType.NEGATIVE_SOFT,
$case.getDelay(), $case));
end
I
have to do an eval(), because a delay can not be negative.
The getDelay() method process the chain and calculates it.
The problem of this attempt, an other similars, is when
the optaplanner engine do the moves while solving, the IntConstraintOccurrence
is not retracted and the score corruption
exception appears.
The question is: ¿have you know similar scenarios, in which
you have to process the entire chain to calculate the score of
a solution? ¿is there a way to solve this?
Thanks
Regards
_______________________________________________
rules-users mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/rules-users
|