当前位置: 首页>>代码示例>>Java>>正文


Java HardSoftScore.valueOf方法代码示例

本文整理汇总了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;
}
 
开发者ID:bibryam,项目名称:employee-task-assignment,代码行数:26,代码来源:ProblemScoreCalculator.java

示例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);
}
 
开发者ID:kiegroup,项目名称:optaplanner-training,代码行数:14,代码来源:ElectionEasyScoreCalculator.java

示例3: calculateScore

import org.optaplanner.core.api.score.buildin.hardsoft.HardSoftScore; //导入方法依赖的package包/类
@Override
public Score calculateScore() {
    return HardSoftScore.valueOf(hardScore, softScore);
}
 
开发者ID:WiserUFBA,项目名称:tutorial-optaplanner,代码行数:5,代码来源:BundleBalancerIncrementalScoreCalculator.java

示例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);
}
 
开发者ID:WiserUFBA,项目名称:tutorial-optaplanner,代码行数:57,代码来源:BundleBalancerEasyScoreCalculator.java

示例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);
}
 
开发者ID:kiegroup,项目名称:optaplanner-training,代码行数:6,代码来源:ElectionIncrementalScoreCalculator.java


注:本文中的org.optaplanner.core.api.score.buildin.hardsoft.HardSoftScore.valueOf方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。