Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No triggering_status in NodeNumericalAttribute ? #198

Open
JustinLouazel opened this issue May 9, 2021 · 1 comment
Open

No triggering_status in NodeNumericalAttribute ? #198

JustinLouazel opened this issue May 9, 2021 · 1 comment

Comments

@JustinLouazel
Copy link

Hello !
I'm currently a engineer student and I'm using NdLib for a project. I'm quite new to NdLib so I strongly hope my question/bug report is relevant. In short, I think the class NodeNumericalAttribute has no parameter "triggering_status" as indicated in the documentation.

I'm using Ubuntu 20.04.2, NDLib 5.1.0 and Python 3.8.

I wanted to use NodeNumericalAttribute in order to build a specific epidemic model where you need to test whether to person is vaccinated or not to move from a status to an other. Though, as I looked into the source code of the class NodeNumericalAttribute, I did not find any mention of "triggering_status". I decided to check by myself with the code below. I expected that the two rules c1 ( the one in commentary and the actual one) would do the exact same thing, as all of my nodes have an age between 0 and 100. Yet, when you run this code with a condition and the other, you get the graphs shown below.
vm=MultiPlot()
g = nx.erdos_renyi_graph(1000,0.001)

# Setting edge attribute
attr = {n: {"Age": random.choice(range(0, 100))} for n in g.nodes()}
nx.set_node_attributes(g, attr)

# Composite Model instantiation
model = gc.CompositeModel(g)

# Model statuses
model.add_status("Susceptible")
model.add_status("Infected")
model.add_status("Removed")

# Compartment definition
# c1a = cpm.NodeNumericalAttribute("Age", value=[0, 100], op="IN", probability=1,triggering_status="Infected")
c1b = cpm.NodeStochastic(1,triggering_status="Infected")

c2 = cpm.NodeStochastic(0.01)

# Rule definition
model.add_rule("Susceptible", "Infected", c1b)
model.add_rule("Infected", "Removed", c2)

# Model initial status configuration
config = mc.Configuration()
config.add_model_parameter('fraction_infected', 0.1)

# Simulation execution
model.set_initial_status(config)
iterations = model.iteration_bunch(100)
trends = model.build_trends(iterations)

Capture d’écran du 2021-05-09 17-57-48
Capture d’écran du 2021-05-09 17-58-38

Thus, I wonder if the parameter "triggering_status" actually is implemented in NodeNumericalAttribute ? By the way, I think the issue is the same for NodeNumericalVariable.

I really hope the answer to the question is not obvious and I thank you by advance for your help.
Have a good day,
Justin

@JustinLouazel
Copy link
Author

Hello !
Just to give a quick update, I created a new class NodeNumericalAttribute where a triggering state is taken into account and it seems to work pretty well. There may be a more correct way to do it but it seems to work pretty well for the moment.
Have a good day,
Justin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant