[rules-users] OptaPlanner: score corruption when using insertLogical with custom objects

pvandenbrink pieter.van.den.brink at topicus.nl
Wed Jul 24 11:05:52 EDT 2013


ge0ffrey wrote
> Turns out this is a user problem in the equals and hashcode of 
> FamilyStart, not a bug in Drools or OptaPlanner :)
> 
>      @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.getTimeslot(), castOther.getTimeslot()) // <== must be Family
> .append(this.getTimeslot(), castOther.getTimeslot())
> .isEquals();
>      }
> 
>      @Override
>      public int hashCode()
>      {
>          return new HashCodeBuilder()
> .append(getTimeslot()) // <== must be Family
> .append(getTimeslot())
> .toHashCode();
>      }

Thanks for looking into it, and you're right. Looks like I made an error in
the reproducer project, sorry... The original code didn't have this
equals/hashcode problem. After fixing this in the reproducer, the example
schedule works fine though, so I'll have to have another look to see if I
can get it to reproduce again with another example dataset.





--
View this message in context: http://drools.46999.n3.nabble.com/OptaPlanner-score-corruption-when-using-insertLogical-with-custom-objects-tp4024932p4025124.html
Sent from the Drools: User forum mailing list archive at Nabble.com.


More information about the rules-users mailing list