Yes I am getting the same results with your recommended rule.
Also I wrote a Drools program that does not use Planner but instead performs
the initial insert of the ShiftAdjustment, then the 3 updates with the
firing of the rules at each insert/update, all in sequence, with the display
of the score after each firing (so no use of the Solution class). And I get
exactly the same erroneous results.
I agree with you, it could be in the hashCode and/or equals methods. I will
check them again against the examples. I have done it so many times already.
:)
It's odd indeed that the tmp working memory is incorrect, instead
of the
real one.
The real working memory is created everytime from scratch to check against
the presumed score, right? Somehow the update of a fact (planning entity in
this case) does not yield the same result as a retract and then insert (or
plain insert in the case of the real working memory).
We looked at the planning entity code earlier. Here is some code for the
IntervalRequirement class that is being used to match against the
ShiftAssignment:
public class IntervalRequirement implements Comparable<IntervalRequirement>
{
private int dayAppliesTo;
private int interval;
private int intervalMinutes;
private Position position;
private int staffingRequired;
@Override
public int compareTo(IntervalRequirement other) {
return this.interval - other.interval;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
} else if (o instanceof IntervalRequirement) {
IntervalRequirement other = (IntervalRequirement) o;
return new EqualsBuilder()
.append(this.interval, other.interval)
.append(this.position, other.position)
.append(this.staffingRequired, other.staffingRequired)
.isEquals();
} else {
return false;
}
@Override
public int hashCode() {
return new HashCodeBuilder()
.append(getClass())
.append(this.interval)
.append(this.position)
.append(this.staffingRequired)
.toHashCode();
}
...
}
--
View this message in context:
http://drools.46999.n3.nabble.com/Planner-5-3-Final-presumedScore-is-corr...
Sent from the Drools: User forum mailing list archive at
Nabble.com.