use of org.kie.karaf.itest.planner.domain.CloudBalance in project droolsjbpm-integration by kiegroup.
the class PlannerCloudBalanceIntegrationTest method cloudBalanceGeneratorForFuse.
private CloudBalance cloudBalanceGeneratorForFuse(int computerNum, int processNum, int seed) {
Random random = new Random(seed);
int costRange = 10000;
int costBaseline = 1000;
int cpuPowerRange = 100;
int cpuPowerBaseLine = 10;
int memoryRange = 100;
int memoryBaseLine = 10;
int networkRange = 100;
int networkBaseLine = 10;
CloudBalance cloudBalance = new CloudBalance();
String string = Integer.MIN_VALUE + "hard";
string += "/";
string += Integer.MIN_VALUE + "soft";
cloudBalance.setScore(HardSoftScore.parseScore(string));
List<CloudComputer> computerList = new ArrayList<>();
for (int i = 0; i < computerNum; i++) {
CloudComputer computer = new CloudComputer();
computer.setCost(random.nextInt(costRange) + costBaseline);
computer.setCpuPower(random.nextInt(cpuPowerRange) + cpuPowerBaseLine);
computer.setMemory(random.nextInt(memoryRange) + memoryBaseLine);
computer.setNetworkBandwidth(random.nextInt(networkRange) + networkBaseLine);
computerList.add(computer);
}
int processCpuPowerRange = 50;
int processCpuPowerBaseLine = 1;
int processMemoryRange = 50;
int processMemoryBaseLine = 1;
int processNetworkRange = 50;
int processNetworkBaseLine = 1;
List<CloudProcess> processList = new ArrayList<>();
for (int i = 0; i < processNum; i++) {
CloudProcess process = new CloudProcess();
process.setRequiredCpuPower(random.nextInt(processCpuPowerRange) + processCpuPowerBaseLine);
process.setRequiredMemory(random.nextInt(processMemoryRange) + processMemoryBaseLine);
process.setRequiredNetworkBandwidth(random.nextInt(processNetworkRange) + processNetworkBaseLine);
processList.add(process);
}
cloudBalance.setComputerList(computerList);
cloudBalance.setProcessList(processList);
return cloudBalance;
}
use of org.kie.karaf.itest.planner.domain.CloudBalance in project droolsjbpm-integration by kiegroup.
the class PlannerCloudBalanceIntegrationTest method solveUsingSolverFactory.
private void solveUsingSolverFactory(String configFile) {
SolverFactory<CloudBalance> solverFactory = SolverFactory.createFromXmlResource(configFile, PlannerCloudBalanceIntegrationTest.class.getClassLoader());
CloudBalance cloudBalance = cloudBalanceGeneratorForFuse(10, 20, 0);
Assert.assertEquals(cloudBalance.getScore().getHardScore(), Integer.MIN_VALUE);
Assert.assertEquals(cloudBalance.getScore().getSoftScore(), Integer.MIN_VALUE);
Solver<CloudBalance> solver = solverFactory.buildSolver();
solver.solve(cloudBalance);
CloudBalance solution = solver.getBestSolution();
Assert.assertNotEquals(solution.getScore().getHardScore(), Integer.MIN_VALUE);
Assert.assertNotEquals(solution.getScore().getSoftScore(), Integer.MIN_VALUE);
}
use of org.kie.karaf.itest.planner.domain.CloudBalance in project droolsjbpm-integration by kiegroup.
the class PlannerCloudBalanceIntegrationTest method solveSolution.
private void solveSolution(CloudBalance cloudBalance) {
LocalSearchPhaseConfig localSearchPhaseConfig = new LocalSearchPhaseConfig();
localSearchPhaseConfig.setTerminationConfig(new TerminationConfig().withStepCountLimit(20));
SolverConfig config = new SolverConfig().withEntityClassList(Arrays.asList(CloudProcess.class)).withSolutionClass(CloudBalance.class).withScoreDirectorFactory(new ScoreDirectorFactoryConfig().withIncrementalScoreCalculatorClass(CloudBalancingIncrementalScoreCalculator.class)).withPhases(new ConstructionHeuristicPhaseConfig().withConstructionHeuristicType(ConstructionHeuristicType.FIRST_FIT_DECREASING), localSearchPhaseConfig);
Assert.assertEquals(cloudBalance.getScore().getHardScore(), Integer.MIN_VALUE);
Assert.assertEquals(cloudBalance.getScore().getSoftScore(), Integer.MIN_VALUE);
SolverFactory<CloudBalance> solverFactory = SolverFactory.create(config);
Solver<CloudBalance> solver = solverFactory.buildSolver();
solver.solve(cloudBalance);
CloudBalance solution = solver.getBestSolution();
Assert.assertNotEquals(solution.getScore().getHardScore(), Integer.MIN_VALUE);
Assert.assertNotEquals(solution.getScore().getSoftScore(), Integer.MIN_VALUE);
}
Aggregations