Hey,

the following model works already, but now I would like to add a restriciton to a variable, and I don’t know how/where to add that restriction.

x_pump(t) should only work in between the range of 0.085 and 0.2. Meaning the pump only runs when x_solar is higher than 0.085 and lower than 0.2.

Can anyone help me to solve this problem? Thanks in advance!

Regards, Martin

Set

t time in hours /t0*t5/;

Parameter solar(t) Solarenergy per hour in kW /

t0 0.05

t1 0.085

t2 0.1

t3 0.3

t4 0.2

t5 0.07/

;

Scalar ddaily Waterdemand per day in cubic meters /3.5/;

Scalar eta efficiency from solarenergy to pump /0.5/;

Scalar costPV Cost per kW installed capacity in Euro /100/;

Variables x_solar(t);

Variables x_pump(t);

positive variable pumpflow(t)

Free Variable TotalCost,PV_Capacity;

Equations Obj,DailyWaterdemand,WaterFlow,limitSolar,solarsize;

Obj… TotalCost =E= PV_Capacity*costPV;

DailyWaterdemand… ddaily =E= sum(t,pumpFlow(t));

WaterFlow(t)… pumpFlow(t) =E= 5.5586*x_pump(t) + 0.2278;

limitSolar(t)… x_pump(t) =L= x_solar(t);

solarsize(t)… x_solar(t) =E= solar(t)*eta*PV_Capacity;

Model WaterPump /all/;

Solve WaterPump using lp minimizing TotalCost