I want to use values of a 2D parameter by applying a loop in such a way that for every run of the loop, the values of only one set is changing while the value of other set is constant during a single run and changes with an increment of 1 when the loop starts again. eg. in a [168X99] matrix the model is reading values from every column until 99 runs of the loop which mean my DATA is a [168X99] matrix but for every run the data i want to use is [168Xi] where i=1,2,3,4,…,99

my code is like>

sets
s /180/
t() set of time periods (168 elements)
scn /1*99/;

I don’t think the error has anything to do with your logic, which was difficult to understand to begin with.
But, the fix of your error is simple. In the profit equation, you have the set scn, which is not controlled.

PUT ‘test’//;
PUT ‘CPU(s)’,‘nequations’,‘single var’,‘bin var’,‘model status’,‘solver status’/;

if(MODE = 1,
PUT ‘OF =’,‘ECONS’//;
else
PUT ‘OF =’,‘PROFIT’//;
); Loop(scn$(ord(scn)=3),
PUT ‘Profit’,PROFIT.l,‘[€]’/;
PUT ‘Sales’,(sum((s,t)$(FP(s)),TIME*F.l(s,t)PRICE(s))),‘[€]’/;
PUT ‘E cost’,(TIMEsum(t,PCON(t)*ECONCOST(t,scn)+(sum(i,UTCONS.l(i,‘EE’,t))-PCON(t))*ECOST(t))),‘[€]’/;
…
…
…
)
;

in the line where loop statement starts, I’m trying to reproduce the result of a previously optimized case but I’m not getting the same result. my profit is even coming in negative and by the logic of if statement(just over loop statement) if the profit is in a negative(loss) it should give ECONS.

so, I’m a little confused here that what’s happening.

Thanks for checking it up.
The code is running but I’m not able to reproduce the result.

Basically I’d say my code is still not working as whatever changes I’m making into loop with $ conditions and if statements the code is giving me the same output every time which is different from the actual output previously obtained from a deterministic scenario.

So code is running but I dont know for which instance…

I’m not sure I understand what you are trying to do, but it seems like you want to run a model for a number of different scenarios in the set scn. For each element of scn you will have some different inputs and you’ll get (potentially) a different solution. But each solve considers only a single scenario. Is this correct?

If so, have a look at the trnsgrid model from the GAMS Model Library. This illustrates the idea behind formulating such a model: don’t use the scenario index in the model itself, but loop over the scenarios, setting the input data , solving, and saving the solution each trip through the loop.

The trnsgrid also illustrates how to use a grid solver, which might be extra complication since it doesn’t directly address your question. The paperco model in GAMSLIB is simpler so you might want to look at that instead.

Yes, you understood my problem completely and perfectly. I’ll take a look at the example in gamslib and will post the progress here for your acknowledgement.