## wrong solution

Problems with modeling
User Posts: 2
Joined: 2 months ago

### wrong solution

Hello !!!
I have modeled this problem and solved this on GAMS but solution I am getting is not correct. Can anyone check my code and tell me where I am wrong...

\$eolcom #
\$title MSW sim1
\$offupper
\$onecho >inputsim1.txt
set=i rng=sets!B3:B4 rDim=1
set=j rng=sets!D3:D6 rDim=1
par=price rng=SP!B3:D7 rDim=1 cDim=1
par=OM rng=omcost!B3:D7 rDim=1 cDim=1
\$offecho
\$CALL GDXXRW.EXE inputsim1.xlsx @inputsim1.txt
\$GDXIN inputsim1.gdx

sets i no of alternatives
j no of stage

parameters OM(j,i) operating and maintenence cost of alternative i at stage j
price(j,i);

binary variables y(j,i) ;

positive variables F(j,i);

Variables z, s, oandm;

Equations profit, sales, OMcost, c1;

profit.. z=e=s-oandm;
sales.. s=e=sum((j,i), price(j,i)*F(j,i));
OMcost.. oandm=e=sum((j,i), y(j,i)*OM(j,i)*F(j,i));
c1.. sum((j,i), y(j,i))=l=1;

model sim1 /all/;
solve sim1 maximize z using minlp;
display y.l, z.l, s.l;

Fred
Posts: 252
Joined: 4 years ago

### Re: wrong solution

How do you know the solution is not correct? I suggest to to share the xlsx file, so other users can run your model.

Fred

dunyayigezerken
User Posts: 29
Joined: 2 years ago

### Re: wrong solution

2 months ago
Hello !!!
I have modeled this problem and solved this on GAMS but solution I am getting is not correct. Can anyone check my code and tell me where I am wrong...

\$eolcom #
\$title MSW sim1
\$offupper
\$onecho >inputsim1.txt
set=i rng=sets!B3:B4 rDim=1
set=j rng=sets!D3:D6 rDim=1
par=price rng=SP!B3:D7 rDim=1 cDim=1
par=OM rng=omcost!B3:D7 rDim=1 cDim=1
\$offecho
\$CALL GDXXRW.EXE inputsim1.xlsx @inputsim1.txt
\$GDXIN inputsim1.gdx

sets i no of alternatives
j no of stage

parameters OM(j,i) operating and maintenence cost of alternative i at stage j
price(j,i);

binary variables y(j,i) ;

positive variables F(j,i);

Variables z, s, oandm;

Equations profit, sales, OMcost, c1;

profit.. z=e=s-oandm;
sales.. s=e=sum((j,i), price(j,i)*F(j,i));
OMcost.. oandm=e=sum((j,i), y(j,i)*OM(j,i)*F(j,i));
c1.. sum((j,i), y(j,i))=l=1;
model sim1 /all/;
solve sim1 maximize z using minlp;
display y.l, z.l, s.l;
Do you want to y11+y12+y13...+y21+y22+y23+...=l=1 or y11+y12+y13=l=1 or y11+y21+y31=l=1 at c1?

Maybe, it should be like;

Code: Select all

``c1(i).. sum(j, y(j,i))=l=1;``
or

Code: Select all

``c1(j).. sum(i, y(j,i))=l=1;``
Maybe the problem occurs by this constraint? So, my advise is that think about the open form of constraint c1, what it looks like? then get the close form of it. So, you can decide the form of the constraint. If it is already correct, please do not consider my answer.

Regards,

brucemccarl
User Posts: 11
Joined: 3 years ago

### Re: wrong solution

make sure optcr is set to a small number

depending on version you are using it can have a default of 10% meaning it can be off the real solution by 10%

set it to 0.001
option optcr=0.001;