Package org.optaplanner.core.api.score

Examples of org.optaplanner.core.api.score.Score


        }
        // averageScore can no longer be null
        double[] differenceSquaredTotalDoubles = null;
        for (SingleBenchmarkResult singleBenchmarkResult : singleBenchmarkResultList) {
            if (!singleBenchmarkResult.isFailure()) {
                Score difference = singleBenchmarkResult.getScore().subtract(averageScore);
                // Calculations done on doubles to avoid common overflow when executing with an int score > 500 000
                double[] differenceDoubles = ScoreUtils.extractLevelDoubles(difference);
                if (differenceSquaredTotalDoubles == null) {
                    differenceSquaredTotalDoubles = new double[differenceDoubles.length];
                }
View Full Code Here


        private void localSearchStepEnded(LocalSearchStepScope stepScope) {
            if (stepScope.getBestScoreImproved()) {
                long timeMillisSpent = stepScope.getPhaseScope().calculateSolverTimeMillisSpent();
                String moveType = stepScope.getStep().getSimpleMoveTypeDescription();
                Score newBestScore = stepScope.getScore();
                Score bestScoreDiff = newBestScore.subtract(oldBestScore);
                oldBestScore = newBestScore;
                pointList.add(new PickedMoveTypeBestScoreDiffStatisticPoint(
                        timeMillisSpent, moveType, bestScoreDiff));
            }
        }
View Full Code Here

        }

        private void localSearchStepEnded(LocalSearchStepScope stepScope) {
            long timeMillisSpent = stepScope.getPhaseScope().calculateSolverTimeMillisSpent();
            String moveType = stepScope.getStep().getSimpleMoveTypeDescription();
            Score newStepScore = stepScope.getScore();
            Score stepScoreDiff = newStepScore.subtract(oldStepScore);
            oldStepScore = newStepScore;
            pointList.add(new PickedMoveTypeStepScoreDiffStatisticPoint(
                    timeMillisSpent, moveType, stepScoreDiff));
        }
View Full Code Here

        // TODO the planning entity list from the solution should be used and might already contain initialized entities
        List<SeatDesignation> seatDesignationList = createSeatDesignationList(dinnerParty);
        // Assign one guest at a time
        List<Seat> undesignatedSeatList = new ArrayList<Seat>(dinnerParty.getSeatList());
        for (SeatDesignation seatDesignation : seatDesignationList) {
            Score bestScore = SimpleScore.valueOf(Integer.MIN_VALUE);
            Seat bestSeat = null;

            boolean added = false;
            // Try every seat for that guest
            // TODO by reordening the seats so index 0 has a different table then index 1 and so on,
            // this will probably be faster because perfectMatch will be true sooner
            for (Seat seat : undesignatedSeatList) {
                if (seatDesignation.getGuest().getGender() == seat.getRequiredGender()) {
                    if (!added) {
                        scoreDirector.beforeEntityAdded(seatDesignation);
                        seatDesignation.setSeat(seat);
                        scoreDirector.afterEntityAdded(seatDesignation);
                        added = true;
                    } else {
                        scoreDirector.beforeVariableChanged(seatDesignation, "seat");
                        seatDesignation.setSeat(seat);
                        scoreDirector.afterVariableChanged(seatDesignation, "seat");
                    }
                    Score score = scoreDirector.calculateScore();
                    if (score.compareTo(bestScore) > 0) {
                        bestScore = score;
                        bestSeat = seat;
                    }
                }
            }
View Full Code Here

                problemScaleCount++;
            }
            failureCount += problemBenchmarkResult.getFailureCount();
        }
        averageProblemScale = problemScaleCount == 0 ? null : totalProblemScale / (long) problemScaleCount;
        Score totalScore = null;
        int solverBenchmarkCount = 0;
        for (SolverBenchmarkResult solverBenchmarkResult : solverBenchmarkResultList) {
            Score score = solverBenchmarkResult.getAverageScore();
            if (score != null) {
                if (totalScore != null && !totalScore.isCompatibleArithmeticArgument(score)) {
                    // Mixing different use cases with different score definitions.
                    totalScore = null;
                    break;
View Full Code Here

        for (SolverBenchmarkResult otherSolverBenchmarkResult : solverBenchmarkResultList) {
            if (otherSolverBenchmarkResult != solverBenchmarkResult) {
                List<Score> otherScoreList = otherSolverBenchmarkResult.getScoreList();
                // TODO the scoreList.size() can differ between SolverBenchmarks
                for (int i = 0; i < scoreList.size(); i++) {
                    Score score = scoreList.get(i);
                    Score otherScore = otherScoreList.get(i);
                    int scoreComparison = score.compareTo(otherScore);
                    if (scoreComparison > 0) {
                        betterCount++;
                    } else if (scoreComparison == 0) {
                        equalCount++;
View Full Code Here

            incrementalScoreCalculator.resetWorkingSolution(workingSolution);
        }
    }

    public Score calculateScore() {
        Score score = incrementalScoreCalculator.calculateScore();
        setCalculatedScore(score);
        return score;
    }
View Full Code Here

        logger.trace("        Move index ({}), score ({}), move ({}).",
                moveScope.getMoveIndex(), moveScope.getScore(), moveScope.getMove());
    }

    private void processMove(ConstructionHeuristicMoveScope moveScope) {
        Score score = moveScope.getStepScope().getPhaseScope().calculateScore();
        if (assertMoveScoreFromScratch) {
            moveScope.getStepScope().getPhaseScope().assertWorkingScoreFromScratch(score, moveScope.getMove());
        }
        moveScope.setScore(score);
        forager.addMove(moveScope);
View Full Code Here

    protected void checkPickEarly(ConstructionHeuristicMoveScope moveScope) {
        switch (pickEarlyType) {
            case NEVER:
                break;
            case FIRST_NON_DETERIORATING_SCORE:
                Score lastStepScore = moveScope.getStepScope().getPhaseScope()
                        .getLastCompletedStepScope().getScore();
                if (moveScope.getScore().compareTo(lastStepScore) >= 0) {
                    earlyPickedMoveScope = moveScope;
                }
                break;
            case FIRST_FEASIBLE_SCORE:
                if (((FeasibilityScore) moveScope.getScore()).isFeasible()) {
                    earlyPickedMoveScope = moveScope;
                }
                break;
            case FIRST_FEASIBLE_SCORE_OR_NON_DETERIORATING_HARD:
                Score lastStepScoreDifference = moveScope.getScore().subtract(moveScope.getStepScope().getPhaseScope()
                        .getLastCompletedStepScope().getScore());
                if (((FeasibilityScore) lastStepScoreDifference).isFeasible()) {
                    earlyPickedMoveScope = moveScope;
                }
                break;
View Full Code Here

    public void solvingStarted(DefaultSolverScope solverScope) {
        // Starting bestSolution is already set by Solver.solve(Solution)
        InnerScoreDirector scoreDirector = solverScope.getScoreDirector();
        int uninitializedVariableCount = scoreDirector.countWorkingSolutionUninitializedVariables();
        solverScope.setBestUninitializedVariableCount(uninitializedVariableCount);
        Score score = scoreDirector.calculateScore();
        solverScope.setBestScore(score);
        solverScope.setBestSolutionTimeMillis(System.currentTimeMillis());
        // The original bestSolution might be the final bestSolution and should have an accurate Score
        solverScope.getBestSolution().setScore(score);
        if (uninitializedVariableCount == 0) {
View Full Code Here

TOP

Related Classes of org.optaplanner.core.api.score.Score

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.