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
$LOAD i j
parameters OM(j,i) operating and maintenence cost of alternative i at stage j
price(j,i);
$LOAD OM price
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;
wrong solution
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
Fred
-
- User
- Posts: 29
- Joined: 5 years ago
Re: wrong solution
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?anaskhan wrote: ↑3 years 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
$LOAD i j
parameters OM(j,i) operating and maintenence cost of alternative i at stage j
price(j,i);
$LOAD OM price
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;
Maybe, it should be like;
Code: Select all
c1(i).. sum(j, y(j,i))=l=1;
Code: Select all
c1(j).. sum(i, y(j,i))=l=1;
Regards,
-
- User
- Posts: 13
- Joined: 6 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;
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;