1

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?

Paulos
  • 119
  • 1
  • 7
  • You could use linear interpolation. I would probably throw this first at an NLP solver and see how that works. Gurobi cal also do non-convex quadratic constraints, so that may be another candidate. – Erwin Kalvelagen Feb 09 '23 at 09:43

1 Answers1

0

There isn't a straightforward way of adding this to PuLP as linear because, mathematically, it's not linear.

See for example the discussion here for some ideas on how to solve this: How to convert quadratic to linear program?

Consult also the Math Stackexchange or the Operations Research Stackexchange for additional discussion.

cadolphs
  • 9,014
  • 1
  • 24
  • 41