From 1777708b242dfb1b661ff3b712a114b44bf03869 Mon Sep 17 00:00:00 2001 From: R0slyn <roslyn.henry.08@aberdeen.ac.uk> Date: Wed, 28 Nov 2018 12:15:57 +0000 Subject: [PATCH] tweak to only output traded crops for crafty --- src/ac/ed/lurg/ModelMain.java | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/ac/ed/lurg/ModelMain.java b/src/ac/ed/lurg/ModelMain.java index a30e8cf4..85c57f03 100644 --- a/src/ac/ed/lurg/ModelMain.java +++ b/src/ac/ed/lurg/ModelMain.java @@ -321,23 +321,21 @@ private void writeCraftyPricesFile(Timestep timestep){ StringBuffer sbHeadings = new StringBuffer("Year, Country, Crop,Import_price, Export_price"); BufferedWriter outputFile = getFileWriter(timestep, ModelConfig.CRAFTY_PRICES_FILE, sbHeadings.toString()); - for (CropType crop : CropType.getAllItems()) { - for (CountryAgent country : countryAgents) { - + for (CountryAgent country : countryAgents) { + + Map<CropType, CountryPrice> currentPrices = country.getCurrentCountryPrices(); + + for (CropType crop : CropType.getImportedTypes()) { + Map<CropType, CropUsageData> cropUsageAllCrops = country.getCropUsageData(); CropUsageData cropUsage = cropUsageAllCrops.get(crop); if (cropUsage == null) continue; - - Double importPrice = null; - Double exportPrice = null; - if (crop.isImportedCrop()) { - CountryPrice px = country.getCurrentCountryPrices().get(crop); - importPrice = px.getImportPrice(); - exportPrice = px.getExportPrice(); - } + CountryPrice px = currentPrices.get(crop); + double importPrice = px.getImportPrice(); + double exportPrice = px.getExportPrice(); StringBuffer sbData = new StringBuffer(); sbData.append(String.format("%d,%s,%s", timestep.getYear(), country.getCountry(), crop.getGamsName())); -- GitLab