I have a model with banks. Each bank is linked to all other banks by a special breed of undirected link called "riskshares". Each bank also has links to other types of agents. Each bank has a list of countries where it operates. The list is called "op-countries-list", which does not have a fixed length, and both its length and countries are randomly picked. For example, one bank might have "op-countries-list" of length 5 = "Australia, Italy, Spain, Canada, Brazil", and another bank might have "op-countries-list" of length 2= "Italy, France". Now: I need to change to "TRUE" one boolean attribute of the "riskshare" link, depending on whether there is one common country in the "op-countries-list" of the two banks linked by the "riskshare".
I have (among other things):
banks-own [op-country-list]
riskshares-own [same-country-op?]
And I am trying this approach:
ask banks [ foreach op-country-list ifelse member? op-country-list of other-end [set same-country-op? of my-out-riskshare true] ]
With this, I get an "OF expected input to be a reporter" error. I think I should come up with a to-report procedure and then use it, but I am not sure how to do it in this case. In addition, I am not sure how to specify that I want other-end to look into the "riskshare" kind of link, and not all other links that the bank has.
Do you have any suggestions?
There is definitely a way to do it with
foreachas you're getting at, but you might findmapa little more appropriate in this case.mapwill iterate over items in a list and do "something"- in this case, you could check for membership in the list of interest. More detail in comments below:This toy model (with the
random-seedas is) gives an output like:Which I think meets the conditions you outline. Hopefully that gets you pointed in the right direction!