Reputation: 1540
I'm working on a problem like CloudBalancing with OptaPlanner 7.33.0.
The returned PlanningSolution object contains the best calculated score but the solution does not match. I debugged all solutions with a very small dataset and the returned solution seems to be the latest that it doesn't have the returned score.
Example :
This is my planning solution class
@PlanningSolution
public class GroupSolution
{
@PlanningEntityCollectionProperty
private List<Request> request;
@ValueRangeProvider(id = "groupRange")
@ProblemFactCollectionProperty
private List<Group> proposedGroups;
@PlanningScore
private HardMediumSoftScore score;
// Others planning fact that I use in my EasyScoreCalculator
}
Request class
@PlanningEntity
public class Request
{
@PlanningVariable(valueRangeProviderRefs = {
"groupRange"
}, nullable = false)
private Group group;
// Other properties
}
Configuration
<?xml version="1.0" encoding="UTF-8"?>
<solver>
<scanAnnotatedClasses>
<packageInclude>my.package.domain</packageInclude>
</scanAnnotatedClasses>
<!-- Score configuration -->
<scoreDirectorFactory>
<initializingScoreTrend>ONLY_DOWN</initializingScoreTrend>
<easyScoreCalculatorClass>my.package.MyEasyScoreCalculator</easyScoreCalculatorClass>
</scoreDirectorFactory>
<constructionHeuristic />
<termination>
<minutesSpentLimit>5</minutesSpentLimit>
</termination>
</solver>
I'm using an EasyScoreCalculator with 3 levels of scoring and I use them like this :
I will continue to investigate on this but if you have any suggestion to get the correct result you can tell me.
But the main question is, do you know if it's a normal OptaPlanner behavior or not? If it's normal in which case he will return a non matching score and solution?
Upvotes: 1
Views: 234
Reputation: 27337
1) Sounds like score corruption. Given that FAST_ASSERT "fixes it" (it doesn't), run it with <environmentMode>NON_INTRUSIVE_FULL_ASSERT</environmentMode>
, if it throws an exception, it might point you to the real problem, because it detects the issue earlier.
2) Could also be due to planning entity cloning corruption. That's harder to detect. Do you use a custom solution cloner? Are there any domain classes that have references to the planning entity class(es) or planning solution (so references Request
or GroupSolution
)? Any classes that have a Collection or Map with Request
or GroupSolution
instances?
Upvotes: 1