Hello all,
I want to define a new set from two sets. In my example:
s,m,i,j are sets
alias(i,j)
Of i and j there is a subset: dummy_TS(i) and dummy_TS(j) respectively
defined sets: f(s,m,i,j) and h(dummy_TS)
Now I want to define a new set: t(s,dummy_TS)
s shall always be assigned to dummy_TS if at f(s,m,i,j) s is assigned to the subset dummy_TS over i or j.
I have already tried to work by means of intersection, but I have encountered a bunch of syntax errors.
I hope someone can help me
Many greetings
Janisch
Set Operations Topic is solved
Re: Set Operations
Many things need to be clarified in the question before looking for the right answer.
1. "s shall always be assigned to dummy_TS" but dummy_TS is a subset of i. you cannot assign s to it.
2. "if at f(s,m,i,j) s is assigned to the subset dummy_TS": at any value of m, i, j/all values of m, i, j? is f a function? if yes, how can f(s, m, i, j) be a set? You don't need alias to define s, m ,i, j you could say s, m ,i, i
3. "over i or j" both are aliases.
Best to give a small example.
- Atharv
1. "s shall always be assigned to dummy_TS" but dummy_TS is a subset of i. you cannot assign s to it.
2. "if at f(s,m,i,j) s is assigned to the subset dummy_TS": at any value of m, i, j/all values of m, i, j? is f a function? if yes, how can f(s, m, i, j) be a set? You don't need alias to define s, m ,i, j you could say s, m ,i, i
3. "over i or j" both are aliases.
Best to give a small example.
- Atharv
Re: Set Operations
Hey Atharv,
f(s,m,i,j) is not a function. It is a set.
here a short example:
set i respectively j: set h(dummy_TS): set f(s,m,i,j): The solution should be: t(s, dummy_TS) = /Bet.TransferB, Middlegate.terminalC_d, Alliance_Europe.terminalE_d, Top.TransferB, Top.TransferA)
I hope this has made it more understandable.
f(s,m,i,j) is not a function. It is a set.
here a short example:
set i respectively j: set h(dummy_TS): set f(s,m,i,j): The solution should be: t(s, dummy_TS) = /Bet.TransferB, Middlegate.terminalC_d, Alliance_Europe.terminalE_d, Top.TransferB, Top.TransferA)
I hope this has made it more understandable.
Re: Set Operations
If an element in i or j columns of set f exist in set h (which is a subset of dummy_ts, not sure if this is needed or makes sense) then you want to include that element in set t. This can be done as follows.
It is not clear why you would want h(dummy_ts) which is a subset of a subset. You can simply have h(i) and populate it as needed.
- Atharv
Code: Select all
set f(s, m ,i, i);
f(s, m, i, i)$(dummy_ts(i))=yes;
Code: Select all
h(i)$(dummy_ts(i)) =yes;
Re: Set Operations
I want to achieve that I automatically know which c is assigned to a dummy_TS and only the combinations I want to have in this set t(s,dummy_TS).
Re: Set Operations
Let me reframe your question:
You need t(s, i) only when i is in dummy_ts and i is in 'any' two of the last two columns of f.
It is much clearer now that you need to create another set to tell you whether a given i exists in the last two columns of set f.
Let's say that set is fprojected(i) that contains all i elements in set f.
It is then easy to populate set t(s, i) as follows:
The only question now is to get the set fprojected. There are many ways but one the elegant ways is to use projections.
Hope this answers your question.
- Atharv
You need t(s, i) only when i is in dummy_ts and i is in 'any' two of the last two columns of f.
It is much clearer now that you need to create another set to tell you whether a given i exists in the last two columns of set f.
Let's say that set is fprojected(i) that contains all i elements in set f.
It is then easy to populate set t(s, i) as follows:
Code: Select all
t(s, i)$(dummy_ts(i) and fprojected(i)) =yes;
Code: Select all
*To get i in fourth column
set f1(i);
f1 < f;
* To get i from third column
set f2(i) <= f;
*Union of two sets
fprojected(i)$(f1(i) and f2(i)) = yes;
- Atharv
Re: Set Operations
Yes, exactly. But unfortunately my code example does not work when I try to implement your solution. Something is wrong with the syntax.
Here is my example:
Here is my example:
Code: Select all
SET f_c_r(s,m,i,j);
SET dummy_TS(i);
SET fprojected(i)
SET t(s,i);
set f1(i);
*To get i in fourth column
f1(i) <= f_c_r;
set f2(i);
*To get i from third column
f2 <= f;
*Union of two sets
fprojected(i)$(f1(i) and f2(i)) = yes;
t(s, i)$(dummy_ts(i) and fprojected(i)) =yes;
Re: Set Operations
There are a couple of typos in my previous comment. Following code works.
- Atharv
Code: Select all
set
s /s1*s5/
m /m1*m4/
i /i1*i8/
dummy_ts(i) /i2, i6, i7/
h(dummy_ts) /i2, i6, i7/
;
display
dummy_ts
h;
alias(i, j);
set
f(s, m, i, i);
f(s, m, 'i2', 'i6') = yes;
sets
fprojected1(i)
fprojected2(i)
fprojected(i);
*fprojected1 = sum((ii, s, m), f(s, m, ii,i )
option fprojected1 < f;
option fprojected2 <= f;
fprojected(i)$(fprojected1(i) or fprojected2(i))= yes;
display fprojected;
f(s, m ,i, i)$(dummy_ts(i))=yes;
set t(s, i);
t(s, i)$(dummy_ts(i) and fprojected(i))= yes;
*f(s, m ,i, i)$(h(dummy_ts))=yes;
display t;