Hello everyone,
I have a code with a certain number of agents where the state of one agent at time ‘t’ is dependent on the state of one or more other agents at time ‘t - 1’.
Is it possible to automatically generate a dependency network in python for this system? By dependency network, I mean a directed network where an arrow from node B to node A shows that A is dependent on B (A takes input from B). (Something like citation network)
Thanks.
This question requires some more information. Is this a NetLogo model which you want to then export a network from to python? If so, what is the NetLogo model and how are the dependencies represented there?
1 Like
Do you want to share some code or a skeleton model? You can use ``` to wrap up the code like in Markdown, and the forum will show a pretty syntax highlighting. Or you can even upload NetLogo models as files
1 Like
Thanks for replies. This is a NetLogo model. Following code is taken from the model:
;Update system controller action
let culture-val [state] of one-of turtles with [feature = "Safety Culture"]
let corr-act-val [state] of one-of turtles with [feature = "Inspection corrective
action"]
let mon-corr-act-val [state] of one-of turtles with [feature = "Monitor action taken"]
let penal-val [state] of one-of turtles with [feature = "Strong Penalty"]
;set compliance value
set compliance max list culture-val (corr-act-val * mon-corr-act-val * penal-val)
;set monitoring of residual chlorine
ask one-of turtles with [feature = "Monitor residual chlorine"]
[
set state state * compliance
]
;set monitoring of E-coli value
ask one-of turtles with [feature = "Monitor E.Coli level"]
[
set state state * compliance
]
Feature refers to the name of the turtle or agent. In the given model, the agents represent the controls in a system. Safety Culture, Strong Penalty etc. are agents that represent controls.
The variable ‘Compliance’ takes the maximum value among Safety Culture and product of three other agent states namely Inspection Corrective Action, Monitor Action Taken and Strong Penalty. Thus, the variable ‘Compliance’ takes input from the four agents.
The agent ‘Monitor residual chlorine’ control takes input from ‘Compliance’. That is, it in turn depends on the four above mentioned agents (‘Compliance’ is only an intermediate variable).
Therefore, in the dependency network, there should an arrow from each of the above four agents to ‘Monitor residual chlorine’ agent. That is, the state of ‘Monitor residual chlorine’ agent depends upon the state of four other agents.
Hope I was able to better describe the problem.
The objective is to perform network analysis on this derived dependency network. I can manually create the network for small models. But this approach can be difficult for models with many numbers of agents.
Thanks.
Hi @Pradeesh, sorry I didn’t see this until now for some reason.
Is there a reason you aren’t using links to to directly represent the dependency network?
You could then use the network extension to export the network and use whatever software you are using for network analysis.
Thanks for the reply, @jzkelter. I didn’t use links within the model as the dependency network is not a core requirement for running the model. That is, I can run the model even without the dependency network. The network provides additional information useful for analysis.
However, now I think that I could add an additional line of code for each agent within the Go procedure such that it creates directed links from other agents if it uses information from these agents for updating one or more of its state variables. This could be programed to run only once, during the first tick.
Thanks
Yeah that makes sense. If that network never changes, you could even just save the network and then delete all the links afterwards if you don’t want them there for the rest of the model run.
1 Like