Currently I am trying to model the Dantzig Fulkerson Johnson Subtour elimination constraints in CPLEX.
I want to generate all the possible subsets of customers {"1", "2", "3", "4"} in ILOG Script.
For this, first I created a tuple structure that contains a set of strings where all the customers involved in a subtour can be stored:
tuple subtour {
{string} customers;
}
Now, I can create a set of subtour where I can store all the subtours:
{subtour} subtours;
I create an empty set of strings to help out in the execute-block:
{string} emptySet;
Now I create my execute-block: (In this first step, I am just trying to fill subtours with the subtours containing just one customer as a first test, e.g. in the first iteration subtours = {<{"1"}>, <{"2"}>,...}
execute FillSubtours {
for(var i in customers) {
emptySet.add(i);
subtours.add(emptySet);
writeln(subtours);
emptySet.clear();
}
}
So after this procedure, the goal is to have subtours like this:
subtours = {<{"1"}>, <{"2"}>, <{"3"}>, <{"4"}>}
Containing all the possible subtours with one element.
Sadly it looks the following:
subtours = {<{"4"}>}
Does anyone know where this went wrong and how I can fix it?