コード例 #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 calculateInaccessibleOfferPrice() {
   inaccessibleOfferPrice = new Double(0.0);
   for (Shop shop : shopsList) {
     inaccessibleOfferPrice += shop.getDelivery();
   }
   for (Map.Entry<Product, List<Offer>> entry : offersMap.entrySet()) {
     for (Offer offer : entry.getValue()) {
       inaccessibleOfferPrice += offer.getPrice();
     }
   }
 }