title: Set up model in CPLEX using Python API
body: <p>In fact, I'm trying to implement the very simple model formulation:</p>
  
  <pre><code>min  sum_i(y_i*f_i) + sum_i(sum_j(x_ij*c_ij))
  s.t.   sum_i(x_ij) = 1         for all j
               x_ij &lt;= y_i       for all i,j
           x_ij, y_i are binary
  </code></pre>
  
  <p>But I simply cannot figure out how the Python API works. They suggest creating variables like this:</p>
  
  <pre><code>model.variables.add(obj = fixedcost, 
                      lb = [0] * num_facilities, 
                      ub = [1] * num_facilities, 
                      types = ["B"] * num_facilities)
  
  # Create one binary variable for each facility/client pair. The variables
  # model whether a client is served by a facility.
  for c in range(num_clients):
      model.variables.add(obj = cost[c], 
                          lb = [0] * num_facilities, 
                          ub = [1] * num_facilities, 
                          types = ["B"] * num_facilities)
  
  # Create corresponding indices for later use
  supply = []
  for c in range(num_clients):
      supply.append([])
      for f in range(num_facilities):
          supply[c].append((c+1)*(num_facilities)+f)
  
  # Constraint no. 1:
  for c in range(num_clients):        
      assignment_constraint = cplex.SparsePair(ind = [supply[c][f] for f in \
                                                      range(num_facilities)],
                                               val = [1] * num_facilities)
      model.linear_constraints.add(lin_expr = [assignment_constraint],                    
                                   senses = ["L"], 
                                   rhs = [1])
  </code></pre>
  
  <p>For this constraints I have no idea how the variables from above are refered to since it only mentions an auxiliary list of lists. Can anyone explain to me how that should work? The problem is easy, I also know how to do it in C++ but the Python API is a closed book to me.</p>
  
  <p>The problem is the uncapacitated facility location problem and I want to adapt the example file facility.py</p>
  
  <p>EDIT: One idea for constraint no.2 is to create one-dimensional vectors and use vector addition to create the final constraint. But that tells me that this is an unsupported operand for SparsePairs</p>
  
  <pre><code>for f in range(num_facilities):
      index = [f]
      value = [-1.0]
      for c in range(num_clients):
          open_constraint = cplex.SparsePair(ind = index, val = value) + cplex.SparsePair(ind = [supply[c][f]], val = [1.0])
          model.linear_constraints.add(lin_expr=[open_constraint],
                                      senses = ["L"],
                                      rhs = [0])
  </code></pre>