Package org.optaplanner.core.impl.score.definition

Examples of org.optaplanner.core.impl.score.definition.ScoreDefinition


        }
    }

    public void readCsvStatisticFile() {
        File csvFile = getCsvFile();
        ScoreDefinition scoreDefinition = singleBenchmarkResult.getSolverBenchmarkResult().getSolverConfig()
                .getScoreDirectorFactoryConfig().buildScoreDefinition();
        if (!pointList.isEmpty()) {
            throw new IllegalStateException("The pointList with size (" + pointList.size() + ") should be empty.");
        }
        if (!csvFile.exists()) {
View Full Code Here


        if (unimprovedTimeMillisSpentLimit != null) {
            terminationList.add(new UnimprovedTimeMillisSpentTermination(unimprovedTimeMillisSpentLimit));
        }
        if (bestScoreLimit != null) {
            Score bestScoreLimit_ = configPolicy.getScoreDefinition().parseScore(bestScoreLimit);
            ScoreDefinition scoreDefinition = configPolicy.getScoreDefinition();
            double[] timeGradientWeightNumbers = new double[scoreDefinition.getLevelsSize() - 1];
            for (int i = 0; i < timeGradientWeightNumbers.length; i++) {
                timeGradientWeightNumbers[i] = 0.50; // Number pulled out of thin air
            }
            terminationList.add(new BestScoreTermination(scoreDefinition, bestScoreLimit_, timeGradientWeightNumbers));
        }
        if (bestScoreFeasible != null) {
            ScoreDefinition scoreDefinition = configPolicy.getScoreDefinition();
            if (!(scoreDefinition instanceof FeasibilityScoreDefinition)) {
                throw new IllegalStateException("The termination bestScoreFeasible (" + bestScoreFeasible
                        + ") is not compatible with a scoreDefinitionClass (" + scoreDefinition.getClass()
                        + ") which does not implement the interface "
                        + FeasibilityScoreDefinition.class.getSimpleName() + ".");
            }
            if (!bestScoreFeasible) {
                throw new IllegalArgumentException("The termination bestScoreFeasible (" + bestScoreFeasible
View Full Code Here

public class BestScoreTerminationTest {

    @Test
    public void solveTermination() {
        ScoreDefinition scoreDefinition = mock(ScoreDefinition.class);
        when(scoreDefinition.getLevelsSize()).thenReturn(1);
        Termination termination = new BestScoreTermination(scoreDefinition, SimpleScore.valueOf(-1000), new double[]{});
        DefaultSolverScope solverScope = mock(DefaultSolverScope.class);
        when(solverScope.getScoreDefinition()).thenReturn(new SimpleScoreDefinition());
        when(solverScope.isBestSolutionInitialized()).thenReturn(true);
        when(solverScope.getStartingInitializedScore()).thenReturn(SimpleScore.valueOf(-1100));
View Full Code Here

        assertEquals(1.0, termination.calculateSolverTimeGradient(solverScope), 0.0);
    }

    @Test
    public void phaseTermination() {
        ScoreDefinition scoreDefinition = mock(ScoreDefinition.class);
        when(scoreDefinition.getLevelsSize()).thenReturn(1);
        Termination termination = new BestScoreTermination(scoreDefinition, SimpleScore.valueOf(-1000), new double[]{});
        AbstractPhaseScope phaseScope = mock(AbstractPhaseScope.class);
        when(phaseScope.getScoreDefinition()).thenReturn(new SimpleScoreDefinition());
        when(phaseScope.isBestSolutionInitialized()).thenReturn(true);
        when(phaseScope.getStartingScore()).thenReturn(SimpleScore.valueOf(-1100));
View Full Code Here

        assertEquals(1.0, termination.calculatePhaseTimeGradient(phaseScope), 0.0);
    }

    @Test
    public void calculateTimeGradientSimpleScore() {
        ScoreDefinition scoreDefinition = mock(ScoreDefinition.class);
        when(scoreDefinition.getLevelsSize()).thenReturn(1);
        BestScoreTermination termination = new BestScoreTermination(scoreDefinition,
                SimpleScore.valueOf(10), new double[]{});

        assertEquals(0.0, termination.calculateTimeGradient(
                SimpleScore.valueOf(0), SimpleScore.valueOf(10), SimpleScore.valueOf(0)), 0.0);
View Full Code Here

                SimpleScore.valueOf(10), SimpleScore.valueOf(40), SimpleScore.valueOf(20)), 0.00001);
    }

    @Test
    public void calculateTimeGradientSimpleBigDecimalScore() {
        ScoreDefinition scoreDefinition = mock(ScoreDefinition.class);
        when(scoreDefinition.getLevelsSize()).thenReturn(1);
        BestScoreTermination termination = new BestScoreTermination(scoreDefinition,
                SimpleBigDecimalScore.valueOf(new BigDecimal("10.00")), new double[]{});

        assertEquals(0.0, termination.calculateTimeGradient(
                SimpleBigDecimalScore.valueOf(new BigDecimal("0.00")), SimpleBigDecimalScore.valueOf(new BigDecimal("10.00")),
View Full Code Here

                SimpleBigDecimalScore.valueOf(new BigDecimal("20.00"))), 0.00001);
    }

    @Test
    public void calculateTimeGradientHardSoftScore() {
        ScoreDefinition scoreDefinition = mock(ScoreDefinition.class);
        when(scoreDefinition.getLevelsSize()).thenReturn(2);
        BestScoreTermination termination = new BestScoreTermination(scoreDefinition,
                HardSoftScore.valueOf(-10, -300), new double[]{0.75});

        // Normal cases
        // Smack in the middle
View Full Code Here

                HardSoftScore.valueOf(-14, -0)), 0.0);
    }

    @Test
    public void calculateTimeGradientHardSoftBigDecimalScore() {
        ScoreDefinition scoreDefinition = mock(ScoreDefinition.class);
        when(scoreDefinition.getLevelsSize()).thenReturn(2);
        BestScoreTermination termination = new BestScoreTermination(scoreDefinition,
                HardSoftBigDecimalScore.valueOf(new BigDecimal("10.00"), new BigDecimal("10.00")), new double[]{0.75});

        // hard == soft
        assertEquals(0.0, termination.calculateTimeGradient(
View Full Code Here

                HardSoftBigDecimalScore.valueOf(new BigDecimal("20.00"), new BigDecimal("20.00"))), 0.00001);
    }

    @Test
    public void calculateTimeGradientBendableScoreHS() {
        ScoreDefinition scoreDefinition = mock(ScoreDefinition.class);
        when(scoreDefinition.getLevelsSize()).thenReturn(2);
        BestScoreTermination termination = new BestScoreTermination(scoreDefinition,
                BendableScore.valueOf(new int[]{-10}, new int[]{-300}), new double[]{0.75});

        // Normal cases
        // Smack in the middle
View Full Code Here

                BendableScore.valueOf(new int[]{-14}, new int[]{-0})), 0.0);
    }

    @Test
    public void calculateTimeGradientBendableScoreHHSSS() {
        ScoreDefinition scoreDefinition = mock(ScoreDefinition.class);
        when(scoreDefinition.getLevelsSize()).thenReturn(5);
        BestScoreTermination termination = new BestScoreTermination(scoreDefinition,
                BendableScore.valueOf(new int[]{0, 0}, new int[]{0, 0, -10}),
                new double[]{0.75, 0.75, 0.75, 0.75});

        // Normal cases
View Full Code Here

TOP

Related Classes of org.optaplanner.core.impl.score.definition.ScoreDefinition

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.