<div dir="ltr"><div><div><div><div><div><div><div></div></div><span name="Geoffrey De Smet">Geoffrey, thanks for response.<br></span></div><span name="Geoffrey De Smet">The </span>the Customer
"toRemove" instance IS the same instance as which is in the workingSolution's
Customer list. In fact, in the test example I have attached, I get that instance via:<br><br>final Customer toRemove = workingSolution.getCustomerList().get(0);<br><br></div>I try to reproduce the hack in CloudBalancing's problemFactChange implementation, but with no success. I mean, I tried:<br>
<br></div><div> // to clean the next variable of previous in the chain<br></div><div> Standstill prev = toRemove.getPreviousStandstill();<br> scoreDirector.beforeEntityRemoved(prev);<br> prev.setNextCustomer(null);<br>
scoreDirector.afterEntityRemoved(prev);<br> <br></div>but this throw an exception like:<br>java.lang.IllegalStateException: The entity (1(after 66)) has a variable (previousStandstill) with value (66(after 51)) which has a mappedBy variable (nextCustomer) with a value (null) which is not that entity.<br>
<br></div>Also, i try to clean the previous variable of the following item in the chain:<br><br> // to clean the previous variable of the following customer in the chain<br> Customer nextCustomer = toRemove.getNextCustomer();<br>
if (nextCustomer != null) {<br> scoreDirector.beforeEntityRemoved(nextCustomer);<br> nextCustomer.setPreviousStandstill(null);<br> scoreDirector.beforeEntityRemoved(nextCustomer);<br> }<br><br>but this throw an exception like:<br>
java.lang.IllegalStateException: The ScoreDirector (class org.optaplanner.core.impl.score.director.common.TrailingEntityMapSupport) is corrupted, because the entity (10(after null)) for chained planningVariable (previousStandstill) cannot be retracted: it was never inserted.<br>
<br></div><div>Can you take a look to the test I have attached and <span id="result_box" class="" lang="en"><span class="">guide me to solve this?<br><br>Thanks a lot.<br></span></span></div><div><span id="result_box" class="" lang="en"><span class="">Regards<br>
</span></span></div><div><div><br> <br><br><div><br><div><br></div></div></div>
</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/11/4 Geoffrey De Smet <span dir="ltr"><<a 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"><div class="im">
<br>
<div>On 01-11-13 19:38, Juan Ignacio
Barisich wrote:<br>
</div>
<blockquote type="cite">
<div dir="ltr">
<div>
<div>
<div>
<div>
<div>
<div>
<div>Hi everybody<br>
</div>
I am using optaplanner in real-time style. My
application domain is similar to the "Vehicle
Routing" example (<a href="http://docs.jboss.org/drools/release/6.0.0.CR5/optaplanner-docs/html_single/index.html#vehicleRouting" target="_blank">http://docs.jboss.org/drools/release/6.0.0.CR5/optaplanner-docs/html_single/index.html#vehicleRouting</a>).
I mean, I am using chained variables and shadow
variables. I have a problem while trying to remove a
fact (an entity), via a ProblemFactChange:<br>
<br>
java.lang.IllegalArgumentException: The entity
instance (...) was never added to this
ScoreDirector. Usually the cause is that that
specific instance was not in your Solution's
entities.<br>
<br>
</div>
The fact removing that I made is like:<br>
<br>
solver.addProblemFactChange(new ProblemFactChange() {<br>
<br>
@Override<br>
public void doChange(ScoreDirector
scoreDirector) {<br>
...<br>
scoreDirector.beforeEntityRemoved(toRemove);<br>
workingSolution.getCustomerList().remove(toRemove);<br>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote></div>
the remove() method will make no difference because the Customer
"toRemove" instance<br>
is not the same instance as which is in the workingSolution's
Customer list.<br>
<br>
See the CloudBalancing's PRoblemFactChange implementation how to
solve this.<br>
And one of the warnings in the Real-time planning section of the
docs to understand it better:)<br>
<blockquote type="cite"><div class="im">
<div dir="ltr">
<div>
<div>
<div>
<div>
<div>
scoreDirector.afterEntityRemoved(toRemove);<br>
}<br>
});<br>
<br>
</div>
I think the problem is there. Do you know what I'm doing
wrong?<br>
</div>
I have attached a test case based on the "Vehicle
Routing". To run it, just put that file into the
optaplanner-distribution-6.0.0.CR5/examples/sources/src/test/java/org/optaplanner/examples/vehiclerouting/app/
directory.<br>
<br>
</div>
<a href="http://drools.46999.n3.nabble.com/file/n4017760/serverlog.zip" rel="nofollow" target="_blank"><span></span></a><span>I'd
appreciate any ideas on how to resolve this.</span></div>
Best regards,<br>
<br>
</div>
Juan Ignacio Barisich<br>
<div>
<div>
<div>
<div><br>
<br>
<br>
<br>
</div>
</div>
</div>
</div>
</div>
<br>
<fieldset></fieldset>
<br>
</div><pre>_______________________________________________
rules-users mailing list
<a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a>
<a 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 href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a 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>