CloudBalancingHelloWorld找不到最佳解决方案

时间:2016-06-17 16:55:23

标签: optaplanner

在OptaPlanner用户指南中,有一个示例将4个进程分配给2台具有2个禁区(CPU和RAM)的计算机。

Cloud balance example

我创建了一个CloudBalance解决方案来测试这个例子。令人惊讶的是,最佳分数总是-1硬,而最佳解决方案是0硬。 我尝试过不同的分数计算器,但结果是一样的。

这是结果

Process 1 -> Computer 2 
Process 2 -> Computer 1
Process 3 -> Computer 1
Process 4 -> Computer 2

任何人都可以帮忙解释为什么找不到最佳解决方案吗?任何建议都表示赞赏。

以下是创建CloudBalance的方法

public static CloudBalance createCloudBalance(){
    CloudBalance cb = new CloudBalance();

    CloudComputer cc1 = new CloudComputer();
    cc1.setId(1L);
    cc1.setCpuPower(7);
    cc1.setMemory(6);
    cc1.setNetworkBandwidth(100);
    cc1.setCost(30);

    CloudComputer cc2 = new CloudComputer();
    cc2.setId(2L);
    cc2.setCpuPower(6);
    cc2.setMemory(6);
    cc2.setNetworkBandwidth(100);
    cc2.setCost(25);

    List<CloudComputer> computerList = new ArrayList<CloudComputer>(2);
    computerList.add(cc1);
    computerList.add(cc2);

    CloudProcess cp1 = new CloudProcess();
    cp1.setId(1L);
    cp1.setRequiredCpuPower(5);
    cp1.setRequiredMemory(5);
    cp1.setRequiredNetworkBandwidth(1);

    CloudProcess cp2 = new CloudProcess();
    cp2.setId(2L);
    cp2.setRequiredCpuPower(4);
    cp2.setRequiredMemory(3);
    cp2.setRequiredNetworkBandwidth(1);

    CloudProcess cp3 = new CloudProcess();
    cp3.setId(3L);
    cp3.setRequiredCpuPower(2);
    cp3.setRequiredMemory(3);
    cp3.setRequiredNetworkBandwidth(1);

    CloudProcess cp4 = new CloudProcess();
    cp4.setId(4L);
    cp4.setRequiredCpuPower(2);
    cp4.setRequiredMemory(1);
    cp4.setRequiredNetworkBandwidth(1);

    List<CloudProcess> processList = new ArrayList<CloudProcess>(4);
    processList.add(cp1);
    processList.add(cp2);
    processList.add(cp3);
    processList.add(cp4);

    cb.setComputerList(computerList);
    cb.setProcessList(processList);

    return cb;
}

更新CloudBalancingHelloWorld以使用上述方法

CloudBalance unsolvedCloudBalance = createCloudBalance();

1 个答案:

答案 0 :(得分:0)

添加pillarSwapMoveSelector和pillarChangeMoveSelector - 我们很快就会开箱即用。