InfluenceDiagram.fastPrototype
- static InfluenceDiagram.fastPrototype(*args)
- Create an Influence Diagram with a dot-like syntax which specifies:
the structure ‘a->b<-c;b->d;c<-e;’.
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’
the type of the variables with different syntax as postfix:
by default, a variable is a
pyagrum.RangeVariableusing the default domain size (second argument)with
'a[10]', the variable is apyagrum.RangeVariableusing 10 as domain size (from 0 to 9)with
'a[3,7]', the variable is apyagrum.RangeVariableusing a domainSize from 3 to 7with
'a[1,3.14,5,6.2]', the variable is apyagrum.DiscretizedVariableusing the given ticks (at least 3 values)with
'a{top|middle|bottom}', the variable is apyagrum.LabelizedVariableusing the given labels.with ‘a{-1|5|0|3}’, the variable is a
pyagrum.IntegerVariableusing the sorted given values.with ‘a{-0.5|5.01|0|3.1415}’, the variable is a
pyagrum.NumericalDiscreteVariableusing the sorted given values.
Notes
If the dot-like string contains such a specification more than once for a variable, the first specification will be used.
a name may be written between single quotes (
'Visit Asia'{yes|no}, a doubled quote standing for a quote), after the prefix (*'my decision'); a quoted name beginning with*or$is a chance node.the tensors (probabilities, utilities) are randomly generated.
see also
pyagrum.fastID.
- Parameters:
dotlike (
str) – the string containing the specificationdomainSize (
int | str) – the default domain size or the default domain for variables
- Returns:
the resulting Influence Diagram
- Return type:
Example
import pyagrum as gum
diag = gum.InfluenceDiagram.fastPrototype("C{low|high}->*D[3]->$U<-C")
diag.chanceNodeSize(), diag.decisionNodeSize(), diag.utilityNodeSize()
# (1, 1, 1)
print(diag.variable("D"))
# D:Range([0,2])
# the second argument is the default domain size of the variables without specification
diag = gum.InfluenceDiagram.fastPrototype("A->B[1,3]<-*C{yes|No}->$D<-E[1,2.5,3.9]", 6)
print(diag.variable("A"))
# A:Range([0,5])
print(diag.variable("E"))
# E:Discretized(<[1;2.5[,[2.5;3.9]>)
# a name between single quotes, after the prefix of its type
infdiag = gum.InfluenceDiagram.fastPrototype("'my state'->*'my decision'->$'my utility'")
infdiag.isUtilityNode("my utility")
# True
Class