title: Pyomo and dynamic objective function creation
body: <p>I want to iteratively add to a Pyomo objective function based upon rows in a pandas dataframe.  I've created variables based upon the size of the dataframe:</p>
  
  <p><code>model.A = Var(range(0,len(arc_decvars)), initialize=0,within=Integers,bounds=(0,5))</code></p>
  
  <p>where <code>arc_decvars</code> is a list in the same order as the corresponding pandas dataframe series.</p>
  
  <p>What I would like to do is create an objective function like this, but without having to specify the indices explicitly in the code:</p>
  
  <p><code>model.ObjFcn = ( df.coefficient[0] * model.A[0] * ( 1- df.coefficient[0] * model.A[0]) ) + ( df.coefficient[1] * model.A[1] * ( 1- df.coefficient[1] * model.A[1]) +...+ ( df.coefficient[999] * model.A[999] * ( 1- df.coefficient[999] * model.A[999]) )</code></p>
  
  <p>Any idea on how to do this?</p>
  
  <p>---- Followup:</p>
  
  <p>I am adding a series of constraints like this, one for each node:</p>
  
  <pre><code>def NodeA(model):
      k = sum(
          model.ArcVar[i] * node_arc_matrix[i,0]
          for i in model.ArcVar
              )
      return k ==  2*model.NodeVar[1]
  model.NodeAConstraint=Constraint(rule=NodeA)
  </code></pre>
  
  <p>Where the 0-index in node_arc_matrix refers to the column corresponding to Node_A.  Instead of creating a constriant for each node manually can I create constraints across both i (arcs) and j (nodes)?</p>