From ae709700e6ed0815b8a659e806a7c6881fde30b4 Mon Sep 17 00:00:00 2001
From: R0slyn <roslyn.henry.08@aberdeen.ac.uk>
Date: Wed, 26 Jun 2019 15:56:02 +0100
Subject: [PATCH] Backout changeset 779218d5009ab924c8b64a703bd431f904e80b0b

---
 .../ed/lurg/country/AbstractCountryAgent.java | 14 +++++++++-
 src/ac/ed/lurg/country/CountryAgent.java      | 28 -------------------
 .../country/crafty/CraftyCountryAgent.java    | 20 -------------
 3 files changed, 13 insertions(+), 49 deletions(-)

diff --git a/src/ac/ed/lurg/country/AbstractCountryAgent.java b/src/ac/ed/lurg/country/AbstractCountryAgent.java
index ac9bd99f..2a2a2cc3 100644
--- a/src/ac/ed/lurg/country/AbstractCountryAgent.java
+++ b/src/ac/ed/lurg/country/AbstractCountryAgent.java
@@ -39,7 +39,19 @@ public abstract class AbstractCountryAgent {
 		currentMinDemandFract = getMinDemandFraction();
 	}
 
-	protected abstract void calculateCountryPrices(Map<CropType, GlobalPrice> worldPrices);
+	private void calculateCountryPrices(Map<CropType, GlobalPrice> worldPrices){
+		Map<CropType, CountryPrice> countryPrices = new HashMap <CropType, CountryPrice>();
+
+		for (CropType c : CropType.getImportedTypes()) {
+			GlobalPrice worldPrice = worldPrices.get(c);
+			Double tb = tradeBarriers.get(c);
+			LogWriter.println(worldPrice + " " + c);
+			CountryPrice prices = new CountryPrice(worldPrice.getCountryImportPrice(tb==null ? 0 : tb, currentTimestep), worldPrice.getExportPrice());
+			countryPrices.put(c, prices);
+		}
+
+		currentCountryPrices = countryPrices;
+	}
 	
 	private void calculateDemand() {
 		Map<CommodityType, Double> producerPrices = getProducerCommodityPrices();
diff --git a/src/ac/ed/lurg/country/CountryAgent.java b/src/ac/ed/lurg/country/CountryAgent.java
index 192c5278..01797409 100644
--- a/src/ac/ed/lurg/country/CountryAgent.java
+++ b/src/ac/ed/lurg/country/CountryAgent.java
@@ -59,34 +59,6 @@ public class CountryAgent extends AbstractCountryAgent {
 	public RasterSet<IntegerRasterItem> getYieldClusters() {
 		return yieldClusters;
 	}
-	
-	@Override
-	protected void calculateCountryPrices(Map<CropType, GlobalPrice> worldPrices) {
-		Map<CropType, CountryPrice> countryPrices = new HashMap <CropType, CountryPrice>();
-		
-		Map<CropType, CropUsageData> cropUsageMap = previousGamsRasterOutput.getCropUsageData();
-		
-		for (CropType c : CropType.getImportedTypes()) {
-			GlobalPrice worldPrice = worldPrices.get(c);
-			Double tb = tradeBarriers.get(c);
-			CropUsageData cropUsageData = cropUsageMap.get(c);
-			LogWriter.println(worldPrice + " " + c);
-			double importsPostShock = cropUsageData.getShockedNetImports();
-			double productionPostShock = cropUsageData.getProductionExpected()-cropUsageData.getProductionShock();
-			double weighting = importsPostShock/(productionPostShock+importsPostShock);
-				
-			double importPrice = worldPrice.getCountryImportPrice(tb==null ? 0 : tb, currentTimestep) * weighting;
-			double exportPrice = worldPrice.getExportPrice() * (1-weighting);
-	
-			double newImportPrice = importPrice + exportPrice;
-	
-			CountryPrice prices = new CountryPrice(newImportPrice, worldPrice.getExportPrice());
-			countryPrices.put(c, prices);
-		}
-
-		currentCountryPrices = countryPrices;
-		
-	}
 
 	private RasterSet<IntegerRasterItem> calcYieldClusters(RasterSet<IrrigationItem> irrigData, YieldRaster countryYieldSurfaces) {
 
diff --git a/src/ac/ed/lurg/country/crafty/CraftyCountryAgent.java b/src/ac/ed/lurg/country/crafty/CraftyCountryAgent.java
index e81408fa..cbdb684c 100644
--- a/src/ac/ed/lurg/country/crafty/CraftyCountryAgent.java
+++ b/src/ac/ed/lurg/country/crafty/CraftyCountryAgent.java
@@ -6,14 +6,10 @@ import java.util.Map.Entry;
 
 import ac.ed.lurg.country.AbstractCountryAgent;
 import ac.ed.lurg.country.CompositeCountry;
-import ac.ed.lurg.country.CountryPrice;
 import ac.ed.lurg.country.GlobalPrice;
-import ac.ed.lurg.country.SingleCountry;
 import ac.ed.lurg.demand.AbstractDemandManager;
 import ac.ed.lurg.landuse.CropUsageData;
-import ac.ed.lurg.types.CommodityType;
 import ac.ed.lurg.types.CropType;
-import ac.ed.lurg.utils.LogWriter;
 
 /** 
  * Country agent that is interface over data transferred to and from CRAFTY.
@@ -42,20 +38,4 @@ public class CraftyCountryAgent extends AbstractCountryAgent {
 		
 		updateNetImportsFromProdAndDemand(currentProjectedDemand, currentMinDemandFract, cropUsageData);
 	}
-	
-	@Override
-	protected void calculateCountryPrices(Map<CropType, GlobalPrice> worldPrices) {
-		Map<CropType, CountryPrice> countryPrices = new HashMap <CropType, CountryPrice>();
-
-		for (CropType c : CropType.getImportedTypes()) {
-			GlobalPrice worldPrice = worldPrices.get(c);
-			Double tb = tradeBarriers.get(c);
-			LogWriter.println(worldPrice + " " + c);
-			CountryPrice prices = new CountryPrice(worldPrice.getCountryImportPrice(tb==null ? 0 : tb, currentTimestep), worldPrice.getExportPrice());
-			countryPrices.put(c, prices);
-		}
-
-		currentCountryPrices = countryPrices;
-		
-	}
 }
\ No newline at end of file
-- 
GitLab