title: Pyomo update Set and Var to solve again
body: <p>I am quite new to Pyomo but not to Python. </p>
  
  <p>I have the following problem:</p>
  
  <pre><code>import pyomo.environ as pyo
  
  model = pyo.ConcreteModel()
  model.A = pyo.Set(initialize=range(7))
  model.B = pyo.Set(initialize=range(7))
  model.AB = pyo.Set(initilize= list((a,b) for a in model.A for b in model.B)
  model.X = pyo.Var(model.A, model.B, within=pyo.Binary)
  model.objective = pyo.Objective(... maximize)
  solver = pyo.SolverFactory('glpk')
  result = solver.solve(model)
  </code></pre>
  
  <p>Next I want to update the model.B Set() and as aconsequence modify de model.AB Set and the model.X Var so I can solve it again. For example, I want to set:</p>
  
  <pre><code>model.B = pyo.Set(initialize=range(4)
  </code></pre>
  
  <p>Then update the model.AB, model.X and solve again.  If done that manually:</p>
  
  <pre><code>model.B = pyo.Set(initialize=range(4)
  model.AB = pyo.Set(initilize= list((a,b) for a in model.A for b in model.B)
  model.X = pyo.Var(model.A, model.B, within=pyo.Binary)
  result = solver.solve(model)
  </code></pre>
  
  <p>Thats not working, it gives the following error:</p>
  
  <pre><code>RuntimeError: Cannot add component 'X_index' (type &lt;class 'pyomo.core.base.sets._SetProduct'&gt;) to block 'unknown': a component by that name (type &lt;class 'pyomo.core.base.sets._SetProduct'&gt;) is already defined.
  </code></pre>