title: Cannot iterate over abstract Set before it has been constructed (initialized)
body: <p>In an abstract Model in pyomo, I want to define a new parameter in the following way:</p>
  
  <pre><code>from __future__ import division
  from pyomo.environ import *
  from coopr.pyomo import *
  from objbrowser import *
  import os
  model = AbstractModel()
  
  model.F = Set()
  model.N_f = Set(dimen=2)
  model.arcs = Set(dimen=2)
  model.l_fmn = Param(model.arcs)
  model.d_f = Param(model.F)
  
  for k in model.F:
      for i1 in model.N_f[k]:
          for i2 in model.arcs[k]:
              def maker_fn(model):
                  if model.arcs[k].index(i2) &lt; model.N_f[k].index(i1):
                      return  sum(model.l_fmn[k,i2] + model.d_f[k])
                  else:
                      return model.d_f[k]
  
              model.r_fn[k,i1] = Param(initialize=maker_fn)
  </code></pre>
  
  <p>What I want to do with these loops here is to define a parameter model.r_fn with form Param(model.N_f), I mean, a parameter with one value for each of the elements of model.N_f, which has the value at each element of model.l_fmn + model.d_f if the index at model.arcs[k] is lower than the index at model.N_f[k], and if it is not lower, let the value be the same of model.d_f.</p>
  
  <p>I don't know if this is the proper way to stablish the loops and the def function to create a param, but the problem I get when I execute this is:</p>
  
  <p>"RuntimeError: Cannot iterate over abstract Set 'F' before it has been constructed (initialized)."</p>
  
  <p>I have tried different things and I still don't know why I get this error.</p>
  
  <p>So I would really appreciate if anyone could tell me how to fix this error and also the proper way of making the function I want to do work propertly in order to get the parameter.</p>
  
  <p>Thank you all very much in advance.</p>
  
  <p>The .dat file is the following:</p>
  
  <pre><code>set F := f1 f2 f3;
  
  set N_f :=
  f1 "q(a)"
  f1 a
  f1 b
  f1 C
  f2 A
  f2 "q(A)"
  f2 e
  f2 B
  f3 B
  f3 "q(b)"
  f3 f
  f3 C;
  
  set arcs :=
  f1 "(A,q(A))"
  f1 "(q(A),a)"
  f1 "(a,b)"
  f1 "(b,C)"
  f2 "(A,q(A))"
  f2 "(q(A),e)"
  f2 "(e,B)"
  f3 "(B,q(B))"
  f3 "(q(B),f)"
  f3 "(f,C)";
  
  param l_fmn :=
  f1 "(A,q(A))" 0
  f1 "(q(A),a)" 5
  f1 "(a,b)" 8
  f1 "(b,C)" 1
  f2 "(A,q(A))" 0
  f2 "(q(A),e)" 5
  f2 "(e,B)" 7 
  f3 "(B,q(B))" 0
  f3 "(q(B),f)" 3
  f3 "(f,C)" 3;
  
  param d_f :=
  f1 1
  f2 1
  f3 17;
  </code></pre>