# Creating an Optimisation Problem to Optimise Water Flow

A water tank needs to be refilled with an electric pump when the water level gets below a certain level. The pump can operate at variable flow rates. Further, there is a time-variant electric billing during different times of the day. We need to quickly fill the tank with the minimum electricity bill.

I've devised the following solution \begin{align}\min&\quad\sum_{t=1}^{24}\gamma \cdot Q_p(\alpha)\cdot t\cdot C_t\cdot U_i(s)\\\text{s.t}&\quad p_{\min} \le P_{t} \le p_{\max}\\&\quad l_{\min} \le l_{t} \le l_{\max}\end{align} where

• $$\gamma$$ is a coefficient to demonstrate that the power consumption is proportional to flow rate $$Q_p(\alpha)$$;

• energy cost is represented as $$t\cdot C_t$$ where $$C_t$$ is cost of electricity at time $$t$$;

• $$U_i(s)$$ is the status of the pump where $$U_i(s)\in[0,1]$$ such that $$0$$ means inactive and $$1$$ means active;

• $$p_{\min}$$ and $$p_{\max}$$ are the minimum and maximum pressure levels respectively;

• $$l_{\min}$$ and $$l_{\max}$$ are the minimum and maximum threshold levels respectively.

So far I've achieved the above mathematical formulation as per my understanding.

I am unable to add a constraint where the problem states that if the tank level drops below a threshold, then it is compulsory to refill the tank and I'd want to then change the pump status represented by $$U_i(s)$$ to be equal to $$1$$. How can a add that constraint?

Is my above problem formulation correct or is there any other error?

Formulate the given problem and suggest an optimisation problem (No implementation required)

Problem Description: Consider a water tank on a roof top that needs to be refilled with an electric pump when water level in the tank gets below certain threshold. The electric pump can operate with variable flow rate and its power consumption is directly promotional to flow rates. Furthermore, we also consider time variant pricing for electricity billing i.e. same power consumption during different day time will be charged differently. Assume peak pricing policy around mid-day time and gradual decrease in pricing near morning and evening.

The home user need is to quickly refill the tank with minimum electricity bill. Your task is to formulate the given problem and suggest an optimisation formula to full-fill given user requirements. You need to consider three parameters (a) tank water level (b) pump flow rate (c) pricing rate at current time.

Consider any further relevant assumptions or constraints if needed. Your assumptions or constraints must be valid in given problem scenario.

2nd Attempt

After looking at answer and comments I've tried to improve my objective function.

$$in_t = Q_p(t,\alpha)$$ will make inflow dependent on both time $$t$$ and pressure $$\alpha$$.

$$power = \gamma . Q_p(t,\alpha)$$ Since power consumption is proportional to inflow rate $$Q_p(t,\alpha)$$ I've multiplied it with factor $$\gamma$$.

$$U(t)$$ is status of pump at time $$t$$. It would be $$0$$ or $$1$$ if inactive or active respectively.

Since electricity cost is time variant therefore $$C(t)$$ would represent cost of electricity at time $$t$$.

Factoring all the above cost I've developed the following cost function:

\begin{align}\min&\quad\sum_{t=1}^{24} Min: \gamma \cdot Q_p(t,\alpha) \cdot C(t) \cdot U(t)\end{align} $$s.t.$$ \begin{align}l_{min} \le l_t - out_t - Q_p(t, \alpha) \le l_{max} \end{align} \begin{align} P_{min} \le \alpha \le P_{max} \end{align} I am not sure but I think if $$\alpha$$ represent the pressure then limiting it from $$0$$ to $$p_{max}$$ would help us get rid of incorporating pump status $$U(t)$$ since if pump is not operational pressure would be $$0$$ and $$Q_p(t,\alpha)$$ would eventually equate to $$0$$.

I believe the above constraint do take into account the tracking of tank level. However, the question states "refilling takes place if the level drops below a certain threshold" & I believe that I haven't taken that into account and there should be constraint for that as well. I believe it should be that $$\alpha \ge 0$$ if $$l_t \le l_{thres}$$. Where $$\alpha$$ represents pressure and $$l_{thres}$$ is the level threshold after which the filling starts. If this is correct how would I write a constraint for it?

• What is index $i$ ? What is index $L$? I think you need an equation to model the evolution of the tank's level. Something like $l_{t+1}=l_t - \operatorname{outflow}(t) + \operatorname{inflow}(t)$, when $\operatorname{outflow}$ denotes the volume leaving the tank and $\operatorname{inflow}$ the volume pumped in. – Kuifje Jun 11 at 20:08
• $i$ can be removed from $U_i$ since there is only 1 pump. $l$ denotes tank level. You are absolutely right with adding outflow & inflow. How can that be added to objective function? Moreover, I think adding a constraint to activate pump if tank level falls below a threshold $l_{\min}$ will contradict my second constraint. – Furqan Hashim Jun 11 at 20:13
• What is index $T$ in $l_{t,T}$ ? You do not necessarily have to add the inflow and outflow in the objective function. Is the inflow related to $Q_p$ ? No, don't worry we can write the equation to activate the pump without contradicting the second constraint, but first we need to properly understand and complete the current formulation. – Kuifje Jun 11 at 21:04
• Point of adding $T$ was to illustrate that in 24hrs there shouldn't be a single hour where level drops below $l_{min}$ or goes beyond $l_{max}$. I am not sure if that is correct representation or is it creating confusion. It can removed if not written correctly. $Q_p$ is related to inflow. I believe we need to state initial tank level in the above formulation along with inflow & outflow. (if not in objective it should be mentioned somewhere in constraints defining constraint for tank levels.) – Furqan Hashim Jun 11 at 21:16

## This was my answer to the initial question which has been edited since:

First you need to add equations to model the evolution of the tank's level: $$l_{t+1}=l_t - \mbox{out}_t + \mbox{in}_t$$

$$\mbox{out}_t$$ is the volume that is pumped out of the tank at time $$t$$, and $$\mbox{in}_t$$ is the volume that is pumped in.

$$\mbox{in}_t$$ is a variable that takes a positive value only when the tank reaches the minimum threshold. And this value cannot be lower than $$l_{\max}-l_{\min}$$, so that the tank is refilled properly:

\begin{align} \mbox{in}_t &\ge (l_{\max}-l_{\min}) \delta_t \\ \delta_t &\in \{0,1\} \end{align}

If $$l_t - \mbox{out}_t > l_{\min}$$, then $$\mbox{in}_t$$ has to take value $$0$$, otherwise we would have $$l_{t+1} > l_{\max}.$$

And to activate $$U_i(s)$$: $$\delta_t \le U_i(s)$$

I am pretty sure your cost function is not well defined though.

• Tank volume : $$V$$
• Tank minimum threshold (safety volume) : $$V_s$$
• Time span : $$T$$
• Step time : $$\Delta t$$
• Proportionality constant between inflow and power: $$k$$
• Pricing rate [\/watt] at time $$t \in T$$ : $$c_t$$ • Outflow volume at time $$t \in T$$: $$\mbox{out}_t$$. I consider that this parameter is known or estimated, for example with a sensor on the tank. 2) Variables: • $$\mbox{in}_t \in \mathbb{R}^+$$: volume pumped in at time $$t \in T$$ • $$v_t \in \mathbb{R}^+$$ : tank water level at time $$t \in T$$ (volume, same dimension as $$\mbox{in}_t$$) • $$p_t \in \mathbb{R}^+$$: power consumption at time $$t\in T$$ 3) Objective function: You are minimizing power consumption (the electricity bill): $$\min \quad \sum_{t \in T} c_t \; p_t$$ 4) Constraints: • power consumption definition: $$p_t \; \Delta t= k \; \mbox{in}_t \quad \forall t \in T$$ Note: power is proportional to rate, which is the volume divided by the step time. • tank level: \begin{align*} v_{t+1} &= v_t - \mbox{out}_t + \mbox{in}_t \quad &\forall t \in T \\ V_s & \le v_t \le V \quad &\forall t \in T \end{align*} 5) Possible additional constraints: As suggested by OP: • Maximum power $$P$$: $$p_t \le P \quad \forall t \in T$$ To me it is not explicit that the tank must necessarily be refilled when the pump is active. If it is, see initial answer. Also, the binary status of the pump is not necessary. If the pump is not pumping, $$p_t = 0$$. • I've created a cost function bearing in mind the I need to reduce the cost of electricity. Now if I understand your answer correctly can I replacein_t$with$Q_{p}(\alpha)$which is the inflow rate? What do you mean by adding equation to model$l_{t+1} = l_{t} - out_{t} + in_{t}$? Do you mean to add it as a constraint or do I need to incorporate it with cost function? If yes, then how? Moreover, could explain how did you deduced that cost function is not well defined? And how can I go about correcting it? – Furqan Hashim Jun 12 at 8:39 • You cannot replace$in(t)$by$Q_p$because$Q_p$does not depend on$t$. Yes, adding to the model means adding the equation as a constraint. I think the model is incomplete because, for example, variables$P_t$are not in the cost function. And I believe the term$t*C_t$is incorrect. To help you correct the model more background information is needed. Is this homework ? A project ? What data do you have ? – Kuifje Jun 12 at 8:56 • I've made an edit and added a heading task which is the complete problem verbatim. Please note this is a homework practise question. No data is given I just need to formulate the optimisation problem. – Furqan Hashim Jun 12 at 9:12 • I've made a second attempt to build the objective function. Could you please review and help me out to get to correct formulation of the task. – Furqan Hashim Jun 12 at 15:59 • This is a linear problem and can thus be solved with the well known simplex algorithm. The objective was not well defined because a) parameter$t$was part of the cost function, which I did not understand b) some variables were not in the objective function ($P_t$for example) c) Variable$U(t)\$ seemed unecessary to me. No problem, happy to help. – Kuifje Jun 16 at 12:11