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
eff442f5
Commit
eff442f5
authored
9 years ago
by
Peter Alexander
Browse files
Options
Downloads
Patches
Plain Diff
Fix to problem getting values for crop not produced
parent
6895337e
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
GAMS/IntExtOpt.gms
+2
-2
2 additions, 2 deletions
GAMS/IntExtOpt.gms
src/ac/ed/lurg/ModelConfig.java
+1
-1
1 addition, 1 deletion
src/ac/ed/lurg/ModelConfig.java
src/ac/ed/lurg/country/gams/GamsLocationOptimiser.java
+15
-3
15 additions, 3 deletions
src/ac/ed/lurg/country/gams/GamsLocationOptimiser.java
with
18 additions
and
6 deletions
GAMS/IntExtOpt.gms
+
2
−
2
View file @
eff442f5
...
...
@@ -54,8 +54,8 @@ $gdxin
* pasture yield is done in DM terms
PARAMETER baseCost(crop) cost per ha before intensity values just made up at the moment
/ wheat 0.
5
maize
0.5
/ wheat 0.
8
maize
1.0
rice 1.0
tropicalCereals 0.5
oilcrops 0.5
...
...
This diff is collapsed.
Click to expand it.
src/ac/ed/lurg/ModelConfig.java
+
1
−
1
View file @
eff442f5
...
...
@@ -106,7 +106,7 @@ public class ModelConfig {
public
static
final
int
START_TIMESTEP
=
getIntProperty
(
"START_TIMESTEP"
,
0
);
public
static
final
int
END_TIMESTEP
=
getIntProperty
(
"END_TIMESTEP"
,
0
);
public
static
final
int
END_TIMESTEP
=
getIntProperty
(
"END_TIMESTEP"
,
1
);
public
static
final
int
BASE_YEAR
=
getIntProperty
(
"BASE_YEAR"
,
2010
);
public
static
final
double
MAX_IMPORT_CHANGE
=
getDoubleProperty
(
"MAX_IMPORT_CHANGE"
,
0.2
);
...
...
This diff is collapsed.
Click to expand it.
src/ac/ed/lurg/country/gams/GamsLocationOptimiser.java
+
15
−
3
View file @
eff442f5
...
...
@@ -18,6 +18,7 @@ import ac.ed.lurg.utils.LogWriter;
import
ac.ed.lurg.yield.YieldResponsesItem
;
import
com.gams.api.GAMSDatabase
;
import
com.gams.api.GAMSException
;
import
com.gams.api.GAMSGlobals
;
import
com.gams.api.GAMSJob
;
import
com.gams.api.GAMSOptions
;
...
...
@@ -224,9 +225,9 @@ public class GamsLocationOptimiser {
if
(!
cropType
.
equals
(
prevCropType
))
{
feedAmount
=
varFeedAmount
.
findRecord
(
itemName
).
getLevel
();
netImport
=
cropType
.
isImportedCrop
()
?
varNetImports
.
findRecord
(
itemName
).
getLevel
()
:
0
;
cropAdj
=
parmCropAdj
.
findRecord
(
itemName
).
getValue
(
);
prod
=
parmProd
.
findRecord
(
itemName
).
getValue
(
);
prodCost
=
parmProdCost
.
findRecord
(
itemName
).
getValue
(
);
cropAdj
=
getParmValue
(
parmCropAdj
,
itemName
);
prod
=
getParmValue
(
parmProd
,
itemName
);
prodCost
=
getParmValue
(
parmProdCost
,
itemName
);
cropUsageData
.
put
(
cropType
,
new
CropUsageData
(
feedAmount
,
netImport
,
prod
,
prodCost
));
cropAdjs
.
put
(
cropType
,
cropAdj
);
...
...
@@ -267,6 +268,17 @@ public class GamsLocationOptimiser {
GamsLocationOutput
results
=
new
GamsLocationOutput
(
modelStatus
,
intensities
,
cropAreas
,
cropUsageData
,
cropAdjs
);
return
results
;
}
private
double
getParmValue
(
GAMSParameter
aParm
,
String
itemName
)
{
try
{
double
d
=
aParm
.
findRecord
(
itemName
).
getValue
();
return
d
;
}
catch
(
GAMSException
gamsEx
)
{
//LogWriter.println("GAMSException thrown for " + itemName);
return
0
;
}
}
private
void
addScalar
(
GAMSParameter
param
,
double
val
)
{
param
.
addRecord
().
setValue
(
val
);
...
...
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