Mapping sets-- counter that can cycle through the set?

Hi,

I’m working on a pixel-based agricultural model that has 2 parts: a water balance and a crop-land allocation. I am having some trouble with the constraints for the crop-land allocation. In particular I want to know the amount of land that can be devoted to a particular crop in a pixel, n, during month m given the water balance. The problem I am facing has to do with the time index. I am working at a monthly time scale for a period of 1 typical Jan-Dec year. One of the constraints I am trying to implement is “Land_in_time” which means once land is devoted to a crop, the amount of land for that crop cannot change during the growing period. In other words,the designated cropland must be constant through the growing period .

(cropland(month) = cropland(month+1) for months in the growing period

The problem:
The growing period for some crops will “wrap around” the typical Jan-Dec year. A crop grown starting in november may finish in february. With a regular index I can’t say that the cropland for december = cropland for january.

I tried to create another time index, TM that maps a time counter t to the months. I also created a set GP (growing period) that maps time with months by crop. A snippet of the code is shown below. This is not working as well as I hoped because i’m writing the constraint like this: CropLand(n,crop,t+1,m+1)=E= CropLand(n,crop,t,m) but m still cannot exceed it’s limit and loop back to the beginning so I didn’t really solve the problem.

Does anyone have some ideas? I would greatly appreciate it.



Parts of the Code:

set m/jan feb march apr may jun jul aug sep oct nov dec/
set t/ t1*t12/

set TM(t,m)
/
t1.jun
t2.jul
t3.aug

t11.apr
t12.may
/

set GP(crop,t,m) ‘Growing period’
/
potato.t1.may
potato.t2.jun
potato.t3.jul

potato.t11.march
potato.t12.apr

maize.t1.feb
maize.t2.mar

maize.t11.dec
maize.t12.jan
/

A(n) = area of pixel

// LAND CONSTRAINTS
Land_total(n,m)(Domain(n)).. sum(crop, cropTotLand(n,crop,m)) + NonCropLand(n,m) =E= A(n); // Land can only be devoted to cropland or to noncropland. \ \ CropLandTot(n,crop,m)(Domain(n))…
cropTotLand(n,crop,m) =E= sum(t, CropLand(n,crop,t,m)$GP(crop,t,m));

  • These two constraints add a time component to the cropland and restrict the maximum value. The kc implicitly represents the LGP
  • The total land devoted to crops must be less than what is considered “arable” if it’s in the growing period (crop coefficient, kc >0) or must be 0 if kc=0.

Land_arable(n,crop,t,m)$(Domain(n) and GP(crop,t,m) and kc(crop,m)GT 0)…
CropLand(n,crop,t,m) =L= arableLand(n,crop)*A(n);

Land_arable2(n,crop,t,m)$(Domain(n) and GP(crop,t,m) and kc(crop,m)EQ 0)…
CropLand(n,crop,t,m) =L= 0;

  • Once a certain amount of Cropland is set for a crop, it must remain constant/unchanged for the LGP.

Land_in_time(n,crop,t,m)$(Domain(n) and GP(crop,t,m) and (kc(crop,m)GT 0) and not endMonthLGP(crop,t,m))…
CropLand(n,crop,t+1,m+1)=E= CropLand(n,crop,t,m);



\

Anjuli Jain Figueroa, EIT

MS Technology and Policy
Massachusetts Institute of Technology
ajainf@mit.edu


To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.

Hi all,
I think I can solve my problem with a circular lead operator instead of a linear one. There’s a useful description of it in the GAMS user manual.
Thanks,
Anjuli

On Wed, Apr 18, 2012 at 10:57 AM, Anjuli Jain Figueroa wrote:

Hi,

I’m working on a pixel-based agricultural model that has 2 parts: a water balance and a crop-land allocation. I am having some trouble with the constraints for the crop-land allocation. In particular I want to know the amount of land that can be devoted to a particular crop in a pixel, n, during month m given the water balance. The problem I am facing has to do with the time index. I am working at a monthly time scale for a period of 1 typical Jan-Dec year. One of the constraints I am trying to implement is “Land_in_time” which means once land is devoted to a crop, the amount of land for that crop cannot change during the growing period. In other words,the designated cropland must be constant through the growing period .

(cropland(month) = cropland(month+1) for months in the growing period

The problem:
The growing period for some crops will “wrap around” the typical Jan-Dec year. A crop grown starting in november may finish in february. With a regular index I can’t say that the cropland for december = cropland for january.

I tried to create another time index, TM that maps a time counter t to the months. I also created a set GP (growing period) that maps time with months by crop. A snippet of the code is shown below. This is not working as well as I hoped because i’m writing the constraint like this: CropLand(n,crop,t+1,m+1)=E= CropLand(n,crop,t,m) but m still cannot exceed it’s limit and loop back to the beginning so I didn’t really solve the problem.

Does anyone have some ideas? I would greatly appreciate it.



Parts of the Code:

set m/jan feb march apr may jun jul aug sep oct nov dec/
set t/ t1*t12/

set TM(t,m)
/
t1.jun
t2.jul
t3.aug

t11.apr
t12.may
/

set GP(crop,t,m) ‘Growing period’
/
potato.t1.may
potato.t2.jun
potato.t3.jul

potato.t11.march
potato.t12.apr

maize.t1.feb
maize.t2.mar

maize.t11.dec
maize.t12.jan
/

A(n) = area of pixel

// LAND CONSTRAINTS
Land_total(n,m)(Domain(n)).. sum(crop, cropTotLand(n,crop,m)) + NonCropLand(n,m) =E= A(n); // Land can only be devoted to cropland or to noncropland. \ \ CropLandTot(n,crop,m)(Domain(n))…
cropTotLand(n,crop,m) =E= sum(t, CropLand(n,crop,t,m)$GP(crop,t,m));

  • These two constraints add a time component to the cropland and restrict the maximum value. The kc implicitly represents the LGP
  • The total land devoted to crops must be less than what is considered “arable” if it’s in the growing period (crop coefficient, kc >0) or must be 0 if kc=0.

Land_arable(n,crop,t,m)$(Domain(n) and GP(crop,t,m) and kc(crop,m)GT 0)…
CropLand(n,crop,t,m) =L= arableLand(n,crop)*A(n);

Land_arable2(n,crop,t,m)$(Domain(n) and GP(crop,t,m) and kc(crop,m)EQ 0)…
CropLand(n,crop,t,m) =L= 0;

  • Once a certain amount of Cropland is set for a crop, it must remain constant/unchanged for the LGP.

Land_in_time(n,crop,t,m)$(Domain(n) and GP(crop,t,m) and (kc(crop,m)GT 0) and not endMonthLGP(crop,t,m))…
CropLand(n,crop,t+1,m+1)=E= CropLand(n,crop,t,m);



\

Anjuli Jain Figueroa, EIT

MS Technology and Policy
Massachusetts Institute of Technology
ajainf@mit.edu



\

Anjuli Jain Figueroa, EIT

MS Technology and Policy
Massachusetts Institute of Technology
ajainf@mit.edu


To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.