简体   繁体   中英

Score calculation difference while solving vs. explaining the score

I have a DRL using HardMediumSoftScore, and have found that in some cases there is a difference in score result while calculating and afterwards while explaining the score.

SolverFactory<Problem> solverFactory=solverFactory.cloneSolverFactory();
Solver<Problem> solver = requestSolverFactory.buildSolver();
Problem solved = solver.solve( problem );

At the end of this snippet, the Solver logs some kind of score, eg:

Solving ended: time spent (100648), best score (-339hard/0medium/0soft)...

After the above snippet, I immediately have:

ScoreDirector<Roster> scoreDirector = solver.getScoreDirectorFactory().buildScoreDirector();
scoreDirector.setWorkingSolution( solved );
scoreDirector.calculateScore();

for( ConstraintMatchTotal constraintMatchTotal : scoreDirector.getConstraintMatchTotals() )
{
        LOG.debug( "{} {} {}",constraintMatchTotal.getConstraintName(),constraintMatchTotal.getConstraintMatchCount(), constraintMatchTotal.getScoreTotal() );
}

Here hard scores always match, but sometimes there are also medium scores in the explanation, which are not there at the end of solving, like:

hardConstraint 3 -339hard/0medium/0soft
mediumConstraint 14 0hard/-1582medium/0soft

Anyone got an idea?

In the solver config, turn on environmentMode FULL_ASSERT (or FAST_ASSERT ) and let it run long enough. I suspect you 'll get a score corruption exception. Fix that first. (Read the score corruption error message analysis a couple of times to understand it.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM