I'm trying to add a non-linear constraint to my model that describes as the amount of heated water (m_heated
@ temp_heated
) required to add to other cold/inlet/netowrk water mass (m_inlet
@ temp_inlet
) to result in a defined temperature temp_set
. The total flow rate m_total
is total mixture, given by adding both flow rates m_total = m_heated + m_inlet
. Assuming the same fluid, so I'm disregarding the specific heat capacity.
temp_set = ( m_heated * temp_heated + (m_total - m_heated) * temp_inlet ) / m_total
Since my goal is to find the m_heated (to add to the optimization problem), this simplifies to:
m_heated = m_total * (temp_set - temp_inlet) / (temp_heated - temp_inlet)
However, this results in a non-linear equation (m_total
, temp_set
, temp_inlet
are known), and both m_heated
and temp_heated
are not, and they add to other constrains as well.
I used:
milp += m_heated[t] = m_total * (temp_set - temp_inlet) / (temp_heated[t] - temp_inlet)
But it retuns that "Non-constant expressions cannot be multiplied". Is there any way of adding this to PuLP as linear?