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
5adb831e
Commit
5adb831e
authored
10 years ago
by
Peter Alexander
Browse files
Options
Downloads
Patches
Plain Diff
no message
parent
2661b436
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
GAMS/IntExtOpt.gms
+70
-0
70 additions, 0 deletions
GAMS/IntExtOpt.gms
bin/ac/ed/lurg/GamsTest.class
+0
-0
0 additions, 0 deletions
bin/ac/ed/lurg/GamsTest.class
src/ac/ed/lurg/GamsTest.java
+5
-10
5 additions, 10 deletions
src/ac/ed/lurg/GamsTest.java
with
75 additions
and
10 deletions
GAMS/IntExtOpt.gms
0 → 100644
+
70
−
0
View file @
5adb831e
SET crop crop types including pasture / cereals, fruits, oilcrops, starchyRoots, treenuts, vegetables, pasture /
SET crop_less_pasture(crop) arable crops types includes treenuts but not pasture / cereals, fruits, oilcrops, starchyRoots, treenuts, vegetables /
SET feed_crop(crop) / cereals, oilcrops /
SET landuse land use type / cropland, pasture /
PARAMETER previous_area(landuse) areas for previous timestep in ha
PARAMETER demand(crop) yield in t per ha
PARAMETER yield_ref(crop) yield in t per ha
$gdxin %gdxincname%
$load previous_area, demand, yield_ref
$gdxin
PARAMETER
feedEnergy(crop) energy from feed in MJ per t
/ cereals 1
oilcrops 1.5
pasture 0.4
/ ;
SCALAR meatDemand /200/;
SCALAR meatEfficency /0.1/;
SCALAR maxLandUseChange /0.1/;
VARIABLES
area(crop) total area for each crop
feedArea(crop) area used for feed for each crop
intensity(crop) intensity for each crop
yield(crop) energy per area for each crop
unit_energy(crop) energy per area for each crop
energy total input energy
;
POSITIVE VARIABLE area, intensity, feedArea;
EQUATIONS
UNIT_ENERGY_EQ(crop) energy per area
YIELD_EQ(crop) yield given chosen intensity
CROP_DEMAND_CONSTRAINT(crop_less_pasture) satisfy demand for crop
MEAT_DEMAND_CONSTRAINT satisfy demand for crop
INTENSITY_CONSTRAINT(crop) intensity constraint
CROPLAND_CHANGE_CONSTRAINT constraint on the rate of land use change
PASTURE_CHANGE_CONSTRAINT constraint on the rate of land use change
AGRI_LAND_CHANGE_CONSTRAINT constraint expansion of agricultural land
ENERGY_EQ define objective function;
UNIT_ENERGY_EQ(crop) .. unit_energy(crop) =E= intensity(crop) + intensity(crop) / 2 * intensity(crop) / 8;
YIELD_EQ(crop) .. yield(crop) =E= yield_ref(crop) * intensity(crop);
CROP_DEMAND_CONSTRAINT(crop_less_pasture) .. (area(crop_less_pasture) - feedArea(crop_less_pasture)) * yield(crop_less_pasture) =G= demand(crop_less_pasture);
MEAT_DEMAND_CONSTRAINT .. meatEfficency*sum(feed_crop, feedEnergy(feed_crop) * feedArea(feed_crop) * yield(feed_crop)) +
feedEnergy('pasture') * area('pasture') * yield('pasture') =G= meatDemand;
INTENSITY_CONSTRAINT(crop) .. intensity(crop) =G= 1;
CROPLAND_CHANGE_CONSTRAINT .. abs(sum(crop_less_pasture, area(crop_less_pasture))/previous_area('cropland') - 1) =L= maxLandUseChange;
PASTURE_CHANGE_CONSTRAINT .. abs(area('pasture')/previous_area('pasture') - 1) =L= maxLandUseChange;
AGRI_LAND_CHANGE_CONSTRAINT .. abs(sum(crop, area(crop)) / sum(landuse, previous_area(landuse)) - 1) =L= maxLandUseChange;
ENERGY_EQ .. energy =E= SUM(crop, area(crop)*unit_energy(crop));
MODEL LAND_USE /ALL/ ;
SOLVE LAND_USE USING DNLP MINIMIZING energy;
This diff is collapsed.
Click to expand it.
bin/ac/ed/lurg/GamsTest.class
deleted
100644 → 0
+
0
−
0
View file @
2661b436
File deleted
This diff is collapsed.
Click to expand it.
src/ac/ed/lurg/GamsTest.java
+
5
−
10
View file @
5adb831e
...
...
@@ -15,15 +15,13 @@ import com.gams.api.GAMSWorkspaceInfo;
public
class
GamsTest
{
private
final
static
String
WORKING_DIR
=
"/Users/peteralexander/Documents/R_Workspace/tempDir"
;
public
static
void
main
(
String
[]
args
)
{
// create GAMSWorkspace "ws" with default working directory
// (the directory named with current date and time under System.getProperty("java.io.tmpdir"))
System
.
out
.
println
(
System
.
getProperty
(
"user.dir"
));
File
workingDirectory
=
new
File
(
System
.
getProperty
(
"user.dir"
),
"GamsTest"
);
File
workingDirectory
=
new
File
(
WORKING_DIR
,
"GamsTest"
);
workingDirectory
.
mkdir
();
// create a workspace
GAMSWorkspaceInfo
wsInfo
=
new
GAMSWorkspaceInfo
();
wsInfo
.
setWorkingDirectory
(
workingDirectory
.
getAbsolutePath
());
...
...
@@ -59,7 +57,6 @@ public class GamsTest {
}
// add a database and add input data into the database
GAMSParameter
a
=
db
.
addParameter
(
"previous_area"
,
1
,
"previous area"
);
for
(
String
c
:
previous_area
.
keySet
())
a
.
addRecord
(
c
).
setValue
(
previous_area
.
get
(
c
));
...
...
@@ -73,7 +70,7 @@ public class GamsTest {
y
.
addRecord
(
c
).
setValue
(
yield_ref
.
get
(
c
));
// create GAMSJob "t2" from the "model" string variable
GAMSJob
t2
=
ws
.
addJobFromFile
(
"/Users/peteralexander/Documents/R_Workspace/
landalloc
/GAMS/IntExtOpt.gms"
);
GAMSJob
t2
=
ws
.
addJobFromFile
(
"/Users/peteralexander/Documents/R_Workspace/
UNPLUM
/GAMS/IntExtOpt.gms"
);
GAMSOptions
opt
=
ws
.
addOptions
();
System
.
out
.
println
(
db
.
getName
());
...
...
@@ -90,8 +87,6 @@ public class GamsTest {
// cleanup GAMSWorkspace's working directory
cleanup
(
ws
.
workingDirectory
());
// terminate program
System
.
exit
(
0
);
}
static
void
cleanup
(
String
directory
)
{
...
...
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