fastID
- pyagrum.fastID(structure, domain='[2]')
- Create an Influence Diagram with a modified dot-like syntax which specifies:
the structure and the type of the variables following fast syntax,
a prefix for the type of node (chance/decision/utiliy nodes):
a: a chance node named ‘a’ (by default)$a: a utility node named ‘a’*a: a decision node named ‘a’
names possibly between single quotes, after the prefix (
"'my state'->*'my decision'->$'my utility'").
- Parameters:
structure (
str) – the string containing the specificationdomain (
int | str) – the default domain size (int) or domain specification (str) for variables (default is “[2]”
- Returns:
the resulting Influence Diagram
- Return type:
Example
import pyagrum as gum
infdiag = gum.fastID("Weather->*Umbrella->$Comfort<-Weather")
infdiag.isDecisionNode("Umbrella")
# True
infdiag.isUtilityNode("Comfort")
# True
infdiag.isChanceNode("Weather")
# True
# the second argument is the default domain size of the variables without specification
infdiag = gum.fastID("A->B[1,3]<-*C{yes|No}->$D<-E[1,2.5,3.9]", 6)
print(infdiag.variable("A"))
# A:Range([0,5])
print(infdiag.variable("C"))
# C:Labelized({yes|No})
print(infdiag.variable("D")) # a utility node has a single value
# D:Range([0,0])
# a name between single quotes, after the prefix of its type
infdiag = gum.fastID("'my state'->*'my decision'->$'my utility'")
infdiag.isDecisionNode("my decision")
# True