title: Pyomo: ERROR: evaluating expression: No value for uninitialized NumericValue object
body: <p>I am working on an Pyomo optimization script.  It is moderately complex with indexed parameters and variables and 8 constraints.  If I leave the decision variables with no initial value, I get "ERROR: evaluating expression: No value for uninitialized NumericValue object" errors for constraints involving a decision variable.  If I initialize the decision variables to 1 or 0 the solver(glpk) returns Status: optimal and objective function value = 0. All decision variables are also set to 0. I am looking for ideas about how to troubleshoot this.  Below is relevant code (w/o data) and the output from the solver and model.display, which has been edited to make it more compact.</p>
  
  <pre><code>#Sets
  #clinics
  model.C = Set(initialize=list(clinics.keys()))
  
  #clients
  model.B = Set(initialize=list(client_blocks.keys()))
  
  #scalar params
  model.clt_stf_max = 10
  model.tt_max = 45
  model.selected_clinic_max = 4
  model.stf_max = sum(staff_cap.values())  #total available staff is sum of clinic new staff capacity
  model.z_M = 5000  #used in clients at selected clinics constraint
  model.e_M = 500   #used in staff at selected clinics constraint
  
  #indexed params
  model.cnc_stf_cap = Param(C, initialize=staff_cap)
  model.clt_blk = Param(B, initialize=client_blocks)
  model.trav_time = Param(T, initialize=trav_time)
  
  #decision vars
  #x new staff at each clinic
  model.new_stf = Var(model.C, domain=NonNegativeIntegers, initialize=0) 
  
  #y new clients at each clinic/block combo  
  model.new_clt = Var(model.C, model.B, domain=NonNegativeIntegers, initialize=0) 
  
  #z client at selected clinics only 
  model.z =  Var(model.C, model.B, domain=Binary, initialize=0)
  
  #e staff at selected clinics only 
  model.e = Var(model.C, domain=Binary, initialize=0) 
  
  #objective function
  def o_min_tt_rule(model):
      return sum(model.trav_time[c,b]*model.new_clt[c,b] for c in model.C for b in model.B)
  model.o_min_tt = Objective(rule=o_min_tt_rule, sense=minimize)
  
  #constraints
  # limit new clients at clinic to staff capacity  
  def limit_clients_to_clinic_staff_cap_rule(model, c):
      return sum(model.new_clt[c,b] for c in model.C for b in model.B) &lt;= (model.cnc_stf_cap[c] * model.clt_stf_max)
  model.limit_clients_to_clinic_staff_cap = Constraint(model.C, rule=limit_clients_to_clinic_staff_cap_rule)
  
  #total of new clients served in block should not exceed the number new clients in the block 
  def limit_newclient_block_rule(model, b):
      return sum(model.new_clt[c,b] for c in model.C for b in model.B) &lt;= (model.clt_blk[b])
  model.limit_newclient_block = Constraint(model.B, rule=limit_newclient_block_rule)
  
  #limit new clients to selected clinics
  def client_to_selected_clinic_rule(model, c, b):
     return model.new_clt[c,b] &lt;= model.z[c,b] * model.z_M
  model.client_to_selected_clinic = Constraint(model.C, model.B, rule=client_to_selected_clinic_rule)
  
  #limit single client travel time to max travel time minutes
  def limit_client_travtime_rule(model, c, b):
      return (model.trav_time[c,b] * model.z[c,b]) &lt;= model.tt_max
  model.limit_client_travtime = Constraint(model.C, model.B, rule=limit_client_travtime_rule)
  
  #limit selected clinics to max number
  def limit_selected_clinic_to_max_rule(model):
      return summation(model.e) &lt;= model.selected_clinic_max
  model.limit_selected_clinic_to_max = Constraint(rule=limit_selected_clinic_to_max_rule,)
  
  #limit new staff to selected clinics
  def staff_to_selected_clinic_rule(model, c):
      return model.new_stf[c] &lt;= model.e[c] * model.e_M
  model.staff_to_selected_clinic = Constraint(model.C, rule=staff_to_selected_clinic_rule)
  
  #limit new staff at clinic to clinic capacity
  def limit_staff_to_clnic_cap_rule(model, c):
      return model.new_stf[c] &lt;= model.cnc_stf_cap[c]
  model.limit_staff_to_clnic_cap = Constraint(model.C, rule=limit_staff_to_clnic_cap_rule)
  
  #limit total new staff to staff max   
  def limit_tot_staff_rule(model):
      return summation(model.new_stf) &lt;= model.stf_max
  model.limit_tot_staff = Constraint(rule=limit_tot_staff_rule)
  
  
  # solve the model 
  solver = SolverFactory("glpk", tee=True, warmstart=True, symbolic_solver_labels=True)
  </code></pre>
  
  <p>OUTPUT from solver and model.display()</p>
  
  <pre><code>SOLVER:
  Problem: 
  - Name: unknown
    Lower bound: 0.0
    Upper bound: 0.0
    Number of objectives: 1
    Number of constraints: 753
    Number of variables: 665
    Number of nonzeros: 29213
    Sense: minimize
  Solver: 
  - Status: ok
    Termination condition: optimal
    Statistics: 
      Branch and bound: 
        Number of bounded subproblems: 1
        Number of created subproblems: 1
    Error rc: 0
    Time: 0.10507559776306152
  Solution: 
  - number of solutions: 1
    number of solutions displayed: 1
  - Gap: 0.0
    Status: optimal
    Message: None
    Objective:
      o_min_tt:
        Value: 0
    Variable: No nonzero values
    Constraint: No values
  </code></pre>
  
  <p>MODEL:</p>
  
  <pre><code>Model (Staff_Allocation)
  
    Variables:
      new_stf : Size=4, Index=Clinics
          Key                                       : Lower : Value : Upper : Fixed : Stale : Domain
                   FEDCAP Counseling Center - 01004 :     0 :     0 :  None : False : False : NonNegativeIntegers
          The Salvation Army Belmont Center - 04002 :     0 :     0 :  None : False : False : NonNegativeIntegers
                        VIP Wellness Center - 12000 :     0 :     0 :  None : False : False : NonNegativeIntegers
           Westchester Center of Excellence - 11006 :     0 :     0 :  None : False : False : NonNegativeIntegers
      new_clt : Size=392, Index=new_clt_index
          Key                                                            : Lower : Value : Upper : Fixed : Stale : Domain
                   ('FEDCAP Counseling Center - 01004', 360050019001022) :     0 :     0 :  None : False : False : NonNegativeIntegers
  
      z : Size=392, Index=z_index
          Key                                                            : Lower : Value : Upper : Fixed : Stale : Domain
                   ('FEDCAP Counseling Center - 01004', 360050019001022) :     0 :     0 :     1 : False : False : Binary
      e : Size=4, Index=Clinics
          Key                                       : Lower : Value : Upper : Fixed : Stale : Domain
                   FEDCAP Counseling Center - 01004 :     0 :     0 :     1 : False : False : Binary
          The Salvation Army Belmont Center - 04002 :     0 :     0 :     1 : False : False : Binary
                        VIP Wellness Center - 12000 :     0 :     0 :     1 : False : False : Binary
           Westchester Center of Excellence - 11006 :     0 :     0 :     1 : False : False : Binary
  
    Objectives:
      o_min_tt : Size=1, Index=None, Active=True
          Key  : Active : Value
          None :   True :     0
  
    Constraints:
      limit_clients_to_clinic_staff_cap : Size=4
          Key                                       : Lower : Body : Upper
                   FEDCAP Counseling Center - 01004 :  None :    0 : 200.0
          The Salvation Army Belmont Center - 04002 :  None :    0 : 150.0
                        VIP Wellness Center - 12000 :  None :    0 : 150.0
           Westchester Center of Excellence - 11006 :  None :    0 : 250.0
  
      limit_newclient_block : Size=98
          Key             : Lower : Body : Upper
          360050019001022 :  None :    0 :   1.0
          .... 97 more like this
  
      client_to_selected_clinic : Size=392
          Key                                                            : Lower : Body : Upper
                   ('FEDCAP Counseling Center - 01004', 360050019001022) :  None :    0 :   0.0
          .... 391 more like this
  
      limit_client_travtime : Size=392
          Key                                                            : Lower : Body : Upper
                   ('FEDCAP Counseling Center - 01004', 360050019001022) :  None :    0 :  75.0
          .... 391 more like this
  
      limit_selected_clinic_to_max : Size=1
          Key  : Lower : Body : Upper
          None :  None :    0 :   4.0
  
      staff_to_selected_clinic : Size=4
          Key                                       : Lower : Body : Upper
                   FEDCAP Counseling Center - 01004 :  None :    0 :   0.0
          The Salvation Army Belmont Center - 04002 :  None :    0 :   0.0
                        VIP Wellness Center - 12000 :  None :    0 :   0.0
           Westchester Center of Excellence - 11006 :  None :    0 :   0.0
  
      limit_staff_to_clnic_cap : Size=4
          Key                                       : Lower : Body : Upper
                   FEDCAP Counseling Center - 01004 :  None :    0 :   4.0
          The Salvation Army Belmont Center - 04002 :  None :    0 :   3.0
                        VIP Wellness Center - 12000 :  None :    0 :   3.0
           Westchester Center of Excellence - 11006 :  None :    0 :   5.0
  
      limit_tot_staff : Size=1
          Key  : Lower : Body : Upper
          None :  None :    0 :  15.0
  </code></pre>