Page 1 of 1

How can I make this set?

Posted: Fri Apr 26, 2019 10:11 am
by linkho
Hi,
let s be a index of scenario and j index of Network Nodes.(s={1*200} , j={1*100})
d(s,j)= total impacts of contamination scenario s, if the contaminant is first detected by scenario at j.
W(s)=the subset of Network Nodes which d(s,j)<>0.
W'(s)= the subset of W(s) such that d(s,j)<>d(s,j') , for all j,j' belong to W'(s).

How can I make the subset W'(s)?
I attached data related to parameter d(s,j) too.

Thanks in advance!

Re: How can I make this set?

Posted: Sat Apr 27, 2019 7:22 am
by bussieck
Here is the code:

Code: Select all

set s /1*200/, j /1*100/;
parameter d(s,j);
d(s,j)$(uniform(0,1)<0.05) = uniformInt(1,10);
*W(s)=the subset of Network Nodes which d(s,j)<>0.
*W'(s)= the subset of W(s) such that d(s,j)<>d(s,j') , for all j,j' belong to W'(s).
set W(s,j), Wuniq(s,j);

W(s,j) = d(s,j);
Wuniq(s,j) = W(s,j);
* Knock out the duplicate ones
alias (j,jj);
loop((s,j,jj)$(W(s,j) and W(s,jj) and ord(jj)>ord(j) and d(s,j)=d(s,jj)), Wuniq(s,jj) = no);
-Michael

Re: How can I make this set?

Posted: Sat Apr 27, 2019 2:20 pm
by linkho
Thanks so much !