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);
  }
 private OptimizationParams mockOptimizationsMock() {
   List<Long> productsId = new ArrayList<>();
   productsId.add(new Long(340));
   productsId.add(new Long(341));
   productsId.add(new Long(342));
   productsId.add(new Long(343));
   productsId.add(new Long(344));
   productsId.add(new Long(345));
   return new OptimizationParams(productsId);
 }
 private void createProductListAndOffersMap() {
   productList = new ArrayList<>();
   offersMap = new HashMap<>();
   List<Long> productsId = optimizationParams.getProductsId();
   for (Long productId : productsId) {
     Product product = productRepository.findOne(productId);
     if (product != null) {
       List<Offer> offerList = offerRepository.findByIdProduct(productId);
       if (offerList.size() > 0) {
         productList.add(product);
         offersMap.put(product, offerList);
       } else {
         missedProductList.add(new MissedProduct(product.getName()));
       }
     } else {
       missedProductList.add(new MissedProduct("Id: " + productId));
     }
   }
 }
 private void createShopsList() {
   shopsList = new ArrayList<>();
   Set<Long> shopIdSet = new HashSet<>();
   for (Map.Entry<Product, List<Offer>> entry : offersMap.entrySet()) {
     List<Offer> offerList = entry.getValue();
     for (Offer offer : offerList) {
       shopIdSet.add(offer.getIdSklep());
     }
   }
   for (Long shopId : shopIdSet) {
     Shop shop = shopRepository.findOne(shopId);
     shopsList.add(shop);
   }
 }