Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PLUM
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Land Use Lab
PLUM
Commits
523e84ba
Commit
523e84ba
authored
1 year ago
by
Bart Arendarczyk
Browse files
Options
Downloads
Patches
Plain Diff
Slight changes to trade constraints.
parent
3f278de4
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/ac/ed/lurg/country/CountryAgent.java
+4
-4
4 additions, 4 deletions
src/ac/ed/lurg/country/CountryAgent.java
src/ac/ed/lurg/country/GlobalPrice.java
+4
-11
4 additions, 11 deletions
src/ac/ed/lurg/country/GlobalPrice.java
with
8 additions
and
15 deletions
src/ac/ed/lurg/country/CountryAgent.java
+
4
−
4
View file @
523e84ba
...
@@ -178,7 +178,7 @@ public class CountryAgent extends AbstractCountryAgent {
...
@@ -178,7 +178,7 @@ public class CountryAgent extends AbstractCountryAgent {
if
(
crop
.
isImportedCrop
())
{
if
(
crop
.
isImportedCrop
())
{
changeUp
=
cropPrice
.
getTradeChangeUp
(
maxOfProdOrSupply
);
changeUp
=
cropPrice
.
getTradeChangeUp
(
maxOfProdOrSupply
);
changeDown
=
cropPrice
.
getTradeChangeDown
(
maxOfProdOrSupply
,
crop
.
getStockToUseRatio
());
//
changeDown = cropPrice.getTradeChangeDown(maxOfProdOrSupply, crop.getStockToUseRatio());
if
(
changeUp
<
0
)
{
// need to reduce imports to avoid negative stocks
if
(
changeUp
<
0
)
{
// need to reduce imports to avoid negative stocks
baseTrade
+=
changeUp
;
baseTrade
+=
changeUp
;
...
@@ -225,7 +225,7 @@ public class CountryAgent extends AbstractCountryAgent {
...
@@ -225,7 +225,7 @@ public class CountryAgent extends AbstractCountryAgent {
}
else
{
}
else
{
double
maxOfProdOrSupply
=
carbonUsageData
.
getCarbonCredits
()
+
Math
.
max
(
baseTrade
,
0
);
double
maxOfProdOrSupply
=
carbonUsageData
.
getCarbonCredits
()
+
Math
.
max
(
baseTrade
,
0
);
changeUp
=
globalCarbonPrice
.
getTradeChangeUp
(
maxOfProdOrSupply
);
changeUp
=
globalCarbonPrice
.
getTradeChangeUp
(
maxOfProdOrSupply
);
changeDown
=
globalCarbonPrice
.
getTradeChangeDown
(
maxOfProdOrSupply
,
ModelConfig
.
DEFAULT_STOCK_USE_RATIO
)
;
changeDown
=
maxOfProdOrSupply
*
ModelConfig
.
MAX_IMPORT_CHANGE
;
if
(
changeUp
<
0
)
{
// need to reduce imports to avoid negative stocks
if
(
changeUp
<
0
)
{
// need to reduce imports to avoid negative stocks
baseTrade
+=
changeUp
;
baseTrade
+=
changeUp
;
...
@@ -260,7 +260,7 @@ public class CountryAgent extends AbstractCountryAgent {
...
@@ -260,7 +260,7 @@ public class CountryAgent extends AbstractCountryAgent {
changeUp
=
changeDown
=
0.0
;
changeUp
=
changeDown
=
0.0
;
}
else
{
}
else
{
changeUp
=
woodPrice
.
getTradeChangeUp
(
maxOfProdOrSupply
);
changeUp
=
woodPrice
.
getTradeChangeUp
(
maxOfProdOrSupply
);
changeDown
=
woodPrice
.
getTradeChangeDown
(
maxOfProdOrSupply
,
ModelConfig
.
DEFAULT_STOCK_USE_RATIO
)
;
changeDown
=
maxOfProdOrSupply
*
ModelConfig
.
MAX_IMPORT_CHANGE
;
if
(
changeUp
<
0
)
{
// need to reduce imports to avoid negative stocks
if
(
changeUp
<
0
)
{
// need to reduce imports to avoid negative stocks
baseTrade
+=
changeUp
;
baseTrade
+=
changeUp
;
...
@@ -290,7 +290,7 @@ public class CountryAgent extends AbstractCountryAgent {
...
@@ -290,7 +290,7 @@ public class CountryAgent extends AbstractCountryAgent {
double
prodCost
=
cropUsageData
.
getProdCostRate
();
double
prodCost
=
cropUsageData
.
getProdCostRate
();
Double
tb
=
tradeBarriers
.
get
(
crop
);
Double
tb
=
tradeBarriers
.
get
(
crop
);
double
tradeBarrier
=
tb
==
null
?
0
:
tb
;
double
tradeBarrier
=
tb
==
null
?
0
:
tb
;
double
exportTaxRateForCrop
=
CommodityType
.
CEREALS
.
getCropTypes
().
contains
(
crop
)
?
exportTaxRate
:
0.0
;
double
exportTaxRateForCrop
=
CommodityType
.
CEREALS
_STARCHY_ROOTS
.
getCropTypes
().
contains
(
crop
)
?
exportTaxRate
:
0.0
;
CountryPrice
cp
=
new
CountryPrice
(
crop
,
worldPrice
,
tradeBarrier
,
prodCost
,
weighting
,
exportTaxRateForCrop
);
CountryPrice
cp
=
new
CountryPrice
(
crop
,
worldPrice
,
tradeBarrier
,
prodCost
,
weighting
,
exportTaxRateForCrop
);
return
cp
;
return
cp
;
}
}
...
...
This diff is collapsed.
Click to expand it.
src/ac/ed/lurg/country/GlobalPrice.java
+
4
−
11
View file @
523e84ba
...
@@ -119,8 +119,9 @@ public class GlobalPrice implements Serializable {
...
@@ -119,8 +119,9 @@ public class GlobalPrice implements Serializable {
// Adjust price based on stock change
// Adjust price based on stock change
adjustment
=
1
-
lambda
*
stockChange
/
production
;
adjustment
=
1
-
lambda
*
stockChange
/
production
;
// If below target stock and stocks not already increasing, nudge prices to increase stock.
// If below target stock and stocks not already increasing, nudge prices up to increase stock.
if
(
updatedStock
<
targetStock
&
stockChange
<
0
)
{
// If above target stock and stocks not already decreasing, nudge prices down to decrease stock.
if
((
updatedStock
<
targetStock
&
stockChange
<
0
&
stockChange
<
prevStockChange
)
|
(
updatedStock
>
targetStock
&
stockChange
>
0
&
stockChange
>
prevStockChange
))
{
adjustment
*=
1
-
0.5
*
ModelConfig
.
MARKET_LAMBDA
*
(
updatedStock
-
targetStock
)
/
production
;
adjustment
*=
1
-
0.5
*
ModelConfig
.
MARKET_LAMBDA
*
(
updatedStock
-
targetStock
)
/
production
;
}
}
}
}
...
@@ -195,15 +196,7 @@ public class GlobalPrice implements Serializable {
...
@@ -195,15 +196,7 @@ public class GlobalPrice implements Serializable {
maxOfProdOrSupply
+=
0.05
*
production
/
CountryManager
.
getInstance
().
getCountryCount
();
maxOfProdOrSupply
+=
0.05
*
production
/
CountryManager
.
getInstance
().
getCountryCount
();
double
supplyFraction
=
maxOfProdOrSupply
/
(
production
*
1.05
);
double
supplyFraction
=
maxOfProdOrSupply
/
(
production
*
1.05
);
// ensures stocks don't go below zero even if no exports
// ensures stocks don't go below zero even if no exports
return
(
0.95
*
stockLevel
-
(
importAmount
-
getExportsAfterTransportLosses
()))
*
supplyFraction
;
return
(
0.9
*
stockLevel
-
(
importAmount
-
getExportsAfterTransportLosses
()))
*
supplyFraction
;
}
public
double
getTradeChangeDown
(
double
maxOfProdOrSupply
,
double
targetStockUseRatio
)
{
// plus 5% of global production divided by number of countries in case country has 0 supply
maxOfProdOrSupply
+=
0.05
*
production
/
CountryManager
.
getInstance
().
getCountryCount
();
double
supplyFraction
=
maxOfProdOrSupply
/
(
production
*
1.05
);
// Allow exports to increase until stocks 50% above target stock level
return
Math
.
max
(
targetStockUseRatio
*
production
*
1.5
-
stockLevel
,
0
)
*
supplyFraction
;
}
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment