title: Incorrect value of objective function in simple example solved with pyomo
body: <p>I have recently started to use pyomo for my research, and I'm studying its use with the book "<strong>Pyomo-Optimization modelling in Python</strong>".
  As my research has to do with heat exchanger networks I am currently trying to build and solve a very simple problem before expanding into more complex and meaningful ones.
  Here is the model I input into pyomo.</p>
  
  <pre><code>from coopr.pyomo import*
  model=AbstractModel()
  
  Tcin1=300 
  Thin1=500 
  mc= 135
  mh=128
  Cpc=3.1
  Cph=2.2 
  
  model.Thout1=Var(initialize=480, within=PositiveReals)
  model.Tcout1=Var(initialize=310, within=PositiveReals)
  model.Q=Var(initialize=2000, within=PositiveReals)
  
  import math
  
  
  
  def HeatEx(model):
      return ((Thin1-model.Tcout1)-(model.Thout1-Tcin1))/(math.log(Thin1-model.Tcout1)-math.log(model.Thout1-Tcin1))
  
  model.obj=Objective(rule=HeatEx, sense=minimize)
  
  
  model.con1 = Constraint(expr=(mc*Cpc*(Thin1-model.Thout1) == 
          mh*Cph*(model.Tcout1 - Tcin1)))
  model.con2=Constraint(expr=(model.Q==mc*Cpc*(Thin1-model.Thout1)))            
  model.con3=Constraint(expr=(model.Tcout1==310))
  </code></pre>
  
  <p>I've been running it through the terminal using the <code>ipopt</code> solver as <code>pyomo --solver=ipopt --summary NoFouling.py</code>.</p>
  
  <p>My problem is that I get an incorrect value for the objective. It's says the objective is -60.5025857388 (with variable Thout1 = 493.271206691) which is incorrect. In an attempt to realize what the problem is, I replaced model.Thout1 in the objective function with the value 493.271206691,re-ran the model and obtained the correct objective value which is 191.630949982. This is very strange because all the variable values coming out of pyomo are correct even when the objective function value is wrong. In brief, if I take those values that seemingly give a wrong result and calculate manually the function from those, I get the correct result.</p>
  
  <p><strong>What is the cause of this difference? How can I resolve this problem?</strong></p>
  
  <p>For the record I'm running Python2.7 via Enthought Canopy, on a computer running CentOS 6.5. I also have to confess that I'm a bit new to both python and using a linux system. I have searched through the internet for pyomo answers, but this one seems to be too specific and I have found nothing really useful.</p>
  
  <p>Many thanks</p>