If statement to satisfy a condition

Can someone help me with this: I have a set of crops (rr(i) Key LT crops) that requires chilling units to overcome dormancy. The required chill unit might not be accumulated in the future and I want to be able to plant only crop that satisfy the required chill unit / or only the crops that met the required chill units should enter the crop combination. How do I write this condition in GAMS to say that any crop whose future chill is not upto the threshold should not be planted and any other alternative crop shoud be planted.

I have denoted such crops as: rr(i) Key LT crops / Apples,Pears,Nect,Peach,Plums,Apricots,Wwine /

ch chill unit requirement / present, future, threshold /

pc(ch) present chill unit /present/
fc(ch) future chill unit /future/
tc(ch) threshold chill unit /threshold/

I put a table to show the threshold requirement for each crop:

Table Tchill(rr,tc) crop threshold chill unit

threshold
Apples 1200
Pears 900
Nect 560
Peach 350
Plums 500
Apricots 450
Wwine 500

I also put a table to denoted accumulated chill unit for the planning period:

Table Fchill(ph,fc) crop dormancy chill unit requirement

future
y2046 869
y2047 760
y2048 612
y2049 908
y2050 992
y2051 814
y2052 1038
y2053 603
y2054 778
y2055 664
y2056 967
y2057 815
y2058 1051
y2059 823
y2060 692
y2061 730
y2062 689
y2063 697
y2064 980
y2065 1036


Model below…
Sets
c All enterprises / Apples,Pears,Nect,Peach,Plums,Apricots,Wwine,Lucern,LTPast,Oats,
Potatoes,Tomatoes,Onions,Cabbage,Cauliflw,Carrots,Peas,Pumpkin,Squash,Butternuts,
Lettuce,Spinach,Beetr,Sweetmel,Wheat,Maize,Barley,Korog
/
i(c) All crops / Apples,Pears,Nect,Peach,Plums,Apricots,Wwine,Lucern,LTPast,Oats,
Potatoes,Tomatoes,Onions,Cabbage,Cauliflw,Carrots,Peas,Pumpkin,Squash,Butternuts,
Lettuce,Spinach,Beetr,Sweetmel,Wheat,Maize,Barley,Korog
/
stc(i) All short / Oats,Potatoes,Tomatoes,Onions,Cabbage,Cauliflw,Carrots,Peas,Pumpkin,Squash,Butternuts,
Lettuce,Spinach,Beetr,Sweetmel,Wheat,Maize,Barley,Korog
/
StO(i) Short exc veg / Oats, Wheat,Maize,Barley,Korog
/
v(i) All vegetables / Potatoes,Tomatoes,Onions,Cabbage,Cauliflw,Carrots,Peas,Pumpkin,Squash,Butternuts,
Lettuce,Spinach,Beetr,Sweetmel
/
past(i) All pastures / Lucern,LTPast /
Epast(i) All LT excl past / Apples,Pears,Nect,Peach,Plums,Apricots,Wwine /
VegA(i) Mainstream veg / Potatoes,Tomatoes,Onions,Cabbage /
VegB(i) Rankgewasse /Peas, Pumpkin,Squash,Butternuts /
VegC(i) All other veg / Cauliflw,Carrots,Lettuce,Spinach,Beetr,Sweetmel /
r(i) All oth LT crops / Apples,Pears,Nect,Peach,Plums,Apricots,Wwine,Lucern,LTPast
/
rr(i) Key LT crops / Apples,Pears,Nect,Peach,Plums,Apricots,Wwine /
rtest(i) Toets set / Apples,Pears, Potatoes,Tomatoes,Onions,Wheat,Maize,Barley
/
k(i) All irr crops / Apples,Pears,Nect,Peach,Plums,Apricots,Wwine,Lucern,LTPast,Oats,
Potatoes,Tomatoes,Onions,Cabbage,Cauliflw,Carrots,Peas,Pumpkin,Squash,Butternuts,
Lettuce,Spinach,Beetr,Sweetmel,Wheat,Maize,Barley,Korog
/
d(i) All dryland crops / Wheat,Barley,Korog /

l Landtypes / Irrig, Dryland
/
*SITES ALL SITES /C1,C2,C3,C4,C5,C6,C7,C8,C9, C10, C11,C12,C13,C14,C15,C16,C17,C18,C19,C20,C21,C22,

  •                KD1, kd2,kd3,kd4,kd5,kd6,kd7,kd8,kd9,kd10,kd11,kc1,kc2,kc3,
    
  •                Koekdam, URB1, Agric /
    

SITES ALL SITES /C1,C2,KD1, kd2,kd3,kd4,kd5,kd6,kd7,kd8,kd9,kd10,kd11,kc1,kc2,kc3,
Koekdam, URB1, Agric /
Usite(Sites) Urban sites / URB1 /
UA(Sites) Urban and Agric sites / URB1, Agric /
AS(Sites) Agric sites / Agric /
Dams(SITES) Main Storage / KoekDam /
ROS(SITES) / C1,C2,C3,C4,C5,C6,C7,C8,C9, C10, C11,C12,C13,C14,C15,C16,C17,C18,C19,C20,C21,C22 /
ROS(SITES) / C1,C2 /
j(Sites) Water users / KD1, kd2,kd3,kd4,kd5,kd6,kd7,kd8,kd9,kd10,kd11,kc1,kc2,kc3, Urb1 /
b(j) Irrigation users / KD1, kd2,kd3,kd4,kd5,kd6,kd7,kd8,kd9,kd10,kd11,kc1,kc2,kc3 /
Ea(b) Existing irrig areas / KD1, kd2,kd3,kd4,kd5,kd6,kd7,kd8,kd9,kd10,kd11,kc1,kc2,kc3
/
Eme(b) Emerging farmers / KD1, kd2,kd3,kd4,kd5,kd6,kd7,kd8,kd9,kd10,kd11 /
Cf(b) Commercial farmers / kc1,kc2,kc3 /
FirstFarm(Ea) First Farm
LastFarm(Ea) Last Farm
u(j) Urban users / Urb1 /
g Urban sectors / Ihh /
FW(g) DEMAND SECTORS RECEIVING FREE WAT /IHH /
p Crop products / Markets /
sa Savings / Invest
/
Lo Debt / Stloan /
of Overheadfactors / Vegies, LTcrops, Drcrops /
gsl Growth stage / g01
g40 /
Base******************
Th Total time serie / Y1942Y1990 /
ph(th) Planning horizon / Y1971Y1990 /
py(th) Previous years / Y1951Y1970 /
PyE(Th) Extended Prev years / y1942y1970 /
future***************
Th Total time serie / Y2017Y2065 /
ph(th) Planning horizon / Y2046
Y2065 /
py(th) Previous years / Y2026Y2045 /
PyE(Th) Extended Prev years / y2017
y2045 /

FirstYr(ph) First Year
LastYr(ph) Last Year
m Months / Jan, Febr, March, April, May,
June, July, Aug, Sept, Oct,
Nov, Dec
/
wwm(m) Winter months / April, May, June, July, Aug, Sept /
swm(m) Summer months / Oct, Nov, Dec, Jan, Febr, March /
FirstMo(m) First Month
LastMo(m) Last Month
q Water sources / KkdouwS, KkdouwW, WarmBW, Boreh
/
ww(q) Winter water / KkdouwW, WarmBW, Boreh
/
kw(q) Koekedouw water / KkdouwS, KkdouwW
/
ow(q) All other sources / WarmBW, Boreh
/
wp(q) Pump water schemes / Boreh
/
fd Farm dams / FDams/

Some variables

cr(c,h,b,th) Area of crop i grown on typical farm b t on landtype l
Totarea(i,j,ph) Total longterm crop area in a specific year
TcropA(i,h,b,th) Total crop area for Koekedouw
TLTopp(i,b,ph) Total crop area for Koekdouw in any given year for all irrigation tech
TotvegA(b,ph) Total area of all vegetables
TFCP(c,p,b,ph) Typical farm b t annual production volume of crop i
TCP(i,p,ph) Total region production volume of crop i
CS(i,p,b,ph) Sell cash crops
TCS(i,p,b,ph) Total crop sales volume for Koekedouw
OC(b,ph) Overhead costs for typical farm b
HC(b,ph) Household costs for typical farm b
Owncap(b,ph) Own capital contribution
TOTFAW(b,ph) Total annual water demand for typical farm b t
TFMW(b,m,ph) Typical farm monthly water demand


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.

\

Hello Abiodun,

I see the chill unit changes per year, does it change according to a pre-defined path (or: are they calculated before the optimization part)?
If your chill unit depends on other variables (e.g. crops previously assigned), then using constraints works better. As I don’t know how the capacity of such chill units can be distributed (or if it is still a threshold), I can’t help you with that.
However, if it does, the easiest way is using a map, which only contains crops that do meet the chill unit in each year. (see the manual, search for: mapping)

If I define a set of years y, crops c and map(y,c), parameters chill(c), chill requirement of crop c, and chill_thres(y) chill unit treshold in a specific year, it’ll look something like this:
map(y,c)=yes$(chill_thres(y)-chill(c)>=0)

I hope your question is now completely or partly answered. If neither, please indicate which part is clearly overlooked by me, so other could help.

regards,
Henry Vermue

On Tuesday, January 29, 2013 1:37:49 PM UTC+1, Abiodun Ogundeji wrote:

Can someone help me with this: I have a set of crops (rr(i) Key LT crops) that requires chilling units to overcome dormancy. The required chill unit might not be accumulated in the future and I want to be able to plant only crop that satisfy the required chill unit / or only the crops that met the required chill units should enter the crop combination. How do I write this condition in GAMS to say that any crop whose future chill is not upto the threshold should not be planted and any other alternative crop shoud be planted.


I have denoted such crops as: rr(i) Key LT crops / Apples,Pears,Nect,Peach,Plums,Apricots,Wwine /

ch chill unit requirement / present, future, threshold /

pc(ch) present chill unit /present/
fc(ch) future chill unit /future/
tc(ch) threshold chill unit /threshold/

I put a table to show the threshold requirement for each crop:

Table Tchill(rr,tc) crop threshold chill unit

threshold
Apples 1200
Pears 900
Nect 560
Peach 350
Plums 500
Apricots 450
Wwine 500

I also put a table to denoted accumulated chill unit for the planning period:

Table Fchill(ph,fc) crop dormancy chill unit requirement

future
y2046 869
y2047 760
y2048 612
y2049 908
y2050 992
y2051 814
y2052 1038
y2053 603
y2054 778
y2055 664
y2056 967
y2057 815
y2058 1051
y2059 823
y2060 692
y2061 730
y2062 689
y2063 697
y2064 980
y2065 1036


Model below…
Sets
c All enterprises / Apples,Pears,Nect,Peach,Plums,Apricots,Wwine,Lucern,LTPast,Oats,
Potatoes,Tomatoes,Onions,Cabbage,Cauliflw,Carrots,Peas,Pumpkin,Squash,Butternuts,
Lettuce,Spinach,Beetr,Sweetmel,Wheat,Maize,Barley,Korog
/
i(c) All crops / Apples,Pears,Nect,Peach,Plums,Apricots,Wwine,Lucern,LTPast,Oats,
Potatoes,Tomatoes,Onions,Cabbage,Cauliflw,Carrots,Peas,Pumpkin,Squash,Butternuts,
Lettuce,Spinach,Beetr,Sweetmel,Wheat,Maize,Barley,Korog
/
stc(i) All short / Oats,Potatoes,Tomatoes,Onions,Cabbage,Cauliflw,Carrots,Peas,Pumpkin,Squash,Butternuts,
Lettuce,Spinach,Beetr,Sweetmel,Wheat,Maize,Barley,Korog
/
StO(i) Short exc veg / Oats, Wheat,Maize,Barley,Korog
/
v(i) All vegetables / Potatoes,Tomatoes,Onions,Cabbage,Cauliflw,Carrots,Peas,Pumpkin,Squash,Butternuts,
Lettuce,Spinach,Beetr,Sweetmel
/
past(i) All pastures / Lucern,LTPast /
Epast(i) All LT excl past / Apples,Pears,Nect,Peach,Plums,Apricots,Wwine /
VegA(i) Mainstream veg / Potatoes,Tomatoes,Onions,Cabbage /
VegB(i) Rankgewasse /Peas, Pumpkin,Squash,Butternuts /
VegC(i) All other veg / Cauliflw,Carrots,Lettuce,Spinach,Beetr,Sweetmel /
r(i) All oth LT crops / Apples,Pears,Nect,Peach,Plums,Apricots,Wwine,Lucern,LTPast
/
rr(i) Key LT crops / Apples,Pears,Nect,Peach,Plums,Apricots,Wwine /
rtest(i) Toets set / Apples,Pears, Potatoes,Tomatoes,Onions,Wheat,Maize,Barley
/
k(i) All irr crops / Apples,Pears,Nect,Peach,Plums,Apricots,Wwine,Lucern,LTPast,Oats,
Potatoes,Tomatoes,Onions,Cabbage,Cauliflw,Carrots,Peas,Pumpkin,Squash,Butternuts,
Lettuce,Spinach,Beetr,Sweetmel,Wheat,Maize,Barley,Korog
/
d(i) All dryland crops / Wheat,Barley,Korog /

l Landtypes / Irrig, Dryland
/
*SITES ALL SITES /C1,C2,C3,C4,C5,C6,C7,C8,C9, C10, C11,C12,C13,C14,C15,C16,C17,C18,C19,C20,C21,C22,

  •                KD1, kd2,kd3,kd4,kd5,kd6,kd7,kd8,kd9,kd10,kd11,kc1,kc2,kc3,
    
  •                Koekdam, URB1, Agric /
    

SITES ALL SITES /C1,C2,KD1, kd2,kd3,kd4,kd5,kd6,kd7,kd8,kd9,kd10,kd11,kc1,kc2,kc3,
Koekdam, URB1, Agric /
Usite(Sites) Urban sites / URB1 /
UA(Sites) Urban and Agric sites / URB1, Agric /
AS(Sites) Agric sites / Agric /
Dams(SITES) Main Storage / KoekDam /
ROS(SITES) / C1,C2,C3,C4,C5,C6,C7,C8,C9, C10, C11,C12,C13,C14,C15,C16,C17,C18,C19,C20,C21,C22 /
ROS(SITES) / C1,C2 /
j(Sites) Water users / KD1, kd2,kd3,kd4,kd5,kd6,kd7,kd8,kd9,kd10,kd11,kc1,kc2,kc3, Urb1 /
b(j) Irrigation users / KD1, kd2,kd3,kd4,kd5,kd6,kd7,kd8,kd9,kd10,kd11,kc1,kc2,kc3 /
Ea(b) Existing irrig areas / KD1, kd2,kd3,kd4,kd5,kd6,kd7,kd8,kd9,kd10,kd11,kc1,kc2,kc3
/
Eme(b) Emerging farmers / KD1, kd2,kd3,kd4,kd5,kd6,kd7,kd8,kd9,kd10,kd11 /
Cf(b) Commercial farmers / kc1,kc2,kc3 /
FirstFarm(Ea) First Farm
LastFarm(Ea) Last Farm
u(j) Urban users / Urb1 /
g Urban sectors / Ihh /
FW(g) DEMAND SECTORS RECEIVING FREE WAT /IHH /
p Crop products / Markets /
sa Savings / Invest
/
Lo Debt / Stloan /
of Overheadfactors / Vegies, LTcrops, Drcrops /
gsl Growth stage / g01
g40 /
Base******************
Th Total time serie / Y1942Y1990 /
ph(th) Planning horizon / Y1971Y1990 /
py(th) Previous years / Y1951Y1970 /
PyE(Th) Extended Prev years / y1942y1970 /
future***************
Th Total time serie / Y2017Y2065 /
ph(th) Planning horizon / Y2046
Y2065 /
py(th) Previous years / Y2026Y2045 /
PyE(Th) Extended Prev years / y2017
y2045 /

FirstYr(ph) First Year
LastYr(ph) Last Year
m Months / Jan, Febr, March, April, May,
June, July, Aug, Sept, Oct,
Nov, Dec
/
wwm(m) Winter months / April, May, June, July, Aug, Sept /
swm(m) Summer months / Oct, Nov, Dec, Jan, Febr, March /
FirstMo(m) First Month
LastMo(m) Last Month
q Water sources / KkdouwS, KkdouwW, WarmBW, Boreh
/
ww(q) Winter water / KkdouwW, WarmBW, Boreh
/
kw(q) Koekedouw water / KkdouwS, KkdouwW
/
ow(q) All other sources / WarmBW, Boreh
/
wp(q) Pump water schemes / Boreh
/
fd Farm dams / FDams/

Some variables

cr(c,h,b,th) Area of crop i grown on typical farm b t on landtype l
Totarea(i,j,ph) Total longterm crop area in a specific year
TcropA(i,h,b,th) Total crop area for Koekedouw
TLTopp(i,b,ph) Total crop area for Koekdouw in any given year for all irrigation tech
TotvegA(b,ph) Total area of all vegetables
TFCP(c,p,b,ph) Typical farm b t annual production volume of crop i
TCP(i,p,ph) Total region production volume of crop i
CS(i,p,b,ph) Sell cash crops
TCS(i,p,b,ph) Total crop sales volume for Koekedouw
OC(b,ph) Overhead costs for typical farm b
HC(b,ph) Household costs for typical farm b
Owncap(b,ph) Own capital contribution
TOTFAW(b,ph) Total annual water demand for typical farm b t
TFMW(b,m,ph) Typical farm monthly water demand


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.

\