title: Initialization of Arcs depening on Sets/Subsets in directed graphs in CPLEX
body: <p>I am dealing with a directed weighted graph and have a question about how to initialize a set a defined in the following:</p>
  <p>Assume that the graph has the following nodes, which are subdivided into three different subsets.</p>
  <pre><code>//Subsets of Nodes
  {int} Subset1= {44,99};
  {int} Subset2={123456,123457,123458};
  {int} Subset3={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
  {int} Nodes=Subset1 union Subset2 union Subset3;
  </code></pre>
  <p>Now there is a set of H_j arcs, where j is in Nodes. H_j gives all arcs outgoing from Node j.
  The arcs are stored in an excel file with the following structure:<a href="https://i.stack.imgur.com/a1Bd8.png" rel="nofollow noreferrer">enter image description here</a></p>
  <p>For node 44 in Nodes (Subset 1), there are the arcs &lt;44,123456&gt;, &lt;44,123457&gt;, &lt;44,123458&gt;. For 66 in Nodes (Subset 2), there is no arc. Can somebody help me how to implement this?
  Important is that the code uses the input from the excel because in my real case there will be too much data to make a manual input... :(</p>
  <p>Maybe there is a real easy solution for that. I would be very thankful!
  Thank you so much in advance!</p>
  <p><a href="https://i.stack.imgur.com/a1Bd8.png" rel="nofollow noreferrer">enter image description here</a></p>
  <p><strong>This addition refers to the answer from @Alex Fleischer:</strong>
  Your code seems to work also in the overall context.
  I am trying to implement the following constraints within a Maximization optimization ( The formulations (j,99) and (j,i) in the lower sum boundaries represent arcs):
  <a href="https://i.stack.imgur.com/0lYtr.png" rel="nofollow noreferrer">enter image description here</a></p>
  <p>I tried to implement it like this:</p>
  <pre><code>{int} TEST= {99};
  subject to {
      sum(m in M, j in a[m])x[&lt;44,j&gt;]==3;
      sum(j in destPerOrig[99], t in TEST)x[&lt;j,t&gt;]==3;
      forall(i in Nodes_wo_Subset1)
      sum(j in destPerOrig[i],i in destPerOrig[i])x[&lt;j,i&gt;]==1;
  }
  </code></pre>
  <p>M is a set of trains and a[M] gives a specific cost value for each indiviudal train. CPLEX shows 33 failure messages.
  The most frequent one is that it cannot extract x[&lt;j,i&gt;], sum(in in destPerOrig[i]), sum(j in destPerOrig[i] and that x and destPerOrig are outside of the valid area.</p>
  <p>Most probably the problem is that I implement the constraints in the wrong manner. Again, it is a directed graph.</p>
  <p>Referring to the mathematical formulation in the screenshot: Could the format of destPerOrig[i] be a problem?
  At the moment destPerOrig[44] gives {2 3 4}. But should´t it give:
  {&lt;44 2&gt; &lt;44 3&gt; &lt;44 4&gt;} to work within the mathematical formulation?</p>
  <p>I hope that this is enoug information for you to help me :(</p>
  <p>I would be very thankful!</p>