package org.jboss.qa.brms.performance.realworld.cloudbalancing;

import java.util.Collections;

import org.jboss.qa.brms.performance.AbstractPlannerBenchmark;
import org.jboss.qa.brms.performance.examples.Examples;
import org.jboss.qa.brms.performance.examples.cloudbalancing.CloudBalancingExample;
import org.jboss.qa.brms.performance.examples.cloudbalancing.termination.CloudBalanceCalculateCountTermination;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Param;
import org.optaplanner.core.api.solver.Solver;
import org.optaplanner.core.api.solver.SolverFactory;
import org.optaplanner.core.config.score.director.ScoreDirectorFactoryConfig;
import org.optaplanner.core.config.solver.SolverConfig;
import org.optaplanner.core.config.solver.termination.TerminationConfig;
import org.optaplanner.examples.cloudbalancing.domain.CloudBalance;

public class CloudBalanceBenchmark extends AbstractPlannerBenchmark<CloudBalance> {

    private static final String CLOUD_BALANCING_DROOLS_SCORE_RULES_FILE =
            "org/optaplanner/examples/cloudbalancing/solver/cloudBalancingConstraints.drl";

    @Param({"CB_100_300", "CB_1600_4800", "CB_10000_30000"})
    private CloudBalancingExample.DataSet dataset;

    @Override
    protected CloudBalance createInitialSolution() {
        return Examples.CLOUD_BALANCING.loadSolvingProblem(dataset);
    }

    @Override
    protected Solver<CloudBalance> createSolver() {
        // the pre-defined configuration in CloudBalancing cannot be used
        SolverConfig solverConfig = new SolverConfig();
        solverConfig.setSolutionClass(CloudBalance.class);

        ScoreDirectorFactoryConfig scoreDirectorFactoryConfig = new ScoreDirectorFactoryConfig();
        scoreDirectorFactoryConfig.setInitializingScoreTrend("ONLY_DOWN");
        scoreDirectorFactoryConfig.setScoreDrlList(Collections.singletonList(CLOUD_BALANCING_DROOLS_SCORE_RULES_FILE));
        solverConfig.setScoreDirectorFactoryConfig(scoreDirectorFactoryConfig);
        solverConfig.setTerminationConfig(new TerminationConfig().withTerminationClass(
                CloudBalanceCalculateCountTermination.class));

        SolverFactory<CloudBalance> solverFactory = SolverFactory.create(solverConfig);
        return solverFactory.buildSolver();
    }

    @Benchmark
    public CloudBalance benchmark() {
        return runBenchmark();
    }

    public static void main(String[] args) {
        CloudBalanceBenchmark benchmark = new CloudBalanceBenchmark();
        Solver<CloudBalance> solver = benchmark.createSolver();
        solver.solve(benchmark.createInitialSolution());
    }
}

@@ -58,16 +58,44 @@
 ncing;%0A%0A
+import java.util.ArrayList;%0A
 import j
@@ -116,16 +116,16 @@
 ctions;%0A
-
 %0Aimport 
@@ -895,16 +895,153 @@
 Balance;
+%0Aimport org.optaplanner.examples.cloudbalancing.domain.CloudComputer;%0Aimport org.optaplanner.examples.cloudbalancing.domain.CloudProcess;
 %0A%0Apublic
@@ -1759,19 +1759,20 @@
 rConfig.
-set
+with
 Solution
@@ -1797,16 +1797,76 @@
 .class);
+%0A        solverConfig.withEntityClasses(CloudProcess.class);
 %0A%0A      
@@ -2032,16 +2032,16 @@
 DOWN%22);%0A
-
         
@@ -2148,24 +2148,25 @@
 LES_FILE));%0A
+%0A
         solv

Fix CloudBalanceBenchmark