本文整理汇总了Java中org.optaplanner.core.api.score.buildin.hardsoft.HardSoftScore.valueOf方法的典型用法代码示例。如果您正苦于以下问题:Java HardSoftScore.valueOf方法的具体用法?Java HardSoftScore.valueOf怎么用?Java HardSoftScore.valueOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.optaplanner.core.api.score.buildin.hardsoft.HardSoftScore
的用法示例。
在下文中一共展示了HardSoftScore.valueOf方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: calculateScore
import org.optaplanner.core.api.score.buildin.hardsoft.HardSoftScore; //导入方法依赖的package包/类
public Score calculateScore(ProblemDefinition problemDefinition, int initScore) {
Set<Employee> employees = problemDefinition.getEmployees();
Set<Task> tasks = problemDefinition.getTasks();
Set<Task> assignedTasks = new HashSet<Task>();
int hardScore = 0;
int softScore = 0;
for (Employee employee : employees) {
if (employee.getTask() == null) {
softScore++; //unassigned employee
} else {
assignedTasks.add(employee.getTask());
if ((!employee.canDeliver(employee.getTask()))) {
softScore++; //skill mismatch
}
}
}
int unassignedTasks = tasks.size() - assignedTasks.size();
hardScore += 5 * unassignedTasks; // tasks left unassigned
HardSoftScore hardSoftScore = HardSoftScore.valueOf(initScore, -hardScore, -softScore);
return hardSoftScore;
}
示例2: calculateScore
import org.optaplanner.core.api.score.buildin.hardsoft.HardSoftScore; //导入方法依赖的package包/类
@Override
public Score calculateScore(Election election, int initScore) {
int gamerCandidateWins = 0;
int gamerMinimumPopulation = 0;
for (FederalState federalState : election.getFederalStateList()) {
if (Election.GAMER_CANDIDATE.equals(federalState.getWinningCandidate())) {
gamerCandidateWins += federalState.getElectoralVotes();
gamerMinimumPopulation += federalState.getMinimumMajorityPopulation();
}
}
int hardScore = (gamerCandidateWins >= 270) ? 0 : (gamerCandidateWins - 270);
return HardSoftScore.valueOf(initScore, hardScore, -gamerMinimumPopulation);
}
示例3: calculateScore
import org.optaplanner.core.api.score.buildin.hardsoft.HardSoftScore; //导入方法依赖的package包/类
@Override
public Score calculateScore() {
return HardSoftScore.valueOf(hardScore, softScore);
}
示例4: calculateScore
import org.optaplanner.core.api.score.buildin.hardsoft.HardSoftScore; //导入方法依赖的package包/类
/**
* A very simple implementation. The double loop can easily be removed by using Maps as shown in
* {@link CloudBalancingMapBasedEasyScoreCalculator#calculateScore(CloudBalance)}.
* @param controller
*/
@Override
public HardSoftScore calculateScore(Controller controller) {
int hardScore = 0;
int numHostUsed = 0;
for (Host host : controller.getHostList()) {
int capacityUsed = 0;
boolean used = false;
/* Calcula o uso */
for (Bundle bundle : controller.getBundleList()) {
if (host.equals(bundle.getHostAssociated())) {
capacityUsed += bundle.getCapacityRequired();
used = true;
}
}
/* Pontuação **Hard** é a capacidade dos que está sendo excedida */
int capacityAvailable = host.getCapacity() - capacityUsed;
if (capacityAvailable < 0) {
hardScore += capacityAvailable;
}
/* Como o objetivo é manter o sistema balanceado ou seja com uma
quantidade de nós próximas então temos outra métrica hard */
/* Só que eu ainda não sei qual é ela */
/* Incrementa o numero de host usados */
if(used){
numHostUsed++;
}
}
/* Pontuação **Soft** é o número de nós que não estão sendo utilizados quanto mais nós utilizados melhor */
int softScore = 0;
/* Se a quantidade de bundles for menor que a quantidade de hosts teremos sempre um host com ou sem nenhum bundle */
if(controller.getBundleList().size() >= controller.getHostList().size()){
softScore = numHostUsed - controller.getHostList().size();
}
/* Imprime o resultado da rodada */
Controller.CONTADOR_RODADA++;
System.out.println( "Rodada " + Controller.CONTADOR_RODADA + " => "
+ "Hard Score = " + hardScore + " | Soft Score = " + softScore);
/* Retorna a avaliação das pontuações */
return HardSoftScore.valueOf(hardScore, softScore);
}
示例5: calculateScore
import org.optaplanner.core.api.score.buildin.hardsoft.HardSoftScore; //导入方法依赖的package包/类
@Override
public Score calculateScore(int initScore) {
int hardScore = (gamerCandidateWins >= 270) ? 0 : (gamerCandidateWins - 270);
return HardSoftScore.valueOf(initScore, hardScore, -gamerMinimumPopulation);
}