Hello, I built a model in GAMS which relies on a recursive relationship, ie:
But I'm having trouble compiling it. I've defined t as follows:
and the equations are here:
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:
What am I doing wrong here? Thanks in advance 
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 ♦ 
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 ♦ 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

answered 21 Dec '11, 17:11 yoni162 
answered 22 Dec '11, 05:08 yoni162 
 Job model 22.12.gms Start 12/22/11 13:05:30 WINVS8 23.7.3 x86/MS Windows *** 12 Integer +INF Bounds have been reset to 100  model 22.12.gms(63) 4 MbDicopt Jul 14, 2011 23.7.3 WIN 27723.27726 VS8 x86/MS Windows  DICOPT: No nonlinearities found: executing the MIP solver
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 nonzero 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(t1)+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(t1)+P(t)+alpha*(RI(t1)+R(t)) =g= D(t); ESR(t).. SR(t) =l= RC(t1)+theta*RU(t)+PU(t); NewInventory(t).. PI(t) =e= PI(t1)+P(t)+PU(t); RegroundInventory(t).. RI(t) =e= RI(t1)+R(t)RU(t); RegroundReserve(t).. RC(t) =e= RC(t1)+PU(t)+theta*RU(t)SR(t); SentRelation(t).. R(t) =e= SR(t2); Model lehavim /all/ ; solve lehavim using minlp minimizing z ; display SR.l, P.l ; answered 22 Dec '11, 06:12 yoni162 