1 %feature("docstring") gum::InfluenceDiagram
2 "
3 InfluenceDiagram represents an Influence Diagram.
4 
5 InfluenceDiagram() -> InfluenceDiagram
6     default constructor
7 
8 InfluenceDiagram(source) -> InfluenceDiagram
9     Parameters:
10         * **source** (*pyAgrum.InfluenceDiagram*) -- the InfluenceDiagram to copy
11 "
12 
13 %feature("docstring") gum::InfluenceDiagram::add
14 "
15 Add a chance variable, it's associate node and it's CPT.
16 
17 The id of the new variable is automatically generated.
18 
19 Parameters
20 ----------
21 variable : pyAgrum.DiscreteVariable
22 	The variable added by copy.
23 id : int
24 	The chosen id. If 0, the NodeGraphPart will choose.
25 
26 Warnings
27 --------
28 give an id (not 0) should be reserved for rare and specific situations !!!
29 
30 Returns
31 -------
32 int
33     the id of the added variable.
34 
35 Raises
36 ------
37 pyAgrum.DuplicateElement
38 	If id(<>0) is already used
39 "
40 
41 %feature("docstring") gum::InfluenceDiagram::addArc
42 "
43 Add an arc in the ID, and update diagram's potential nodes cpt if necessary.
44 
45 Parameters
46 ----------
47 tail : int
48   the id of the tail node
49 head : int
50   the id of the head node
51 
52 Raises
53 ------
54 pyAgrum.InvalidEdge
55 	If arc.tail and/or arc.head are not in the ID.
56 pyAgrum.InvalidEdge
57 	If tail is a utility node
58 "
59 
60 %feature("docstring") gum::InfluenceDiagram::addChanceNode
61 "
62 Add a chance variable, it's associate node and it's CPT.
63 
64 The id of the new variable is automatically generated.
65 
66 Parameters
67 ----------
68 variable : pyAgrum.DiscreteVariable
69 	the variable added by copy.
70 id : int
71 	the chosen id. If 0, the NodeGraphPart will choose.
72 
73 Warnings
74 --------
75 give an id (not 0) should be reserved for rare and specific situations !!!
76 
77 Returns
78 -------
79 int
80     the id of the added variable.
81 
82 Raises
83 ------
84 pyAgrum.DuplicateElement
85 	If id(<>0) is already used
86 "
87 
88 %feature("docstring") gum::InfluenceDiagram::addDecisionNode
89 "
90 Add a decision variable.
91 
92 The id of the new variable is automatically generated.
93 
94 Parameters
95 ----------
96 variable : pyAgrum.DiscreteVariable
97 	the variable added by copy.
98 id : int
99 	the chosen id. If 0, the NodeGraphPart will choose.
100 
101 Warnings
102 --------
103 give an id (not 0) should be reserved for rare and specific situations !!!
104 
105 Returns
106 -------
107 int
108     the id of the added variable.
109 
110 Raises
111 ------
112 pyAgrum.DuplicateElement
113 	If id(<>0) is already used
114 "
115 
116 %feature("docstring") gum::InfluenceDiagram::addUtilityNode
117 "
118 Add a utility variable, it's associate node and it's UT.
119 
120 The id of the new variable is automatically generated.
121 
122 Parameters
123 ----------
124 variable : pyAgrum.DiscreteVariable
125 	the variable added by copy
126 id : int
127 	the chosen id. If 0, the NodeGraphPart will choose
128 
129 Warnings
130 --------
131 give an id (not 0) should be reserved for rare and specific situations !!!
132 
133 Returns
134 -------
135 int
136     the id of the added variable.
137 
138 Raises
139 ------
140 pyAgrum.InvalidArgument
141 	If variable has more than one label
142 pyAgrum.DuplicateElement
143 	If id(<>0) is already used
144 "
145 
146 %feature("docstring") gum::InfluenceDiagram::arcs
147 "
148 Returns
149 -------
150 list:
151 	the list of all the arcs in the Influence Diagram.
152 "
153 
154 %feature("docstring") gum::InfluenceDiagram::chanceNodeSize
155 "
156 Returns
157 -------
158 int
159 	the number of chance nodes.
160 "
161 
162 %feature("docstring") gum::InfluenceDiagram::changeVariableName
163 "
164 Parameters
165 ----------
166 id : int
167 	the node Id
168 new_name : str
169 	the name of the variable
170 
171 Raises
172 ------
173 pyAgrum.DuplicateLabel
174 	If this name already exists
175 pyAgrum.NotFound
176 	If no nodes matches id.
177 "
178 
179 %feature("docstring") gum::InfluenceDiagram::children
180 "
181 Parameters
182 ----------
183 id : int
184   the id of the parent
185 
186 Returns
187 -------
188 Set
189 	the set of all the children
190 "
191 
192 %feature("docstring") gum::InfluenceDiagram::cpt
193 "
194 Returns the CPT of a variable.
195 
196 Parameters
197 ----------
198 VarId : int
199 	A variable's id in the pyAgrum.BayesNet.
200 
201 Returns
202 -------
203 pyAgrum.Potential
204 	The variable's CPT.
205 
206 Raises
207 ------
208 pyAgrum.NotFound
209 	If no variable's id matches varId.
210 "
211 
212 %feature("docstring") gum::InfluenceDiagram::decisionNodeSize
213 "
214 Returns
215 -------
216 int
217 	the number of decision nodes
218 "
219 
220 %feature("docstring") gum::InfluenceDiagram::decisionOrderExists
221 "
222 Returns
223 -------
224 bool
225 	True if a directed path exist with all decision node
226 "
227 
228 %feature("docstring") gum::InfluenceDiagram::erase
229 "
230 Erase a Variable from the network and remove the variable from all his childs.
231 
232 If no variable matches the id, then nothing is done.
233 
234 Parameters
235 ----------
236 id : int
237 	The id of the variable to erase.
238 var : pyAgrum.DiscreteVariable
239 	The reference on the variable to remove.
240 "
241 
242 %feature("docstring") gum::InfluenceDiagram::eraseArc
243 "
244 Removes an arc in the ID, and update diagram's potential nodes cpt if necessary.
245 
246 If (tail, head) doesn't exist, the nothing happens.
247 
248 Parameters
249 ----------
250 arc : pyAgrum.Arc
251 	The arc to be removed.
252 tail : int
253   the id of the tail node
254 head : int
255   the id of the head node
256 "
257 
258 %feature("docstring") gum::InfluenceDiagram::existsPathBetween
259 "
260 Returns
261 -------
262 bool
263 	true if a path exists between two nodes.
264 "
265 
266 %feature("docstring") gum::InfluenceDiagram::getDecisionGraph
267 "
268 Returns
269 -------
270 pyAgrum.DAG
271 	the temporal Graph.
272 "
273 
274 %feature("docstring") gum::InfluenceDiagram::getDecisionOrder
275 "
276 Returns
277 -------
278 list
279 	the sequence of decision nodes in the directed path.
280 
281 Raises
282 ------
283 NotFound
284 	If such a path does not exist
285 "
286 
287 %feature("docstring") gum::InfluenceDiagram::idFromName
288 "
289 Returns a variable's id given its name.
290 
291 Parameters
292 ----------
293 name : str
294 	the variable's name from which the id is returned.
295 
296 Returns
297 -------
298 int
299 	the variable's node id.
300 
301 Raises
302 ------
303 pyAgrum.NotFound
304 	If no such name exists in the graph.
305 "
306 
307 %feature("docstring") gum::InfluenceDiagram::ids
308 "
309 .. note:: Deprecated in pyAgrum>0.13.0
310     Please use nodes() instead
311 "
312 
313 %feature("docstring") gum::InfluenceDiagram::nodes
314 "
315 Returns
316 -------
317 set
318     the set of ids
319 "
320 
321 %feature("docstring") gum::InfluenceDiagram::isChanceNode
322 "
323 Parameters
324 ----------
325 varId : int
326 	the tested node id.
327 
328 Returns
329 -------
330 bool
331 	true if node is a chance node
332 "
333 
334 %feature("docstring") gum::InfluenceDiagram::isDecisionNode
335 "
336 Parameters
337 ----------
338 varId : int
339 	the tested node id.
340 
341 Returns
342 -------
343 bool
344 	true if node is a decision node
345 "
346 
347 %feature("docstring") gum::InfluenceDiagram::isUtilityNode
348 "
349 Parameters
350 ----------
351 varId : int
352 	the tested node id.
353 
354 Returns
355 -------
356 bool
357 	true if node is an utility node
358 "
359 
360 %feature("docstring") gum::InfluenceDiagram::loadBIFXML
361 "
362 Load a BIFXML file.
363 
364 Parameters
365 ----------
366 name : str
367 	the name's file
368 
369 Raises
370 ------
371 pyAgrum.IOError
372 	If file not found
373 pyAgrum.FatalError
374 	If file is not valid
375 "
376 
377 %feature("docstring") gum::InfluenceDiagram::names
378 "
379 Returns
380 -------
381 list
382 	The names of the InfluenceDiagram variables
383 "
384 
385 
386 %feature("docstring") gum::InfluenceDiagram::nodeId
387 "
388 Parameters
389 ----------
390 var : pyAgrum.DiscreteVariable
391 	a variable
392 
393 Returns
394 -------
395 int
396 	the id of the variable
397 
398 Raises
399 ------
400 pyAgrum.IndexError
401 	If the InfluenceDiagram does not contain the variable
402 "
403 
404 %feature("docstring") gum::InfluenceDiagram::parents
405 "
406 Parameters
407 ----------
408 id :
409 	The id of the child node
410 
411 Returns
412 -------
413 set
414     the set of the parents ids.
415 "
416 
417 %feature("docstring") gum::InfluenceDiagram::saveBIFXML
418 "
419 Save the BayesNet in a BIFXML file.
420 
421 Parameters
422 ----------
423 name : str
424 	the file's name
425 "
426 
427 %feature("docstring") gum::InfluenceDiagram::toDot
428 "
429 Returns
430 -------
431 str
432     a friendly display of the graph in DOT format
433 "
434 
435 %feature("docstring") gum::InfluenceDiagram::utility
436 "
437 Parameters
438 ----------
439 varId : int
440 	the tested node id.
441 
442 Returns
443 -------
444 pyAgrum.Potential
445 	the utility table of the node
446 
447 Raises
448 ------
449 pyAgrum.IndexError
450 	If the InfluenceDiagram does not contain the variable
451 "
452 
453 %feature("docstring") gum::InfluenceDiagram::utilityNodeSize
454 "
455 Returns
456 -------
457 int
458 	the number of utility nodes
459 "
460 
461 %feature("docstring") gum::InfluenceDiagram::variable
462 "
463 Parameters
464 ----------
465 id : int
466  	the node id
467 
468 Returns
469 ------
470 pyAgrum.DiscreteVariable
471 	a constant reference over a variabe given it's node id
472 
473 Raises
474 ------
475 pyAgrum.NotFound
476 	If no variable's id matches the parameter
477 "
478 
479 %feature("docstring") gum::InfluenceDiagram::variableFromName
480 "
481 Parameters
482 ----------
483 name : str
484 	a variable's name
485 
486 Returns
487 -------
488 pyAgrum.DiscreteVariable
489 	the variable
490 
491 Raises
492 ------
493 pyAgrum.IndexError
494 	If the InfluenceDiagram does not contain the variable
495 "
496 
497 %feature("docstring") gum::InfluenceDiagram::variableNodeMap
498 "
499 TBD
500 "
501 
502 %feature("docstring") gum::InfluenceDiagram::fastPrototype
503 "
504 Create an Influence Diagram with a dot-like syntax which specifies:
505     - the structure 'a->b<-c;b->d;c<-e;'.
506     - a prefix for the type of node (chance/decision/utiliy nodes):
507 
508       - `a` : a chance node named 'a' (by default)
509       - `$a` : a utility node named 'a'
510       - `*a` : a decision node named 'a'
511 
512     - the type of the variables with different syntax as postfix:
513 
514       - by default, a variable is a pyAgrum.RangeVariable using the default domain size (second argument)
515       - with `'a[10]'`, the variable is a pyAgrum.RangeVariable using 10 as domain size (from 0 to 9)
516       - with `'a[3,7]'`, the variable is a pyAgrum.RangeVariable using a domainSize from 3 to 7
517       - with `'a[1,3.14,5,6.2]'`, the variable is a pyAgrum.DiscretizedVariable using the given ticks (at least 3 values)
518       - with `'a{top|middle|bottom}'`, the variable is a pyAgrum.LabelizedVariable using the given labels.
519       - with 'a{-1|5|0|3}', the variable is a pyAgrum.IntegerVariable using the sorted given values.
520 
521 Note
522 ----
523   - If the dot-like string contains such a specification more than once for a variable, the first specification will be used.
524   - the potentials (probabilities, utilities) are randomly generated.
525   - see also pyAgrum.fastID.
526 
527 Examples
528 --------
529 >>> import pyAgrum as gum
530 >>> bn=pyAgrum.fastID('A->B[1,3]<-*C{yes|No}->$D<-E[1,2.5,3.9]',6)
531 
532 Parameters
533 ----------
534 dotlike : str
535         the string containing the specification
536 domainSize : int
537         the default domain size for variables
538 
539 Returns
540 -------
541 pyAgrum.InfluenceDiagram
542         the resulting Influence Diagram
543 "
544