title: How to convert a multi-dimensional array model to a tuple structure in CPLEX?
body: <p>I would like to use a large dataset (3100 demand locations) for my facility location problem. </p>
  
  <p>One of the constraints is the size of the distance matrix. If I use a 2d array for distance between locations, I store a very large amount of unnecessary data. (Like long distances which I will not use in my model, so I add another constraint like &lt;= maxdist )</p>
  
  <p>Instead of using a 2D array I am trying to use the following tuple, however if I don`t use the complete distance matrix (which converted to a tuple) I do not get a solution ? </p>
  
  <p>Thanks for your suggestions ...</p>
  
  <pre><code>    {string} Supply = ...;      // Supply locations
      {string} DC = ...;          // Candidate facility locations
      {string} Demand = ...;      // Demand locations
  
      tuple Dist_Tup{
      string FROM;
      string TO;
      float MILES;
      };
  
      setof(Dist_Tup) DistanceTmp=...;
      setof(Dist_Tup) Distance = { &lt;FROM,TO,MILES&gt; | &lt;FROM,TO,MILES&gt; in DistanceTmp : FROM in Supply || FROM in DC};
  
      dexpr float TransportCost1 = sum(i in Supply , a in Alt , j in DC , p in Period, BB in Distance : BB.TO==j &amp;&amp; BB.FROM==i) X[i][a][j][p]*Dist[BB]*C[i][j];
  
      //dexpr float TransportCost1 = sum(i in Supply , a in Alt , j in DC , p in Period) X[i][a][j][p]*G[i][a][j]*C[i][j];
  </code></pre>