Skip to content
Snippets Groups Projects
Commit f81f77db authored by Peter Alexander's avatar Peter Alexander
Browse files

Automated merge with bundle:/var/folders/q0/_71d_v6x7_db44ndq976wzym0000gn/T/SourceTreeTemp.t5ImPa

parents 434713d1 75c96674
No related branches found
No related tags found
Loading
package ac.ed.lurg.country;
import ac.ed.lurg.ModelConfig;
public class GlobalPrice {
double exportPrice;
double importAmount;
double exportAmount;
public GlobalPrice(double exportPrice, double importAmount, double exportAmount) {
this.exportPrice = exportPrice;
this.importAmount = importAmount;
this.exportAmount = exportAmount;
}
public static GlobalPrice createInitial(double exportPrice) {
return new GlobalPrice(exportPrice, Double.NaN, Double.NaN);
}
public double getExportPrice() {
return exportPrice;
}
public double getCountryImportPrice(double countryTradeBarrier) {
double importPrice = exportPrice * (1.0 + countryTradeBarrier*ModelConfig.TRADE_BARRIER_ADJ) / (1.0 - ModelConfig.TRANSPORT_LOSSES);
return importPrice;
}
public double getImportAmount() {
return importAmount;
}
public double getExportAmount() {
return exportAmount;
}
public GlobalPrice createWithUpdatedMarketPrices(double imports, double exports, boolean adjustPrice) {
if (imports > 0 || exports > 0) {
double ratio;
if (imports > exports)
ratio = (imports-exports)/imports;
else
ratio = (imports-exports)/exports;
double adjustment = adjustPrice ? Math.exp(ratio * ModelConfig.MARKET_LAMBA) : 1.0;
return new GlobalPrice(exportPrice * adjustment, imports, exports);
}
else {
return this;
}
}
@Override
public String toString() {
return String.format("export=%.3f", exportPrice);
}
}
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