title: Formulate square of a function in Mixed Integer Linear Programming using pulp
body: <p>I have a linear equation Ax = b. I am trying to minimize (Ax-b)^2 using pulp in Python. Dimensions of A are (1000, 500) and b is (1000,). </p>
  
  <p>So far I have tried this:</p>
  
  <pre><code>import pulp
  mse = pulp.LpProblem("Example_Problem", LpMinimize)
  vars = pulp.LpVariable.dicts('x', range(len(A[0])), lowBound=0,upBound =1, 
                               cat='Integer')
  for row, rhs in zip(A, b):
      mse += sum([row[i]*vars[i] for i in range(len(row))]) - rhs
  </code></pre>
  
  <p>How do i use the square for the function mse. If i try:</p>
  
  <pre><code>mse += (sum([row[i]*vars[i] for i in range(len(row))]) - rhs)**2
  </code></pre>
  
  <p>I get this error:</p>
  
  <p>*unsupported operand type(s) for ** or pow(): 'LpAffineExpression' and 'int'*</p>