# recursive equations in GAMS

 1 Hello, I built a model in GAMS which relies on a recursive relationship, ie: Inventory(t)=Inventory(t-1)+...  But I'm having trouble compiling it. I've defined t as follows: Sets t time / t1 * t5 /;  and the equations are here: Equations cost define objective functionz EDI(t) satisfying demand at period t ESR(t) upper bound for tools sent for regrinding during period t; cost.. z =e= sum(t, CPI*PI(t)+CRI*RI(t)+CP*P(t)+CR*SR(t)); EDI(t).. D(t) =l= PI(t-1)+P(t)+alpha*(RI(t-1)+R(t)); ESR(t).. SR(t) =l= RC(t-1)+theta*RU(t)+PU(t);  All the parameters are defined previously, and initialized as 0 so that for example, PI(0) (which we will encounter when t=t1). I'm getting an error message when trying to run the program: **** we could not write the default gamsnext file RC=13 **** Msg=Permission denied **** Name=|225agamsnext.cmd| **** TERMINATED DUE TO ERRORS IN INIT-NEXT **** PLEASE REPORT TO THE GAMS ADMINISTRATOR  What am I doing wrong here? Thanks in advance asked 21 Dec '11, 15:12 yoni162 32●2●7 accept rate: 0% fbahr ♦ 4.6k●7●16

 2 The problem does not seem to be the recursion but the line "permission denied". GAMS puts some temporary files on disk to ensure its proper execution. These files are written to the "current" directory. This directory may not be clear, in particular when you run GAMS from a graphical front end. Try setting the "current" directory to a directory where you have write permissions, either your project directory, or some TEMP directory. Actually, I do not know how to do this, but I believe that this should be a first step. answered 21 Dec '11, 16:21 Marco Luebbecke ♦ 3.4k●1●6●15 accept rate: 16%
 1 Your model is integer infeasible. I checked its linear programming relaxation (with no objective function as it seems the model lacks necessary variable declaration), it's infeasible as well. Based on the CPLEX report, the infeasibility is due to D(3) and if you drop it, the model would be feasible. I checked it and any value other than zero for D(3) makes the model infeasible. It seems your constraints are in conflict. In order to solve this problem, I suggest you find a feasible solution to your problem manually and then check it either manually or by GAMS to find the constraints not working or in conflict. You could also check textbooks and papers to check your model (your model seems to be similar to standard production planning models). By the way, your model is completely linear. So, don't declare it as MINLP, but as MIP. answered 22 Dec '11, 07:15 Ehsan ♦ 4.8k●3●12●24 accept rate: 16% You were right, there was an error in the equations.. Also, I guess I didn't fully understand the meaning of "Parameters"..they were supposed to be variables as well (some of them). Anyway, it works now, so thanks a lot for your patience and willing to help! (22 Dec '11, 09:37) yoni162
 0 Hi, I realized the error message I was getting didn't have much to do with the model itself..anyway, it fixed it (running GAMS in XP compatibility mode). Now the error messages that I'm getting are: 143 - suffix is missing 141 - Symbol neither initialized or assigned. I'm noticing this only happens with the variables I've defined - P(t) & SR(t). How can I get around that? 1 Sets 2 t time / t0 * t5 /; 3 4 Variables 5 SR(t) amount of tools sent for regrinding during period t 6 P(t) amount of new tools added to inventory at beginning of period t 7 z total operation cost ; 8 9 Integer variable SR; 10 Integer variable P; 11 12 Parameters 13 D(t) Demand for new tools in period t /t0 0, t1 10, t2 0, t3 5, t4 0, t5 0 / 14 15 CP cost of one new tool /10/ 16 CR cost of one reground tool /4/ 17 CPI holding cost per one new tool /1/ 18 CRI holding cost per one reground tool /1/ 19 alpha reground tool life as percentage of new tool life /0.8/ 20 theta proportion of reground tools available for regrinding /0.6667/ 21 22 PI(t) 23 RI(t) 24 PU(t) 25 RU(t) 26 R(t) 27 RC(t) ; 28 29 PI(t) = 0; 30 RI(t) = 0; 31 RU(t) = 0; 32 RC(t) = 0; 33 R(t) = 0; 34 35 PI(t) = PI(t-1)+P(t)+PU(t) ; **** $143,141,141 36 RI(t) = RI(t-1)+R(t)-RU(t); 37 PU(t) = D(t)-alpha*RU(t); 38 RU(t) = min(RI(t-1)+R(t), D(t)/alpha); 39 RC(t) = RC(t-1)+PU(t)+theta*RU(t)-SR(t); ****$143,141 40 R(t) = SR(t-2); **** \$143  answered 21 Dec '11, 17:11 yoni162 32●2●7 accept rate: 0%
 0  OK the issue is resolved. The problem was with using the variables in the PARAMETER  block instead of in the EQUATIONS block. It compiles now, although I'm getting an "**Infeasible column 'P(t1)'**" message..  answered 22 Dec '11, 05:08 yoni162 32●2●7 accept rate: 0% 1 @yoni162: It would be easier to help you if you could post the complete solution process log or parts of it with more information. (22 Dec '11, 05:28) Ehsan ♦
**OK, here is the log:**


--- Job model 22.12.gms Start 12/22/11 13:05:30 WIN-VS8 23.7.3 x86/MS Windows
GAMS Rev 237 Copyright (C) 1987-2011 GAMS Development. All rights reserved Licensee: GAMS Development Corporation, Washington, DC G871201/0000CA-ANY Free Demo, 202-342-0180, sales@gams.com, www.gams.com DC0000 --- Starting compilation --- model 22.12.gms(64) 3 Mb --- Starting execution: elapsed 0:00:00.017 --- model 22.12.gms(36) 4 Mb --- Generating MINLP model lehavim --- model 22.12.gms(63) 6 Mb --- 29 rows 13 columns 41 non-zeroes --- 0 nl-code 0 nl-non-zeroes --- 12 discrete-columns

*** 12 Integer +INF Bounds have been reset to 100

## --- model 22.12.gms(63) 4 Mb

Dicopt Jul 14, 2011 23.7.3 WIN 27723.27726 VS8 x86/MS Windows

--- DICOPT: No non-linearities found: executing the MIP solver

  The model is linear (possibly with integer variables).
We will call the MIP solver to solve it for you.

Advice: use a MIP solver to solve this problem.


IBM ILOG CPLEX Jul 14, 2011 23.7.3 WIN 27723.27726 VS8 x86/MS Windows Cplex 12.3.0.0

Reading data... Starting Cplex... Infeasible column 'P(t3)'. Presolve time = 0.00 sec. MIP status(119): integer infeasible or unbounded CPLEX Error 1217: No solution exists. Problem is integer infeasible. --- Restarting execution --- model 22.12.gms(63) 0 Mb --- Reading solution for model lehavim --- Executing after solve: elapsed 0:00:00.492 --- model 22.12.gms(64) 3 Mb *** Status: Normal completion --- Job model 22.12.gms Stop 12/22/11 13:05:30 elapsed 0:00:00.497

If you look at the model code here, you'll see that the error message "Infeasible column 'P(t3)'." corresponds with the first non-zero value of the parameter D(t).

Sets t time / t0 * t5 /;

Variables SR(t) amount of tools sent for regrinding during period t P(t) amount of new tools added to inventory at beginning of period t z total operation cost ;

Integer variable SR; Integer variable P;

Parameters D(t) Demand for new tools in period t /t0 0, t1 0, t2 0, t3 10, t4 0, t5 0/

CP cost of one new tool /10/ CR cost of one reground tool /4/ CPI holding cost per one new tool /1/ CRI holding cost per one reground tool /1/ alpha reground tool life as percentage of new tool life /0.8/ theta proportion of reground tools available for regrinding /0.6667/

PI(t) RI(t) PU(t) RU(t) R(t) RC(t) ;

PI(t) = 0; RI(t) = 0; RU(t) = 0; RC(t) = 0; R(t) = 0;

PU(t) = D(t)-alpha*RU(t); RU(t) = min(RI(t-1)+R(t), D(t)/alpha);

Equations cost define objective functionz EDI(t) satisfying demand at period t ESR(t) upper bound for tools sent for regrinding during period t NewInventory(t) RegroundInventory(t) RegroundReserve(t) SentRelation(t);

cost.. z =e= sum(t, CPIPI(t)+CRIRI(t)+CPP(t)+CRSR(t));

EDI(t).. PI(t-1)+P(t)+alpha*(RI(t-1)+R(t)) =g= D(t);

ESR(t).. SR(t) =l= RC(t-1)+theta*RU(t)+PU(t);

NewInventory(t).. PI(t) =e= PI(t-1)+P(t)+PU(t);

RegroundInventory(t).. RI(t) =e= RI(t-1)+R(t)-RU(t);

RegroundReserve(t).. RC(t) =e= RC(t-1)+PU(t)+theta*RU(t)-SR(t);

SentRelation(t).. R(t) =e= SR(t-2);

Model lehavim /all/ ; solve lehavim using minlp minimizing z ; display SR.l, P.l ;

yoni162
3227
accept rate: 0%

 toggle preview community wiki

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "Title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported

Tags: