private int sumSoftScore(Set<CloudComputer> usedComputerSet) {
   int softScore = 0;
   for (CloudComputer usedComputer : usedComputerSet) {
     softScore -= usedComputer.getCost();
   }
   return softScore;
 }
 public void doChange(ScoreDirector<CloudBalance> scoreDirector) {
   CloudBalance cloudBalance = scoreDirector.getWorkingSolution();
   // Set a unique id on the new computer
   long nextComputerId = 0L;
   for (CloudComputer otherComputer : cloudBalance.getComputerList()) {
     if (nextComputerId <= otherComputer.getId()) {
       nextComputerId = otherComputer.getId() + 1L;
     }
   }
   computer.setId(nextComputerId);
   // A SolutionCloner does not clone problem fact lists (such as computerList)
   // Shallow clone the computerList so only workingSolution is affected, not bestSolution or
   // guiSolution
   cloudBalance.setComputerList(new ArrayList<>(cloudBalance.getComputerList()));
   // Add the problem fact itself
   scoreDirector.beforeProblemFactAdded(computer);
   cloudBalance.getComputerList().add(computer);
   scoreDirector.afterProblemFactAdded(computer);
 }
 private int sumHardScore(
     Map<CloudComputer, Integer> cpuPowerUsageMap,
     Map<CloudComputer, Integer> memoryUsageMap,
     Map<CloudComputer, Integer> networkBandwidthUsageMap) {
   int hardScore = 0;
   for (Map.Entry<CloudComputer, Integer> usageEntry : cpuPowerUsageMap.entrySet()) {
     CloudComputer computer = usageEntry.getKey();
     int cpuPowerAvailable = computer.getCpuPower() - usageEntry.getValue();
     if (cpuPowerAvailable < 0) {
       hardScore += cpuPowerAvailable;
     }
   }
   for (Map.Entry<CloudComputer, Integer> usageEntry : memoryUsageMap.entrySet()) {
     CloudComputer computer = usageEntry.getKey();
     int memoryAvailable = computer.getMemory() - usageEntry.getValue();
     if (memoryAvailable < 0) {
       hardScore += memoryAvailable;
     }
   }
   for (Map.Entry<CloudComputer, Integer> usageEntry : networkBandwidthUsageMap.entrySet()) {
     CloudComputer computer = usageEntry.getKey();
     int networkBandwidthAvailable = computer.getNetworkBandwidth() - usageEntry.getValue();
     if (networkBandwidthAvailable < 0) {
       hardScore += networkBandwidthAvailable;
     }
   }
   return hardScore;
 }