本文整理汇总了Java中org.optaplanner.core.api.score.buildin.bendable.BendableScore类的典型用法代码示例。如果您正苦于以下问题:Java BendableScore类的具体用法?Java BendableScore怎么用?Java BendableScore使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BendableScore类属于org.optaplanner.core.api.score.buildin.bendable包,在下文中一共展示了BendableScore类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createPlanningSolution
import org.optaplanner.core.api.score.buildin.bendable.BendableScore; //导入依赖的package包/类
private DataObject createPlanningSolution() {
DataObject dataObject = new DataObjectImpl("test",
"TestSolution");
AnnotationImpl planningSolutionAnnotation = new AnnotationImpl(DriverUtils.buildAnnotationDefinition(PlanningSolution.class));
dataObject.addAnnotation(planningSolutionAnnotation);
ObjectProperty scoreObjectProperty = new ObjectPropertyImpl("score",
BendableScore.class.getName(),
false);
dataObject.addProperty(scoreObjectProperty);
AnnotationImpl planningScoreAnnotation = new AnnotationImpl(DriverUtils.buildAnnotationDefinition(PlanningScore.class));
planningScoreAnnotation.setValue("bendableHardLevelsSize",
1);
planningScoreAnnotation.setValue("bendableSoftLevelsSize",
2);
scoreObjectProperty.addAnnotation(planningScoreAnnotation);
return dataObject;
}
示例2: loadDataObjectWithBendableScoreType
import org.optaplanner.core.api.score.buildin.bendable.BendableScore; //导入依赖的package包/类
@Test
public void loadDataObjectWithBendableScoreType() {
PlannerDataObjectEditor objectEditor = createObjectEditor();
DataObject dataObject = context.getDataObject();
dataObject.addAnnotation(DataModelerEditorsTestHelper.createAnnotation(PlanningSolution.class,
null,
null));
ObjectProperty scoreObjectProperty = new ObjectPropertyImpl("score",
BendableScore.class.getName(),
false);
dataObject.addProperty(scoreObjectProperty);
scoreObjectProperty.addAnnotation(DataModelerEditorsTestHelper.createAnnotation(PlanningScore.class,
new Pair("bendableHardLevelsSize",
5),
new Pair("bendableSoftLevelsSize",
10)));
scoreObjectProperty.addAnnotation(DataModelerEditorsTestHelper.createAnnotation(Generated.class,
null,
null));
objectEditor.onContextChange(context);
verify(view,
times(1)).setPlanningSolutionBendableScoreHardLevelsSize(5);
verify(view,
times(1)).setPlanningSolutionBendableScoreSoftLevelsSize(10);
}
示例3: onPlanningSolutionScoreTypeChange
import org.optaplanner.core.api.score.buildin.bendable.BendableScore; //导入依赖的package包/类
@Test
public void onPlanningSolutionScoreTypeChange() {
PlannerDataObjectEditor objectEditor = createObjectEditor();
objectEditor.onContextChange(context);
Mockito.reset(view);
when(view.getPlanningSolutionScoreType()).thenReturn(BendableScore.class.getName());
context.getAnnotationDefinitions().put(PlannerDomainAnnotations.PLANNING_SCORE_ANNOTATION,
mock(AnnotationDefinition.class));
context.getAnnotationDefinitions().put(PlannerDomainAnnotations.JAXB_XML_ROOT_ELEMENT,
mock(AnnotationDefinition.class));
context.getAnnotationDefinitions().put(PlannerDomainAnnotations.JAXB_XML_ACCESSOR_TYPE,
mock(AnnotationDefinition.class));
context.getAnnotationDefinitions().put(PlannerDomainAnnotations.JAXB_XML_JAVA_TYPE_ADAPTER_ANNOTATION,
mock(AnnotationDefinition.class));
context.getAnnotationDefinitions().put(Generated.class.getName(),
mock(AnnotationDefinition.class));
objectEditor.onPlanningSolutionScoreTypeChange();
DataObject dataObject = context.getDataObject();
ObjectProperty scoreObjectProperty = dataObject.getProperty("score");
assertNotNull(scoreObjectProperty);
assertEquals(BendableScore.class.getName(),
scoreObjectProperty.getClassName());
}
示例4: getScoreHolderTypeFqn
import org.optaplanner.core.api.score.buildin.bendable.BendableScore; //导入依赖的package包/类
public String getScoreHolderTypeFqn(final String scoreTypeFqn) {
if (BendableScore.class.getName().equals(scoreTypeFqn)) {
return BendableScoreHolder.class.getName();
} else if (BendableBigDecimalScore.class.getName().equals(scoreTypeFqn)) {
return BendableBigDecimalScoreHolder.class.getName();
} else if (BendableLongScore.class.getName().equals(scoreTypeFqn)) {
return BendableLongScoreHolder.class.getName();
} else if (HardMediumSoftScore.class.getName().equals(scoreTypeFqn)) {
return HardMediumSoftScoreHolder.class.getName();
} else if (HardMediumSoftBigDecimalScore.class.getName().equals(scoreTypeFqn)) {
return HardMediumSoftBigDecimalScoreHolder.class.getName();
} else if (HardMediumSoftLongScore.class.getName().equals(scoreTypeFqn)) {
return HardMediumSoftLongScoreHolder.class.getName();
} else if (HardSoftScore.class.getName().equals(scoreTypeFqn)) {
return HardSoftScoreHolder.class.getName();
} else if (HardSoftBigDecimalScore.class.getName().equals(scoreTypeFqn)) {
return HardSoftBigDecimalScoreHolder.class.getName();
} else if (HardSoftDoubleScore.class.getName().equals(scoreTypeFqn)) {
return HardSoftDoubleScoreHolder.class.getName();
} else if (HardSoftLongScore.class.getName().equals(scoreTypeFqn)) {
return HardSoftLongScoreHolder.class.getName();
} else if (SimpleScore.class.getName().equals(scoreTypeFqn)) {
return SimpleScoreHolder.class.getName();
} else if (SimpleBigDecimalScore.class.getName().equals(scoreTypeFqn)) {
return SimpleBigDecimalScoreHolder.class.getName();
} else if (SimpleDoubleScore.class.getName().equals(scoreTypeFqn)) {
return SimpleDoubleScoreHolder.class.getName();
} else if (SimpleLongScore.class.getName().equals(scoreTypeFqn)) {
return SimpleLongScoreHolder.class.getName();
}
return null;
}
示例5: calculateScore
import org.optaplanner.core.api.score.buildin.bendable.BendableScore; //导入依赖的package包/类
@Override
public BendableScore calculateScore(ClusterState solution) {
int[] hardScores = { calculateHardScore(solution) };
int[] softScores = {
solution.countNonIdleHosts(),
- (int) Math.round(solution.calculateStdDevCpuPercUsedPerHost()),
VmPlacementConfig.initialClusterState.get().countVmMigrationsNeeded(solution)};
return BendableScore.valueOf(hardScores, softScores);
}
示例6: calculateScore
import org.optaplanner.core.api.score.buildin.bendable.BendableScore; //导入依赖的package包/类
@Override
public BendableScore calculateScore(ClusterState solution) {
int[] hardScores = { calculateHardScore(solution) };
int[] softScores = {
solution.countOffHosts(),
rand.nextInt(POSSIBLE_SCORES),
VmPlacementConfig.initialClusterState.get().countVmMigrationsNeeded(solution)};
return BendableScore.valueOf(hardScores, softScores);
}
示例7: calculateScore
import org.optaplanner.core.api.score.buildin.bendable.BendableScore; //导入依赖的package包/类
@Override
public BendableScore calculateScore(ClusterState solution) {
int[] hardScores = { calculateHardScore(solution) };
int[] softScores = {
solution.countOffHosts(),
solution.countIdleHosts(),
-solution.calculateCumulativeUnusedCpuPerc(),
VmPlacementConfig.initialClusterState.get().countVmMigrationsNeeded(solution)};
return BendableScore.valueOf(hardScores, softScores);
}
示例8: calculateScore
import org.optaplanner.core.api.score.buildin.bendable.BendableScore; //导入依赖的package包/类
@Override
public BendableScore calculateScore(ClusterState solution) {
int[] hardScores = { calculateHardScore(solution) };
int[] softScores = {
solution.countOffHosts(),
calculateSoftScore2(solution),
VmPlacementConfig.initialClusterState.get().countVmMigrationsNeeded(solution)};
return BendableScore.valueOf(hardScores, softScores);
}
示例9: isBendableScore
import org.optaplanner.core.api.score.buildin.bendable.BendableScore; //导入依赖的package包/类
private boolean isBendableScore(String planningSolutionScoreType) {
return BendableScore.class.getName().equals(planningSolutionScoreType)
|| BendableLongScore.class.getName().equals(planningSolutionScoreType)
|| BendableBigDecimalScore.class.getName().equals(planningSolutionScoreType);
}
示例10: testPlanningSolutionLevelsSizeChange
import org.optaplanner.core.api.score.buildin.bendable.BendableScore; //导入依赖的package包/类
public void testPlanningSolutionLevelsSizeChange(boolean isHardScore) {
PlannerDataObjectEditor objectEditor = createObjectEditor();
objectEditor.onContextChange(context);
DataObject dataObject = context.getDataObject();
dataObject.addAnnotation(DataModelerEditorsTestHelper.createAnnotation(PlanningSolution.class,
null,
null));
AnnotationDefinition planningScoreAnnotationDefinition = mock(AnnotationDefinition.class);
when(planningScoreAnnotationDefinition.getClassName()).thenReturn(PlanningScore.class.getName());
context.getAnnotationDefinitions().put(PlannerDomainAnnotations.PLANNING_SCORE_ANNOTATION,
planningScoreAnnotationDefinition);
context.getAnnotationDefinitions().put(Generated.class.getName(),
mock(AnnotationDefinition.class));
ObjectProperty scoreObjectProperty = new ObjectPropertyImpl("score",
BendableScore.class.getName(),
false);
dataObject.addProperty(scoreObjectProperty);
scoreObjectProperty.addAnnotation(DataModelerEditorsTestHelper.createAnnotation(PlanningScore.class,
new Pair("bendableHardLevelsSize",
5),
new Pair("bendableSoftLevelsSize",
5)));
scoreObjectProperty.addAnnotation(DataModelerEditorsTestHelper.createAnnotation(Generated.class,
null,
null));
if (isHardScore) {
when(view.getPlanningSolutionBendableScoreHardLevelsSize()).thenReturn(1);
} else {
when(view.getPlanningSolutionBendableScoreSoftLevelsSize()).thenReturn(1);
}
when(view.getPlanningSolutionScoreType()).thenReturn(BendableScore.class.getName());
objectEditor.onPlanningSolutionBendableScoreHardLevelsSizeChange();
scoreObjectProperty = dataObject.getProperty("score");
assertNotNull(scoreObjectProperty);
Annotation planningScoreAnnotation = scoreObjectProperty.getAnnotation(PlanningScore.class.getName());
assertNotNull(planningScoreAnnotation);
// check whether bendable levels size has been updated
if (isHardScore) {
assertEquals(1,
planningScoreAnnotation.getValue("bendableHardLevelsSize"));
} else {
assertEquals(1,
planningScoreAnnotation.getValue("bendableSoftLevelsSize"));
}
}
示例11: isBendableScore
import org.optaplanner.core.api.score.buildin.bendable.BendableScore; //导入依赖的package包/类
private boolean isBendableScore(final String planningSolutionScoreType) {
return BendableScore.class.getName().equals(planningSolutionScoreType)
|| BendableLongScore.class.getName().equals(planningSolutionScoreType)
|| BendableBigDecimalScore.class.getName().equals(planningSolutionScoreType);
}
示例12: getProjectScoreInformation
import org.optaplanner.core.api.score.buildin.bendable.BendableScore; //导入依赖的package包/类
@Test
public void getProjectScoreInformation() {
Path dataObjectPath = PathFactory.newPath("Test.java",
"file:///dataObjects");
when(assetsUsageService.getAssetUsages(PlanningSolution.class.getName(),
ResourceType.JAVA,
dataObjectPath)).thenReturn(Arrays.asList(dataObjectPath));
when(javaResourceTypeDefinition.accept(dataObjectPath)).thenReturn(true);
// scoreHolder definitions
Package resourcesPackage = mock(Package.class);
when(resourcesPackage.getPackageMainResourcesPath()).thenReturn(PathFactory.newPath("Test.java",
"file:///dataObjects"));
when(kieProjectService.resolvePackage(dataObjectPath)).thenReturn(resourcesPackage);
when(ioService.exists(any(org.uberfire.java.nio.file.Path.class))).thenReturn(true);
GlobalsModel globalsModel = new GlobalsModel();
globalsModel.setGlobals(Arrays.asList(new Global("scoreHolder",
BendableScore.class.getName())));
when(globalsEditorService.load(any(Path.class))).thenReturn(globalsModel);
// Bendable score information
when(ioService.readAllString(Paths.convert(dataObjectPath))).thenReturn("testContent");
GenerationResult generationResult = new GenerationResult();
generationResult.setDataObject(createPlanningSolution());
when(dataModelerService.loadDataObject(dataObjectPath,
"testContent",
dataObjectPath)).thenReturn(generationResult);
ScoreInformation scoreInformation = scoreHolderService.getProjectScoreInformation(dataObjectPath);
assertNotNull(scoreInformation);
Collection<String> scoreHolderFqnTypeFqns = scoreInformation.getScoreHolderFqnTypeFqns();
assertNotNull(scoreHolderFqnTypeFqns);
assertEquals(1,
scoreHolderFqnTypeFqns.size());
assertEquals(BendableScore.class.getName(),
scoreHolderFqnTypeFqns.iterator().next());
Collection<BendableScoreLevelsWrapper> bendableScoreLevelsWrappers = scoreInformation.getBendableScoreLevelsWrappers();
assertNotNull(bendableScoreLevelsWrappers);
assertEquals(1,
bendableScoreLevelsWrappers.size());
BendableScoreLevelsWrapper bendableScoreLevelsWrapper = bendableScoreLevelsWrappers.iterator().next();
assertEquals(1,
bendableScoreLevelsWrapper.getHardScoreLevels());
assertEquals(2,
bendableScoreLevelsWrapper.getSoftScoreLevels());
}