Hello,
I have written the following model, but I have some problem. My problem related to defining sets K_q,a and R_q,a. When I define these sets I get some errors concerning the variable x.
I really need help.

This is my code.

Sets
k /1*25/
q /1*86/
a /1*86/
;
alias(i,k);
Variable
o;
Binary Variables
x(k)
y(a,q,i)
z(q);
Parameters
p
f_ev(q)
d(q)
f_phev(q)
d(q);
p = 3;
$ call gdxxrw Data.xlsx par d rng=edges!A1:B86 rdim=1 cdim=0
$ gdxin Data.gdx
$ load d
$ gdxin
$ call gdxxrw Data.xlsx par f_ev rng=flows!A1:B86 rdim=1 cdim=0
$ gdxin Data.gdx
$ load f_ev
$ gdxin
$ call gdxxrw Data.xlsx par f_phev rng=flows!A1:B86 rdim=1 cdim=0
$ gdxin Data.gdx
$ load f_phev
$ gdxin
Equations
Obj
Const1(a,q,i)
Const2(a,q)
Const3(q)
Const4;
Obj..
o =e= sum(q,f_ev(q)*d(q)*z(q)) + sum((a,q,i),f_phev(q)*d(q)*y(a,q,i));
Const1(a,q,i)..
y(a,q,i) =l= x(i);
Const2(a,q)..
sum(i,y(a,q,i)) =l= 1;
Const3(q)..
z(q) =l= sum(k,x(k));
Const4..
sum(k,x(k)) =e= p;
model CSLM_PHEV /all/;
solve CSLM_PHEV maximizing o using MIP;
display x.l,y.l,z.l,o.l,f_ev,f_phev,d;

Hi
You write: “Please correct my code”, but you give no indication of where there is a problem (the code is correct). You should point to where you have a problem. Don’t expect people to guess your problem or compare your complete model to a picture with the equations.
Cheers
Renger
PS. Code should be inserted using the button </> not the icon with the inverted commas.