コード例 #1
0
  private Optimization prepareResponse(Population results) {
    Individual.Result result = results.get(0).getResult();

    List<OptimizedProduct> optimizedProductList = new ArrayList<>();
    List<OptimizedShop> optimizedShopList = new ArrayList<>();

    for (Integer i = 0; i < shopsList.size(); i++) {
      Shop shop = shopsList.get(i);
      optimizedShopList.add(new OptimizedShop(shop.getName(), shop.getDelivery()));
    }

    for (Integer i = 0; i < productList.size(); i++) {
      OptimizedProduct optimizedProduct =
          new OptimizedProduct(productList.get(i).getName(), result.productPriceMap.get(i));
      optimizedProductList.add(
          new OptimizedProduct(productList.get(i).getName(), result.productPriceMap.get(i)));
      optimizedShopList
          .get(result.productShopMap.get(i))
          .addProduct(optimizedProduct, result.productPriceMap.get(i));
    }

    return new Optimization(
        result.deliveryCost,
        result.purchasingCost,
        optimizedProductList,
        missedProductList,
        optimizedShopList);
  }
コード例 #2
0
 private void createShopsIndexesImage() {
   shopIndexImage = new HashMap<>();
   for (Integer i = 0; i < shopsList.size(); i++) {
     shopIndexImage.put(i, shopsList.get(i).getId());
   }
 }
コード例 #3
0
 private void createProductIndexesImage() {
   productIndexImage = new HashMap<>();
   for (Integer i = 0; i < productList.size(); i++) {
     productIndexImage.put(i, productList.get(i).getId());
   }
 }