title: Optimisation model, skip error due to index componenet
body: <p>I have an index error on one of the components of my objective function and I wanted to know if there's a way to tell pyomo to skip the index component when there's none.</p>
  <p>To clarify, I have a dictionary Penalty_Nu[n, s, d] with only the indexes componenents when the penalty should be applied.</p>
  <p>Model.x is a variable of all [n, s, d] component where:</p>
  <ul>
  <li>N: employee ID</li>
  <li>S: Shifts</li>
  <li>D: Day</li>
  </ul>
  <p>Here's the part of the objective function:</p>
  <pre><code>def obj_function(model):
       return(
           sum(sum(Penalty_Nu[n,s,d]*model.x[n,s,d] for d in model.D) for s in model.S)
       )
      
  model.ObjFunction = Objective(rule=obj_function, sense=minimize)
  </code></pre>
  <p>Here's the error:</p>
  <pre><code>ERROR: Rule failed when generating expression for objective ObjFunction:
      KeyError: (9, 'N', 2)
  ERROR: Constructing component 'ObjFunction' from data=None failed: KeyError:
      (9, 'N', 2)
  </code></pre>
  <p>I know I could add all the components[n, s, d] where the penality should be 0 to the dictionary Penalty_Nu but if there's another way it could really help me.</p>