Skip to content
Snippets Groups Projects
Commit f5dec23a authored by R0slyn's avatar R0slyn
Browse files

changes to fix bioenergy, GAMs wasn't outputting energy crop export levels.

parent d565e7e8
No related branches found
No related tags found
No related merge requests found
......@@ -258,6 +258,7 @@ $gdxin
totalProdCost(crop) = sum(location, unitCost.l(crop, location) * area.l(crop, location));
totalCropland(location) = sum(crop_less_pasture, area.l(crop_less_pasture, location));
totalArea(crop) = sum(location, area.l(crop, location));
netImportAmount(traded_commodity) = importForFeed.l(traded_commodity) - export.l(traded_commodity);
Scalar ms 'model status', ss 'solve status';
ms=LAND_USE.modelstat;
......
......@@ -231,7 +231,7 @@ public class ModelConfig {
public static final double CROP_INCREASE_COST = getDoubleProperty("CROP_INCREASE_COST", 0.05 * LAND_CHANGE_COST * AGRI_LAND_EXPANSION_COST_FACTOR);
public static final double PASTURE_DECREASE_COST = getDoubleProperty("PASTURE_DECREASE_COST", LAND_CHANGE_COST);
public static final double CROP_DECREASE_COST = getDoubleProperty("CROP_DECREASE_COST", 1.65 * LAND_CHANGE_COST);
public static final double PASTURE_INCREASE_COST = getDoubleProperty("PASTURE_INCREASE_COST", 0.4 * LAND_CHANGE_COST * CROP_TO_PASTURE_COST_FACTOR * AGRI_LAND_EXPANSION_COST_FACTOR);
public static final double PASTURE_INCREASE_COST = getDoubleProperty("PASTURE_INCREASE_COST", 0.35 * LAND_CHANGE_COST * CROP_TO_PASTURE_COST_FACTOR * AGRI_LAND_EXPANSION_COST_FACTOR);
public static final double AGRI_EXPANSION_COST_BASE = getDoubleProperty("AGRI_EXPANSION_COST_BASE", 0.03 * LAND_CHANGE_COST * AGRI_LAND_EXPANSION_COST_FACTOR);
public static final double AGRI_EXPANSION_COST_BASE_MANAGED_FOREST = getDoubleProperty("AGRI_EXPANSION_COST_BASE_MANAGED_FOREST", 0.5 * LAND_CHANGE_COST * AGRI_LAND_EXPANSION_COST_FACTOR);
......
......@@ -311,10 +311,9 @@ public class ModelMain {
}
}
private void writeDomesticProductionFile(Timestep timestep) {
try {
StringBuffer sbHeadings = new StringBuffer("Year, Country, Crop, Area, Production, Production_cost, Export_price, Import_price, Net_imports, Net_import_cost, Feed_amount");
StringBuffer sbHeadings = new StringBuffer("Year, Country, Crop, Area, Production, Production_cost, Import_price, Export_price, Net_imports, Net_import_cost, Rum_feed_amount, Mon_feed_amount");
BufferedWriter outputFile = getFileWriter(timestep, ModelConfig.DOMESTIC_OUTPUT_FILE, sbHeadings.toString());
for (CropType crop : CropType.getAllItems()) {
......@@ -329,7 +328,8 @@ private void writeDomesticProductionFile(Timestep timestep) {
Double prodCosts = cropUsage.getProdCost();
Double prod = cropUsage.getProduction();
Double area = cropUsage.getArea();
Double feedAmount = cropUsage.getMonogastricFeed() + cropUsage.getRuminantFeed();
Double rumFeedAmount = cropUsage.getRuminantFeed();
Double monFeedAmount = cropUsage.getMonogastricFeed();
Double importPrice = null;
Double exportPrice = null;
......@@ -345,8 +345,8 @@ private void writeDomesticProductionFile(Timestep timestep) {
}
StringBuffer sbData = new StringBuffer();
sbData.append(String.format("%d,%s, %s", timestep.getYear(), country.getCountry(), crop.getGamsName()));
sbData.append(String.format(",%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f", area, prod, prodCosts, importPrice, exportPrice, netImports, netImportCost, feedAmount));
sbData.append(String.format("%d,%s,%s", timestep.getYear(), country.getCountry(), crop.getGamsName()));
sbData.append(String.format(",%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f", area, prod, prodCosts, importPrice, exportPrice, netImports, netImportCost, rumFeedAmount, monFeedAmount));
outputFile.write(sbData.toString());
outputFile.newLine();
......
......@@ -166,7 +166,6 @@ public class CountryAgent {
throw new RuntimeException("Not cereal and not 1 to 1 mapping for commodity to crop: " + commodity); // skips cereals which is a special case and handled separately below
double demand = demands.get(commodity);
if (commodity == CommodityType.CEREALS) {
Map<CropType, Double> netImportsFromMinDemands = new HashMap<CropType, Double>();
double totalProd = 0, totalmportFromMD = 0, totalExcessProd = 0;
......@@ -211,7 +210,7 @@ public class CountryAgent {
// simple 1-1 commodity to cereal mappings
for (CropType crop : commodity.getCropTypes()) {
CropUsageData cropUsage = cropUsages.get(crop);
double netImports = demand - cropUsage.getProduction();
double netImports = demand - cropUsage.getNetProduction();
LogWriter.println("Updating net imports single commodity/crop" + commodity + "/" + crop + " to " + netImports);
cropUsage.updateNetImports(netImports);
}
......@@ -249,9 +248,13 @@ public class CountryAgent {
if (allowedImportChange > 0.0) {
double maxOfProdOrSupply = ModelConfig.ORIG_LEAST_COST_MIN ?
(cropUsage.getProduction() + Math.max(baseTradeOrProd, 0)) :
Math.max(cropUsage.getNetImports() + baseTradeOrProd, baseTradeOrProd);
Math.max(cropUsage.getNetImports() + baseTradeOrProd, baseTradeOrProd); //max of supply for food
//max of supply overall, needed for when imports are supplying feed and change is zero to allow for production to replace imports
if (maxOfProdOrSupply == 0) maxOfProdOrSupply = Math.max(cropUsage.getNetImports() + cropUsage.getProduction() , cropUsage.getProduction() );
changeDown = changeUp = allowedImportChange * maxOfProdOrSupply;
}
if (CropType.ENERGY_CROPS.equals(crop)) {
double croplandArea = LandUseItem.getTotalLandCover(previousGamsRasterOutput.getLandUses().values(), LandCoverType.CROPLAND);
......@@ -269,6 +272,7 @@ public class CountryAgent {
baseTradeOrProd=0;
}
importConstraints.put(crop, new TradeOrProductionConstraint(baseTradeOrProd - changeDown, baseTradeOrProd + changeUp, ModelConfig.ORIG_LEAST_COST_MIN));
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment