I want to implement a look up table from which variable ‘C’ will pick a value for parameter ‘nr’.
Thanks,
Al-Amin
On Monday, March 14, 2016 at 2:44:18 AM UTC-5, Claudio Delpino wrote:
Al-Amin:
What do you want to look up, where and when (to what end) ?
Regards
Claudio
On Sat, Mar 12, 2016 at 4:40 AM, Al - Amin wrote:
Thank you for your explanation. I have another question. Is there any way to use ‘lookup’ function in GAMS?
-Al-Amin
On Friday, March 11, 2016 at 7:03:36 AM UTC-6, Claudio Delpino wrote:
Al-Amin:
“But the program does not update nr(i,‘year1’) based on C(i,‘year1’)…”
Like I told you before, you have some misconceptions as to what is the difference between symbol types (parameters and variables). This is a basic concept of modelling.
Briefly:
Parameters are CONSTANT in a given model solve
-on the other hand-
Variables are CHANGED by the solver in a given model solve. They have an initial value (level in GAMS-speech) and when the solver finishes running, they will have a final value.
“and also the program uses 0 instead of C.l(i,‘year1’).”:
That is because C.l(i,‘year1’), if not particularly specified IS 0. Check out the attached file of my prior mail.
From what you say, I get that your formulation works on a past one, but in yours, it appears that you need either nr to be a variable, or C to be a parameter.
-very important-:
ALL Variables and ALL Equations are manipulated by the solver at the same time.
The idea that the solver “calculates” a variable from a certain equation is a very common misconception. This only happens in certain solver-solver options-model structures combinations.
Regards!
Claudio
On Thu, Mar 10, 2016 at 5:37 PM, Al - Amin wrote:
Hi Claudio,
Thank you for your suggestions. Let me explain what I want to with the following equation:
C(i,t)=e= C(i,t-1)(1-nr(i,t-1))+sum (m1, x(i,t,m1)e(i,m1))+sum(m2,x(i,t,m2)(100-(C.l(i,t-1)(1-nr(i,t-1)))));
- I need C (i, t) values for each time period t. C(i,t) needs to to be calculated from previous years value that is C(i,t-1). Also C(i,t) depends on the parameter nr(i,t-1). This parameter is dependent on C(i,t-1) values like for C(i,t-1) = 96 nr(i,t-1) should be 0.05, when C(i,t-1) = 58 nr(i,t-1) should be 0.16. Now, I know the values for C at the beginning of analyses periods that is C(i, ‘year0’). With these values the program can compute the parameter nr(i,‘year0’) and compute the C(i,‘year1’) that is
C(i,‘year1’)=e= C(i,‘year0’)(1-nr(i,‘year0’))+sum (m1, x(i,t,m1)e(i,m1))+sum(m2,x(i,t,m2)(100-(C.l(i,‘year0’)(1-nr(i,‘year0’)))));
until year 1 the program computes C correctly. But after year 1, the program does not able to correctly use the previous year’s values to compute current years’s C. for example,for t= ‘year2’:
C(i,‘year2’)=e= C(i,'year1)(1-nr(i,‘year1’))+sum (m1, x(i,t,m1)e(i,m1))+sum(m2,x(i,t,m2)(100-(C.l(i,'year1)(1-nr(i,‘year1’)))));
The program uses C(i,‘year1’) in the first part of the equation (before the first ‘sum’ notation). But the program does not update nr(i,‘year1’) based on C(i,‘year1’), and also the program uses 0 instead of C.l(i,‘year1’). So, the program only calculates for year 1 correctly. But I need to calculate the equation for all the time period correctly.
For the convenience, x(i,t,m1) and x(i,t,m2) are binary variables which determine when an specific action needs to be taken place on a component ‘i’. m1 and m2 represents the set of actions. Actions are divided into two sets because, when program selects an action from set m2, the program must set C(i,t) = 100.
Please let me know if you can help me to overcome the problem. Please let me know if you have difficulty in understanding my problem.
Thanks,
Al-Amin
On Thursday, March 10, 2016 at 6:56:02 AM UTC-6, Claudio Delpino wrote:
Sorry: I had a misconception of my own. Variables aren’t initialized at the lower bound (I got mixed with some solvers behaviour).
If any member of C is set to a level or a bound, then the rest is set to zero.
You can use the attached file to experiment.
On Thu, Mar 10, 2016 at 9:43 AM, Claudio Delpino wrote:
Al-Amin:
From reading this sentence: “where C(i,t) is a variable which is imputed using the following constraint equation:”
I can guess that you don’t have a correct picture of which role parameters, constraints and variables play in a GAMS model. My sincere suggestion is that you try to understand that better, and your “problem” will most likely become clear.
“my problem is the model can calculate the parameter and equation for year 0”: a model SOLVE doesn’t calculate parameters, and will always have an output level for each variable involved.
“for the following years the models assumes all C(i,t) values as zero”: if C(i,t) is a variable, a SOLVE of the model will take it from its current (starting) level to a certain level (value). Which value that is, is dependent on several things.
From your text I understand that parameter nr(i,t) is intended to be calculated as a “result” symbol (parameter), but it also appears in the model.
So, my first question is: does this code go after or before the solve ?
parameter nr(i,t);
nr(i,t)(C.l(i,t)>94.9)=0.005;
nr(i,t)(59.9 wrote:
Hi,
In my model I need to calculate a parameter based on a variable value which calculated when model is solved.
C.l(i,‘year0’)=Co(i);
parameter nr(i,t);
nr(i,t)(C.l(i,t)>94.9)=0.005;
nr(i,t)(59.9<C.l(i,t)and C.l(i,t)<94.9) =0.07;
nr(i,t)(19.9< C.l(i,t)and C.l(i,t)<59.9) =0.16;
nr(i,t)(C.l(i,t)<19.9) =0.08;
where C(i,t) is a variable which is imputed using the following constraint equation:
C(i,t)=e= C(i,t-1)(1-nr(i,t-1))+sum (m1, x(i,t,m1)e(i,m1))+sum(m2,x(i,t,m2)(100-(C.l(i,t-1)(1-nr(i,t-1)))));
where t is the year and I know C(i, ‘year0’) values only. Now my problem is the model can calculate the parameter and equation for year 0. but for the following years the models assumes all C(i,t) values as zero and calculate the parameter and equation based on the zero value. How can I get resolve this issue. My model is MIP.
I would greatly appreciate any help about my problem.
Thanks,
Al-Amin
PhD Student, UT Austin
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 https://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.