title: How can I declare a variable in Pyomo as a matrix?
body: <p>I'm trying to this:</p>
  
  <pre><code>P_sell = np.array([mod.addVar(lb=0, ub=gen_Max[g], name="exchanges_sell") for g in range(n_gen) for l in range(n_load)]).reshape((n_gen,n_load))
  </code></pre>
  
  <p>but I'm using Pyomo, so I think can't declare the variable directly into "model" because it's a matrix so I did this:</p>
  
  <pre><code>def sell(model, gen):
       return (0, model.capmax_act[gen])
  model.venda= Var(model.gen, bounds=sell, doc='P sell')
  
  p_sell = np.array([model.venda[gen] for gen in model.gen for loads in model.loads]).reshape((n_gen,n_load))
  
  </code></pre>
  
  <p>where model.capmax_act[gen] is the same as gen_Max[g]</p>
  
  <p>Does it represent the same thing? Or is it possible to declare model.p_sell as a matrix of variables instead of doing this?</p>
  
  <p>I'm kind of new to python, but I hope you can understand my question.</p>