[rules-users] OptaPlanner: score corruption when using insertLogical with custom objects
Geoffrey De Smet
ge0ffrey.spam at gmail.com
Wed Jul 17 08:25:22 EDT 2013
On 17-07-13 13:02, pvandenbrink wrote:
> ge0ffrey wrote
>> The 7 one probably got inserted with it didn't reach to 5 yet. That was
>> a good logicalInsertion.
>> The issue is, why didn't it get retracted when a move made changes so it
>> did reach to 5?
> I've added a printline in the rules xml file before the insertLogical. At
> one point shortly before the corruption occurs the following two lines
> appear immediately one after another:
>
> inserting FamilyStart for Family 11 at tijdslot Timeslot 5
> inserting FamilyStart for Family 11 at tijdslot Timeslot 7
>
> This seems strange, it's as if they're inserted almost at the same time.
Did you enable logging in OptaPlanner? See docs on logging. Use trace
logging and it will output a line for every move it tries. That will
prove or disprove that those 2 println's are happening as a result of
the same move. (I presume they won't).
>
>
> ge0ffrey wrote
>> This one looks good, but I am mostly interested in those of the
>> logically inserted objects (FamilyStart, etc).
> FamilyStart implements it as follows:
>
> @Override
> public boolean equals(Object other)
> {
> if ((this == other))
> return true;
> if (!(other instanceof FamilyStart))
> return false;
> FamilyStart castOther = (FamilyStart) other;
> return new EqualsBuilder().append(this.getFamily(), castOther.getFamily())
> .append(this.getTimeslot(), castOther.getTimeslot()).isEquals();
> }
>
> @Override
> public int hashCode()
> {
> return new
> HashCodeBuilder().append(getFamily()).append(getTimeslot()).toHashCode();
> }
>
> Similarly, FamilyEnd:
>
> @Override
> public boolean equals(Object other)
> {
> if ((this == other))
> return true;
> if (!(other instanceof FamilyEnd))
> return false;
> FamilyEnd castOther = (FamilyEnd) other;
> return new EqualsBuilder().append(this.getFamily(), castOther.getFamily())
> .append(this.getTimeslot(), castOther.getTimeslot()).isEquals();
> }
>
> @Override
> public int hashCode()
> {
> return new
> HashCodeBuilder().append(getFamily()).append(getTimeslot()).toHashCode();
> }
Looks good.
This means there might be a bug in drools expert after all.
Can you make a reproducer and file a jira? For our convenience, try to
isolate as much as possible:
- remove all other rules
- try to reduce the dataset as much as possible (as long as it reproduces)
- using TRACE logging, try to bring down the number for steps to 1 (by
saving the dataset just before the step which goes wrong and then load
that one).
- Don't worry about reducing the number of moves to as little as
possible for that 1 step - I can hack that in DefaultDecider.
>
>
>
>
>
>
> --
> View this message in context: http://drools.46999.n3.nabble.com/OptaPlanner-score-corruption-when-using-insertLogical-with-custom-objects-tp4024932p4024969.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
More information about the rules-users
mailing list