|
From: | Marc Goetschalckx |
Subject: | Re: [Help-glpk] Different constraint for first element of a set than for other elements |
Date: | Tue, 02 Feb 2010 14:28:33 -0500 |
User-agent: | Thunderbird 2.0.0.23 (Windows/20090812) |
Following are the two constraints: subject to Supply_Capacity {i in SUPPLIERS, t in OTHER_PERIODS}: purchase [i,t] <= capacity [i,t] + inventory [i,t-1] - inventory [i,t] ; subject to Supply_Capacity_Initial {i in SUPPLIERS, t in INITIAL_PERIOD}: purchase [i,t] <= capacity [i,t] + initial_inventory [i] - inventory[i,t]; Is there a function, similar to card() that returns the first element of a set? I did not see different constraints for the first period and the other ones in your answer, all constraints are over the full set of months? Noli Sicad wrote: Hi Marc, Could you show us the constraint that make this error as well as the data sets for these 3 sets so we can fix it. Anyway, here is example how to this period in months: ~~~~~~~~~~ set MONTHS; param Land_Coef{m in MONTHS, i in CROP}; param Forest_Coef{m in MONTHS,j in FORCROP}; var Land{i in CROP}; # constraint #subject to LandAllocation(Months): Crop - ForestCrop <= TotalArea subject to LandAllo{m in MONTHS}: sum{i in CROP} Land_Coef[m,i] * Land[i] - sum{j in FORCROP} Forest_Coef[m,j] * LandForest[j] <= TotalArea; data; set MONTHS:= Jan Feb Mar Apr May Jun Jul Aug Sept Oct Nov Dec; ~~~~~~~~~~ Regards, Noli On 2/2/10, Marc Goetschalckx <address@hidden> wrote:The model has a different constraint for the first element of a set (say PERIODS) than for all remaining elements. I have defined three sets: INITIAL_PERIOD; OTHER_PERIODS; PERIODS := INITIAL_PERIOD union OTHER_PERIODS; when MathProg is generating the model and specifically constraints over the PERIODS set it terminates with the following error cannot convert JAN to floating-point number where JAN is the first period in OTHER_PERIODS How should the model be written in MathProg to allow different constraints for the first element. Thanks |
[Prev in Thread] | Current Thread | [Next in Thread] |