When you use = in a set statement, you are saying that everywhere in the model, the set on the left will have the same value as the expression on the right. You can change your definition using redeclare, but AMPL is rejecting your new definition,
redeclare set SET_B = SET_B diff SET_A;
because it is defining SET_B by an expression that contains SET_B. Instead, you should use AMPL let statements to assign values to your sets. Here is an example, just to show the idea:
set SET_A;
set SET_B;
...
let SET_A := {1,3};
let SET_B := {1,2};
while ...
let SET_B := SET_B diff SET_A;
solve;
...
let SET_B := SET_B union {3,4};
You can use let in similar ways to make whatever assignments you need. (For simplicity, I am just showing the AMPL statements, and you will need to adapt them for use within the C++ API. Also instead of {3,4} you would want to use a set expression that is different each time through the loop.)
When you use = in a set statement, you are saying that everywhere in the model, the set on the left will have the same value as the expression on the right. You can change your definition using redeclare, but AMPL is rejecting your new definition,
redeclare set SET_B = SET_B diff SET_A;
because it is defining SET_B by an expression that contains SET_B. Instead, you should use AMPL “let” statements to assign values to your sets. Here is an example, just to show the idea:
set SET_A;
set SET_B;
...
let SET_A := {1,3};
let SET_B := {1,2};
while ...
let SET_B := SET_B diff SET_A;
solve;
...
let SET_B := SET_B union {3,4};
You can use let in similar ways to make whatever assignments you need. (For simplicity, I am just showing the AMPL statements, and you will need to adapt them for use within the C++ API. Also instead of {3,4} you would want to use a set expression that is different each time through the loop.)