Error 149, Uncontrolled set entered as constant

Problems with modeling
Post Reply
sachinpatel_03
User
User
Posts: 3
Joined: 1 month ago

Error 149, Uncontrolled set entered as constant

Post by sachinpatel_03 » 3 weeks ago

hi,

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 /1*80/
t(*) set of time periods (168 elements)
scn /1*99/;

load s,t,scn;

variables
Profit, OF,.......;

Parameters
Time, Econcost(t,scn), Price(s),......;

Equations

Profit_eq, OF_eq;

Profit_eq.. PROFIT =E= TIME*PRICE(s) - TIME*sum(t,PCON(t)*ECONCOST(t,scn)); :roll:
OF_eq.. OF=E=PROFIT*(1-MODE);


please help. how to encode the logic into the program? profit equation is the line where I'm getting the error 149 at the parameter econcost.

cbhomia
User
User
Posts: 4
Joined: 2 months ago

Re: Error 149, Uncontrolled set entered as constant

Post by cbhomia » 3 weeks ago

Sachin,

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.

Profit_eq.. PROFIT =E= TIME*PRICE(s) - TIME*sum(t,PCON(t)*ECONCOST(t,scn));

you need to sum it over both t and scn. The equation should look like this

Profit_eq.. PROFIT =E= TIME*PRICE(s) - TIME*sum((t,scn),PCON(t)*ECONCOST(t,scn));

This will remove the error 149. Hope this helps.

-Chintan

sachinpatel_03
User
User
Posts: 3
Joined: 1 month ago

Re: Error 149, Uncontrolled set entered as constant

Post by sachinpatel_03 » 3 weeks ago

Hello Chintan,

yes, it removed the error but I'm still stuck with the loop. As I want to do it for the scn (one increment at a time).


for looping I'm doing like....

Model test /all/;

OPTION MIP = CPLEX;
OPTION optcr=1;
OPTION limrow=0;
OPTION reslim=72000;

Solve test using MIP maximizing OF;

FILE Results /test_results.xls/;
PUT Results;
Results.pc = 6;
Results.pw = 32767;

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',(TIME*sum(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.

cbhomia
User
User
Posts: 4
Joined: 2 months ago

Re: Error 149, Uncontrolled set entered as constant

Post by cbhomia » 19 hours ago

Hello Sachin,

Quick question : were you able to run the model for just 1 instance ?

Post Reply