The DMN API reference

Copyright 2020 Simon Vandevelde, Joost Vennekens This code is licensed under GNU GPLv3 license (see LICENSE) for more information. This file is part of the cDMN solver.

class API.DMN(path: str = None, xml: str = None, auto_propagate: bool = False)[source]

A class representing DMN objects.

Parameters:
  • _specification (str) – the xml specification
  • variables (Dict[str]: cdmn.API.Variable) – a dict containing all the variables found in the specification
  • prop_variables – a dict containing the values of propagated variables
  • dependency_tree (Dict[str]: List[str]) – a dictionary containing for every variable what other variables define it
  • _idp (Dict[str]: str) – a dictionary containing the IDP blocks
clear()[source]

Reset all variables’ values back to None.

Returns:None
Return type:Nono
dependencies_of(var: str)[source]

Returns the list of dependencies of a variable.

Parameters:var (str) – the name of the variable
Returns:list of variable dependencies
Return type:List[str]
get_all_values(propagated: bool = True)[source]

Get a dictionary mapping every variable on their value. If the value is not known, it is None. If propagated is True, then we also include the values of propagated variables. Else, we exclude them, and set them as None.

Parameters:propagated (bool) – True if propagated variables are included.
Returns:dict mapping variables on their (propagated) values.
Return type:Dict[str, str]
get_certain_variables()[source]

Get a list of all the variables for which the value is known.

Returns:list of variables for which the value is known
Return type:List[str]
get_inputs()[source]

Get a list of the input variables.

Returns:the list of inputs
Return type:List[str]
get_intermediary()[source]

Get a list of intermediary variables. An intermediary variable is a variable that is not

Returns:list of intermediary variables
Return type:List[str]
get_outputs()[source]

Get a list of the output variables.

Returns:list of the output variables
Return type:List[str]
get_unknown_variables()[source]

Get a list of all variables with unknown values

Returns:the list of variables that are still missing
Return type:List[str]
get_variable_names() → List[T][source]

Get all variable names.

Returns:a list containing all variable names.
Return type:List[str]
idp

Getter for idp.

Returns:the idp code
Return type:str
is_certain(var: str)[source]

Method to check if a variable is certain. A variable is certain if it has been given a value using set_value, or if it has been propagated a value (i.e. all of the symbols it depends on are also certain)

Parameters:var (str) – the variable
Returns:whether the variable’s value is certain
Return type:bool
maximize(term)[source]

Method to optimize

minimize(term)[source]

Method to optimize

missing_for(variable: str)[source]

Get a list of dependencies of varuable without known value.

Parameters:variable (str) –
Returns:list of variables needed that are still unknown
Return type:List[str]
model_expand(models=10)[source]

Method to model expand the current system

possible_values_of(var: str) → List[T][source]

Returns the possible values of a variable. Only strings have a set of possible values in DMN.

Parameters:var (Variable) – the variable
Returns:list of possible values
Return type:List[str]
propagate()[source]

Method to propagate.

Returns:None
Return type:None
Throws NotSatisfiableError:
 thrown when model resulted in unsat
set_value(variable: str, value)[source]

Set a variable’s value.

Parameters:
  • variable (str) – the name of the variable
  • value (str or int) – the value for the variable
specification

Getter for specification.

Returns:the specification
Return type:str
update_structure()[source]

Method to generate the structure. If a variable has been assigned a value, it should be included in the structure.

This method also updates the struct value in _idp.

Returns:the structure
Return type:str
exception API.DMNError[source]

Base class for all DMN-related exceptions

exception API.NotSatisfiableError[source]

Error thrown when unsat

class API.Variable(name: str, var_type: str, logical_type: str, possible_values: List[T], dependent_on: Dict[KT, VT], dependency_of: Dict[KT, VT])[source]

Class representing (c)DMN variables. On top of variable name, type, logical type and value, we also gather what dependencies (both upstream and downstream) a variable has.

Parameters:
  • name (str) – the name of the variable
  • type (str) – if the variable is a constant, the type can be string, integer, float. If the variable is a boolean, the type is None.
  • logical_type (str) – the variable type from a logical viewpoint. This can be boolean, constant, predicate or function.
  • value (List[str]) – the value that a symbol has.
  • possible_values – a list containing possible values. This list is only relevant for symbols with type string.
  • dependent_on (List[str]) – a Dict of symbols on which this variable depends, together with their ‘dependency level’
  • dependency_of (List[str]) – a Dict of symbols that depend on this variable, together with their ‘dependency level’