title: How to handle variable in matrix form which is of binary type in scipy to optimize with differential evolution
body: <p>I am experimenting to solve an optimization problem using differential evolution. I want to make use of scipy package in Python. The objective function I am trying to optimize with constraints is as below:</p>
  <p><a href="https://i.stack.imgur.com/MMoo8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MMoo8.png" alt="enter image description here" /></a></p>
  <p><code>Xki</code> is a binary decision variable I am trying to solve for. I have it as a matrix of size n*n. Rest of the parts of the eqn are defined values. My code for solving this optimization problem</p>
  <pre><code>summation_1 = 0
  
  for k in range(1,n):
      for i in range(0,n):
          for j in range(0,n):
              summation_1 = summation_1 + calculate_p(demands_list,k-1,vehicle_capacity)*x[k-1][i]*x[k][j]*dist_df[i][j]
  
  summation_2 = 0
  
  for k in range(1,n):
      for i in range(1,n):
          summation_2 = summation_2 + (x[k][i]*phi*penalty(k)) + (calculate_po(demands_list,k,vehicle_capacity)*x[k][i]*dist_df[i][0])
  
  objective = summation_1 + summation_2
  
  from scipy.optimize import differential_evolution, LinearConstraint
  bounds = []  #to be defined
  result = differential_evolution(objective, bounds, updating='deferred', workers=2)
  </code></pre>
  <p>I have defined the objective function. The challenges I am facing are:</p>
  <ol>
  <li>How to define the constraints and pass the constraints to objective function ?</li>
  <li>My X variable is in matrix form.. How to handle the variable which is in matrix form?</li>
  <li>since <code>Xki</code> is binary variable. How to handle such that only binary values are considered?</li>
  </ol>