<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<br>
<div class="moz-cite-prefix">On 28-10-13 17:27, Juan Ignacio
Barisich wrote:<br>
</div>
<blockquote
cite="mid:CAFGE-fW6KixOcN3hJKM-tCvzi6eKqtw9CrtDqe6pQX2xcZ3TwA@mail.gmail.com"
type="cite">
<div dir="ltr">
<div>Thanks <span name="Geoffrey De Smet" class="">Geoffrey.
One more question:</span><span name="Geoffrey De Smet"
class=""> Is there a planned release date for optaplanner </span>6.0.0.Final
?<br>
</div>
</div>
</blockquote>
When the rest of drools and jbpm and ready to release. We're on the
same release train :)<br>
But optaplanner 6 is ready for prime time, don't let the "CR5"
suffix make you believe otherwise.<br>
<blockquote
cite="mid:CAFGE-fW6KixOcN3hJKM-tCvzi6eKqtw9CrtDqe6pQX2xcZ3TwA@mail.gmail.com"
type="cite">
<div dir="ltr">
<div><br>
</div>
<div>Thanks again<br>
</div>
<br>
</div>
<div class="gmail_extra"><br>
<br>
<div class="gmail_quote">2013/10/25 Geoffrey De Smet <span
dir="ltr"><<a moz-do-not-send="true"
href="mailto:ge0ffrey.spam@gmail.com" target="_blank">ge0ffrey.spam@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000"> Upgrade to 6.0.0.CR5
(follow the upgrade recipe txt)<br>
and take advantage of the new feature called "shadow
variables" (see docs).<br>
Also see the VRP with timewindows example for an
implementation that uses shadow variables :)
<div>
<div class="h5"><br>
<br>
<div>On 25-10-13 00:27, Juan Ignacio Barisich wrote:<br>
</div>
</div>
</div>
<blockquote type="cite">
<div>
<div class="h5">
<div dir="ltr">
<div>
<div>
<div>
<div>
<div>
<div>
<div>Hi again. The problem was a score
corruption issue. When I activate de
mode debug:<br>
<br>
<environmentMode>DEBUG</environmentMode><br>
<br>
</div>
some exceptions appear, like:<br>
<br>
java.lang.IllegalStateException: Score
corruption: the workingScore
(0hard/-35soft) is not the
uncorruptedScore (0hard/-31soft)...<br>
<br>
</div>
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.: <br>
<br>
rule "distanceToPreviousAppearance"<br>
when<br>
$visit :
Visit(previousAppearance != null,
$distanceToPreviousAppearance :
distanceToPreviousAppearance)<br>
then<br>
insertLogical(new
IntConstraintOccurrence("distanceToPreviousAppearance",
ConstraintType.NEGATIVE_SOFT,<br>
$distanceToPreviousAppearance,<br>
$visit));<br>
end<br>
<br>
</div>
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:<br>
<br>
</div>
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 <span lang="en"><span>approximate
duration of the case (in minutes). So,
if I have the next chain:<br>
<br>
</span></span></div>
<span lang="en"><span>Doctor1 -> Case1
(requestTime:8am, duration:60minutes)
-> Case2(</span></span><span lang="en"><span><span
lang="en"><span>requestTime:8:30am,
duration:30minutes</span></span>)
-> Case3(</span></span><span lang="en"><span><span
lang="en"><span>requestTime:8:30am,
duration:30minutes</span></span>)<br>
<br>
</span></span></div>
<span lang="en"><span>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 </span></span><span lang="en"><span>as
from its previous on the chain.<br>
<br>
I must to implement a rule to calculate a
soft constraint, to achive less-delay
plannings. My first attempt looks like:<br>
<br>
rule "delaySC"<br>
when <br>
$case : Case( )<br>
eval($case.getDelay() > 0)<br>
then<br>
insertLogical(new
IntConstraintOccurrence("delaySC",
ConstraintType.NEGATIVE_SOFT, <br>
$case.getDelay(), $case));<br>
end<br>
<br>
</span></span></div>
<div><span lang="en"><span>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 </span></span><span
lang="en"><span>IntConstraintOccurrence is not
retracted and the </span></span>score
corruption exception appears.<br>
<br>
The question is: ¿have you know similar
scenarios, in which you have to process the
entire chain to calculate the score of a
solution?<span lang="en"><span> ¿is there a way
to solve this?<br>
<br>
</span></span></div>
<div><span lang="en"><span>Thanks<br>
<br>
</span></span></div>
<div><span lang="en"><span>Regards<br>
</span></span></div>
<div><span lang="en"><span><br>
<br>
</span></span></div>
<span lang="en"><span></span></span>
<div>
<div>
<div>
<div><span lang="en"><span></span></span>
<div><br>
<div>
<div>
<div><br>
<br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="gmail_extra"><br>
<br>
<div class="gmail_quote">2013/9/2 Juan Ignacio
Barisich <span dir="ltr"><<a
moz-do-not-send="true"
href="mailto:juan.barisich@gmail.com"
target="_blank">juan.barisich@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">
<div>
<div>
<div>Hi everybody.<br>
</div>
I have a problem with chained planning
variables.<br>
</div>
I'm using optaplanner 5.5.0.Final.<br>
</div>
I have a planning entity like:<br>
<br>
@PlanningEntity()<br>
public class Case implements Chained {<br>
private Chained previous;<br>
@PlanningVariable(chained = true)<br>
@ValueRanges({<br>
@ValueRange(type =
ValueRangeType.FROM_SOLUTION_PROPERTY,
solutionProperty = "doctors"),<br>
@ValueRange(type =
ValueRangeType.FROM_SOLUTION_PROPERTY,
solutionProperty = "cases",
excludeUninitializedPlanningEntity = true)
})<br>
public Chained getPrevious() {<br>
return previous;<br>
}<br>
}<br clear="all">
<div><br>
</div>
<div>A fact class:<br>
public class Doctor implements Chained {<br>
...<br>
}<br>
</div>
<div><br>
</div>
<div> An a solution class:<br>
public class Plan extends implements
Solution<HardAndSoftScore> {<br>
private List<Doctor> doctors;<br>
private List<Case> cases;<br>
private HardAndSoftScore score;<br>
<br>
@PlanningEntityCollectionProperty<br>
public List<Case> getCases() {<br>
return cases;<br>
}<br>
<br>
public Collection<? extends
Object> getProblemFacts() {<br>
return new
ArrayList<Doctor>(doctors);<br>
}<br>
}<br>
<br>
</div>
<div>The equals / hashCode / clone methods
are inspired on the TravelingSalesmanTour
example.<br>
</div>
<div><br>
</div>
<div>I want that Optaplanner generates
chains like:<br>
</div>
<div>DoctorA <- Case1 <- Case2<br>
</div>
<div>DoctorB <- Case3<br>
<br>
</div>
<div>This model tries to represent a list of
Cases assigned to each Doctor.<br>
</div>
<div>Suppose I build a solution like:<br>
<br>
Plan plan = new Plan();<br>
</div>
<div>plan.setDoctors(DoctorA, DoctorB);
//pseudo-code<br>
</div>
<div>plan.setCases(Case1, Case2);
//pseudo-code<br>
<br>
</div>
<div>Then I build a solver:<br>
Solver solver =
getSolverFactory().buildSolver();<br>
solver.setPlanningProblem(plan);<br>
solver.solve();<br>
Plan bestPlan = (Plan)
solver.getBestSolution();<br>
<br>
</div>
<div>The problem is that, Optaplanner is not
testing all the posible combinations of
chains. I mean, suppose that we know that
the better solution (based on the scoring
rules) is:<br>
</div>
<div>DoctorA <br>
</div>
<div>DoctorB <- Case1 <- Case2<br>
</div>
<div><br>
</div>
<div>But Optaplanner seems to test only
chains with DoctorA, so the result of
calling getBestSolution() is:<br>
DoctorA <- Case1 <- Case2<br>
</div>
<div><br>
I guess that Optaplanner only test chains
whit DoctorA, becouse it logs lines like:<br>
...<br>
DEBUG:
org.drools.planner.core.localsearch.DefaultLocalSearchSolverPhase
- Step index (1), time spend (20002),
score (1hard/2soft), best score
(1hard/2soft), accepted/selected move
count (0/58187) for picked step (Case
[id=2, previous=Doctor [id=1]] => Case
[id=1, previous=Case [id=2,
previous=Doctor [id=1]]]).<br>
...<br>
</div>
<div>That is, no lines whith "DoctorB" are
logged. <br>
If the doctor list is inverted, the same
problem happen (the DoctorA is no
processed). That is:<br>
<br>
Plan plan = new Plan();<br>
<div>plan.setDoctors(DoctorB, DoctorA);
//pseudo-code<br>
</div>
<div>plan.setCases(Case1, Case2);
//pseudo-code<br>
Solver solver =
getSolverFactory().buildSolver();<br>
solver.setPlanningProblem(plan);<br>
solver.solve(); // DoctorA is not part
of chains<br>
</div>
<br>
<br>
</div>
<div>I guess the problem is on the solver
configuration, specifically on the
localSearch configuration:<br>
<br>
<localSearch><br>
<unionMoveSelector><br>
<changeMoveSelector><br>
<valueSelector/><br>
</changeMoveSelector><br>
<swapMoveSelector /><br>
<subChainChangeMoveSelector><br>
<selectReversingMoveToo>true</selectReversingMoveToo><br>
</subChainChangeMoveSelector><br>
<subChainSwapMoveSelector><br>
<selectReversingMoveToo>true</selectReversingMoveToo><br>
</subChainSwapMoveSelector><br>
</unionMoveSelector><br>
<acceptor><br>
<planningEntityTabuSize>9</planningEntityTabuSize><br>
</acceptor><br>
<forager><br>
<minimalAcceptedSelection>2000</minimalAcceptedSelection><br>
</forager><br>
</localSearch><br>
<br>
</div>
<div>I tried some alternatives to this
configuration, but with no success.<br>
<br>
</div>
<div>Do you know what I am doing wrong?<br>
<br>
</div>
<div>Thanks a lot.<br>
<br>
</div>
Regards</div>
</blockquote>
</div>
<br>
</div>
<br>
<fieldset></fieldset>
<br>
</div>
</div>
<pre>_______________________________________________
rules-users mailing list
<a moz-do-not-send="true" href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a>
<a moz-do-not-send="true" href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a></pre>
</blockquote>
<br>
</div>
<br>
_______________________________________________<br>
rules-users mailing list<br>
<a moz-do-not-send="true"
href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a moz-do-not-send="true"
href="https://lists.jboss.org/mailman/listinfo/rules-users"
target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</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>