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:

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 specification

  • domainSize (int | str) – the default domain size or the default domain for variables

Returns:

the resulting Influence Diagram

Return type:

pyagrum.InfluenceDiagram

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

InfluenceDiagram