Khái Duy
Khái Duy

Reputation: 69

Iterate through Tuple Cplex

I have a tuple:

`tuple Torder{
    string part;
    int period;
}
{Torder} order = {<i, h> | i in part, h in period};`

Then:

{string} operation = ...;

I'm trying to create a new tuple:

string step[k in operation] = k;

tuple Twip
{
    Torder order;
    string operation;
}

{Twip} status = {<<i, h>, o> | <i, h> in order, k in operation, o in 1.. step[k]};

But the code o in 1.. step[k] outputs

operation is not integer

Upvotes: 0

Views: 199

Answers (1)

Alex Fleischer
Alex Fleischer

Reputation: 10059

This syntax should work fine:

tuple Torder{
    string part;
    int period;
}

range period=1..2;
{string} part={"A","B"};
{Torder} order = {<i, h> | i in part, h in period};

{string} operation = {"Y","Z"};

string step[k in operation] = k;

{string} steps=union (k in operation) {step[k]};

tuple Twip
{
    Torder order;
    string operation;
}

{Twip} status = {<<i, h>, o> | <i, h> in order, k in operation, o in steps: ord(steps,o) <= ord(operation,k)};

execute
{
status;
}

Upvotes: 1

Related Questions