1

I am currently trying to implement a directed weighted graph algorithm in CPLEX.

For that I need to initialize the following node set P which includes three different disjoint subsets.

Node Set P
Disjoint Subset 1: {u,v}
Disjoint Subset 2: {A,B,C,D}
Disjoint Subset 3: {1,2,3,4,5,6,7,8,9,10,11,12}

Does somebody know how this works? So how does look like in code language?

Thanks a lot! Regards

I have the following two nodes:

{int} nodes = {44, 66};

Now I want to define different arcs depending on nodes. For node 44, there are the arcs <44,123456>, <44,123457>, <44,123458>. For 66, there is no arc. How can i implement this properly? I tried it like this, but I know that this cannot work and in fact it doesn´t :(

{int} nodes = {44, 66};
tuple Arc {
  int origin;
  int destination;
}
{Arc} arcs[nodes] = {<44,123456>, <44,123457>, <44,123458>, <66,?>};

Addionally I cannot not put in the numbers manually due to high data amounts, but have to read it from a an excel, in which the data is stored as follow: enter image description here

And maybe I should add the information that the those are nodes and arcs of a weighted and directed graph... So nodes = {44, 66} is a subset of all nodes of the graph and arcs[nodes] is the subset of all arcs and represent those arcs which are outgoing from nodes 44 and 66.

So to conclude my problem: I have set P, which has Subsets 1,2 and 3.

{string} Subset1= {"44","66"};
{string} Subset2= {"123456","123457","123458"};
{string} Subset3= {"1","2","3","4","5","6","7","8","9","10","11","12"};
{string} P=Subset1 union Subset2 union Subset3;

Depending the node from P(Subset 1,2 and 3) I want to express arcs, which are outgoing from a specific node.

Mathematically the set is defined a H_j with j in P. H_j are all arcs outgoing from j. j is the node from P

The arcs come from excel files with the structure above. Maybe there is a real easy solution for that. I would be very thankful!

A321
  • 17
  • 4

1 Answers1

1
{string} Subset1= {"u","v"};
{string} Subset2= {"A","B","C","D"};
{string} Subset3= {"1","2","3","4","5","6","7","8","9","10","11","12"};
{string} P=Subset1 union Subset2 union Subset3;

execute
{
  writeln(P);
}

works fine and gives

{"u" "v" "A" "B" "C" "D" "1" "2" "3" "4" "5" "6" "7" "8" "9" "10" "11" "12"}
Alex Fleischer
  • 9,276
  • 2
  • 12
  • 15
  • Thanks a lot @Alex Fleischer. I added another question above. Can you help me here as well? It begins below the last one ending with "Thanks a lot! Regards. I would be so thankful if you could help me out. Maybe there is a simple solution again – A321 Jun 28 '21 at 11:20
  • For New questions i suggest opening New threads – Alex Fleischer Jun 28 '21 at 12:31
  • You´re right. I posted it again in a new thread – A321 Jun 28 '21 at 13:09