I am trying to satisfy a demand by different production units which have different capacity constraints, different efficiencies, and different initial purchasing prices. I want to obtain the minimum total cost of the system in a year, and also the number of the most optimal units that I should purchase.
My code as below which gives integer infeasible error:
Option optcr=0.001
Sets
i pumps /i1*i8/
pump(i) /i1*i4/
vscond_recip(i) /i1/
vscond_screw(i) /i2/
fx_recip(i) /i3/
fx_screw(i) /i4/
air(i) /i5*i8/
dvscond_recip(i) /i5/
dvscond_screw(i) /i6/
dfx_recip(i) /i7/
dfx_screw(i) /i8/
t time /t1*t8760/
;
Parameters
pmin(i) minimum generation level (kW) /i1*i4 500, i5*i8 300/
pmax(i) maximum generation level (kW) /i1*i4 1500, i5*i8 1000/
c(i) investment costs ($) /i1 15.000, i2 10.000, i3 13.000, i4 15.000, i5 15.000, i6 15.000, i7 12.000, i8 12.000/
u_init(i) initial online status /i1*i8 0/
*demand is for hourly for a year, 8760 inputs.
d(t) demand /
$ondelim
$include Demand.csv
$offdelim
/
parameter hour(t) "hour of the day from 1 to 24";
parameter p_el(t) "electricity price";
hour(t) = mod(ord(t), 24);
p_el(t) =0.03 ;
p_el(t)$(hour(t) >= 6 and hour(t) <= 18) = 0.08;
p_el(t)$(hour(t) > 18 and hour(t) < 24) = 0.05 ;
*COP is for hourly for a year, 8760 inputs.
table COP(t,i)
$ondelim
$include COP.csv
$offdelim
;
display d,COP;
Scalar
plantlife life time of the plant /20/
irate interest rate /0.05/ ;
Variables
u(i,t) online status
v(i) investment "number of investments for the respective unit(s)"
p(i,t) production level
z total costs
;
free variable
z
;
Positive variable
p
v;
binary variables
u ;
Equations
costs total costs
Mingen(i,t) minimum generation
Maxgen(i,t) maximum generation
Demand(t) demand
investment(i,t) investment
;
Mingen(i,t) .. p(i,t)=g=pmin(i)*u(i,t);
Maxgen(i,t) .. p(i,t)=l=pmax(i)*u(i,t);
costs.. z=e=sum( (i,t), p_el(t)*(d(t)/COP(t,i)) )+sum(i,v(i)*(c(i)/(1-((1+irate)**(plantlife/irate)))));
Demand(t).. d(t)=e=sum(i,p(i,t));
investment(i,t)..v(i)=g=u(i,t);
Model UC /all/
Solve UC using mip minimizing z ;
display z.l;
There are two files attached for you to execute the program and hopefully solve my problem:)
Demand.csv (116 KB)
COP.csv (872 KB)