clingo#

a2edgetuple#

gunfolds.conversions.a2edgetuple(answer)[source]#

Converts the output of clingo into list of edges and under sampling rates for drasl

Parameters:

answer (string) – output of clingo

Returns:

list of edges and under sampling rates

Return type:

a tuple of lists

c2edgepairs#

gunfolds.conversions.c2edgepairs(clist)[source]#

Converts clingo predicates to edge pairs for drasl

Parameters:

clist (list of strings) – clingo predicates

Returns:

list of edge pairs

Return type:

list

clingo2num#

gunfolds.conversions.clingo2num(value)[source]#

Converts the output of clingo into list of edges and under sampling rates for drasl

Parameters:

value (string) – output of clingo

Returns:

list of edges and under sampling rates

Return type:

a tuple of lists

clingo_preamble#

gunfolds.conversions.clingo_preamble(g)[source]#

Converts number of nodes into a clingo predicate

Parameters:

g (dictionary (gunfolds graphs)) – gunfolds graph

Returns:

clingo predicate

Return type:

string

clingo_wedge#

gunfolds.conversions.clingo_wedge(x, y, w, n, name='edge')[source]#

Returns clingo predicate for weighted edge

Parameters:
  • x (integer) – outgoing edge

  • y (integer) – incoming edge

  • w (integer) – weight

  • n (integer) – number of nodes

  • name (string) – name of the variable for clingo

Returns:

clingo predicate for weighted edge

Return type:

string

drasl_jclingo2g#

gunfolds.conversions.drasl_jclingo2g(output_g)[source]#

Converts the output of clingo to gunfolds graph for drasl

Parameters:

output_g (string) – the output of clingo for drasl

Returns:

gunfolds graph

Return type:

dictionary (gunfolds graph)

encode_list_sccs#

gunfolds.conversions.encode_list_sccs(glist, scc_members=None)[source]#

Encodes strongly connected components of a list of gunfolds graph to clingo predicates

Parameters:
  • glist (list of dictionaries (gunfolds graphs)) – a list of graphs that are under sampled versions of the same system

  • scc_members (list) – a list of dictionaries for nodes in each SCC

Returns:

clingo predicates

Return type:

string

encode_sccs#

gunfolds.conversions.encode_sccs(g, idx, components=True, SCCS=None)[source]#

Encodes strongly connected components of gunfolds graph to clingo predicates

Parameters:
  • g (dictionary (gunfolds graphs)) – gunfolds graph

  • idx (integer) – index of the graph

  • components (boolean) – If True, encodes SCC components and memberships to clingo predicates

  • SCCS (list) – SCC membership of nodes

Returns:

clingo predicates

Return type:

string

g2clingo#

gunfolds.conversions.g2clingo(g, directed='hdirected', bidirected='hbidirected', both_bidirected=False, preamble=True)[source]#

Convert a graph to a string of grounded terms for clingo

Parameters:
  • g (dictionary (gunfolds graphs)) – gunfolds graph

  • directed (string) – name of the variable for directed edges in the observed graph

  • bidirected (string) – name of the variable for bidirected edges in the observed graph

  • both_bidirected (boolean) – (Ask)

  • preamble (boolean) – (Ask)

Returns:

clingo predicate

Return type:

string

Example: {1:{3:1,4:2,5:3}}
"1": node 1 has an edge with node 3 => edge(1,3).
"2": node 1 has an conf with node 4 => conf(1,4).
"3": node 1 has both edge and conf with node 5 => edge(1,5). conf(1,5).

g2wclingo#

gunfolds.conversions.g2wclingo(g)[source]#

Convert a graph to a string of grounded terms for clingo

Parameters:

g (dictionary (gunfolds graphs)) – gunfolds graph

Returns:

clingo predicate

Return type:

string

msl_jclingo2g#

gunfolds.conversions.msl_jclingo2g(output_g)[source]#

Converts the output of clingo to gunfolds graph for rasl_msl

Parameters:

output_g (string) – the output of clingo for rasl_msl

Returns:

gunfolds graph

Return type:

dictionary (gunfolds graph)

numbered_g2clingo#

gunfolds.conversions.numbered_g2clingo(g, n, directed='hdirected', bidirected='hbidirected')[source]#

Convert a graph to a string of grounded terms for clingo

Parameters:
  • g (dictionary (gunfolds graphs)) – gunfolds graph

  • n (integer) – number of nodes

  • directed (string) – name of the variable for directed edges in the observed graph

  • bidirected (string) – name of the variable for bidirected edges in the observed graph

Returns:

clingo predicate

Return type:

string

Example: {1:{3:1,4:2,5:3}}
"1": node 1 has an edge with node 3 => edge(1,3).
"2": node 1 has an conf with node 4 => conf(1,4).
"3": node 1 has both edge and conf with node 5 => edge(1,5). conf(1,5).

numbered_g2wclingo#

gunfolds.conversions.numbered_g2wclingo(g, num, directed_weights_matrix=None, bidirected_weights_matrix=None, directed='hdirected', bidirected='hbidirected')[source]#

Convert a graph to a string of grounded terms for clingo

Parameters:
  • g (dictionary (gunfolds graphs)) – gunfolds graph

  • num (integer) – index of the graph in the resulting clingo command

  • directed_weights_matrix (numpy matrices) – directed weight matrix

  • bidirected_weights_matrix (numpy matrices) – bidirected weight matrix

  • directed (string) – name of the directed edges in the observed graph

  • bidirected (string) – name of the bidirected edges in the observed graph

Returns:

clingo predicate

Return type:

string

old_g2clingo#

gunfolds.conversions.old_g2clingo(g, file=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>)[source]#

(Ask)

Parameters:
  • g (dictionary (gunfolds graphs)) – gunfolds graph

  • file – (Ask)

rasl_a2edgetuple#

gunfolds.conversions.rasl_a2edgetuple(answer)[source]#

Returns list of edges and the under sampling rate for rasl

Parameters:

answer (string) – output of clingo

Returns:

list of edges and the under sampling rate

Return type:

a tuple of list and an integer

rasl_c2edgepairs#

gunfolds.conversions.rasl_c2edgepairs(clist)[source]#

Converts clingo predicates to edge pairs for rasl

Parameters:

clist (list of strings) – clingo predicates

Returns:

list of edge pairs

Return type:

list

rasl_jclingo2g#

gunfolds.conversions.rasl_jclingo2g(output_g)[source]#

Converts the output of clingo to gunfolds graph for rasl

Parameters:

output_g (string) – the output of clingo for rasl

Returns:

gunfolds graph

Return type:

dictionary (gunfolds graph)

rate#

gunfolds.conversions.rate(u)[source]#

Converts under sampling rate to clingo predicate

Parameters:

u (integer) – maximum under sampling rate

Returns:

clingo predicate for under sampling rate

Return type:

string