clingo_rasl#

drasl#

gunfolds.solvers.clingo_rasl.drasl(glist, capsize=1, timeout=0, urate=0, weighted=False, scc=False, scc_members=None, dm=None, bdm=None, pnum=4.0, edge_weights=(1, 1), configuration='crafty', optim='optN')[source]#

Compute all candidate causal time-scale graphs that could have generated all undersampled graphs at all possible undersampling rates up to urate in glist each at an unknown undersampling rate.

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

  • capsize (integer) – maximum number of candidates to return

  • timeout (integer) – timeout in seconds after which to interrupt computation (0 - no limit)

  • urate (integer) – maximum undersampling rate to consider

  • weighted (boolean) – whether the input graphs are weighted or imprecize. If True but no weight matrices are provided - all weights are set to 1

  • scc (boolean) – whether to assume that each SCC in the input graph is either a singleton or have gcd=1. If True a much more efficient algorithm is employed.

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

  • dm (list of numpy arrays) – a list of n-by-n 2-d square matrix of the weights for directed edges of each input n-node graph

  • bdm (list of numpy arrays) – a list of symmetric n-by-n 2-d square matrix of the weights for bidirected edges of each input n-node graph

  • pnum (integer) – number of parallel threads to run clingo on

  • edge_weights (tuple with 2 elements) – a tuple of 2 values, the first is importance of matching directed weights when solving optimization problem and the second is for bidirected.

  • configuration (string) –

    Select configuration based on problem type

    • frumpy : Use conservative defaults

    • jumpy : Use aggressive defaults

    • tweety : Use defaults geared towards asp problems

    • handy : Use defaults geared towards large problems

    • crafty : Use defaults geared towards crafted problems

    • trendy : Use defaults geared towards industrial problems

  • optim (string) –

    a comma separated string containing configuration for optimization algorithm and optionally a bound [<arg>[, <bound>]]

    • <arg><mode {opt|enum|optN|ignore}>
      • opt : Find optimal model

      • enum : Find models with costs <= <bound>

      • optN : Find optimum, then enumerate optimal models

      • ignore : Ignore optimize statements

    • <bound> : Set initial bound for objective function(s)

Returns:

results of parsed equivalent class

Return type:

dictionary

drasl_command#

gunfolds.solvers.clingo_rasl.drasl_command(g_list, max_urate=0, weighted=False, scc=False, scc_members=None, dm=None, bdm=None, edge_weights=(1, 1))[source]#

Given a list of graphs generates clingo codes

Parameters:
  • g_list (list of dictionaries (gunfolds graphs)) – a list of graphs that are undersampled versions of the same system

  • max_urate (integer) – maximum under sampling rate

  • weighted (boolean) – whether the input graphs are weighted or precize. If True but no weight matrices are provided - all weights are set to 1

  • scc ((GUESS)boolean) – whether to assume that each SCC in the input graph is either a singleton or have gcd=1. If True a much more efficient algorithm is employed.

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

  • dm (list of numpy arrays) – a list of n-by-n 2-d square matrix of the weights for directed edges of each input n-node graph

  • bdm (list of numpy arrays) – a list of symmetric n-by-n 2-d square matrix of the weights for bidirected edges of each input n-node graph

  • edge_weights (tuple with 2 elements) – a tuple of 2 values, the first is importance of matching directed weights when solving optimization problem and the second is for bidirected.

Returns:

clingo code as a string

Return type:

string

drate#

gunfolds.solvers.clingo_rasl.drate(u, gnum, weighted=False)[source]#

Replaces rate if there are multiple under sampled inputs

Parameters:
  • u (integer) – maximum under sampling rate

  • gnum (integer) – number of under sampled inputs

  • weighted (boolean) – whether the input graphs are weighted or precize. If True but no weight matrices are provided - all weights are set to 1

Returns:

clingo code for under sampling with multiple under sampled inputs

Return type:

string

glist2str#

gunfolds.solvers.clingo_rasl.glist2str(g_list, weighted=False, dm=None, bdm=None)[source]#

Converts list of graphs into clingo predicates

Parameters:
  • g_list (list of dictionaries (gunfolds graphs)) – a list of graphs that are undersampled versions of the same system

  • weighted (boolean) – whether the input graphs are weighted or precize. If True but no weight matrices are provided - all weights are set to 1

  • dm (list of numpy arrays) – a list of n-by-n 2-d square matrix of the weights for directed edges of each input n-node graph

  • bdm (list of numpy arrays) – a list of symmetric n-by-n 2-d square matrix of the weights for bidirected edges of each input n-node graph

Returns:

clingo predicates as a string

Return type:

string

rasl#

gunfolds.solvers.clingo_rasl.rasl(g, capsize, timeout=0, urate=0, pnum=None, configuration='tweety')[source]#
Parameters:
  • g (dictionary (gunfolds graphs)) – gunfolds graph

  • capsize (integer) – maximum number of candidates to return

  • timeout (integer) – timeout in seconds after which to interrupt computation (0 - no limit)

  • urate (integer) – maximum undersampling rate to consider

  • pnum (integer) – number of parallel threads to run clingo on

  • configuration (string) –

    Select configuration based on problem type

    • frumpy : Use conservative defaults

    • jumpy : Use aggressive defaults

    • tweety : Use defaults geared towards asp problems

    • handy : Use defaults geared towards large problems

    • crafty : Use defaults geared towards crafted problems

    • trendy : Use defaults geared towards industrial problems

Returns:

results of parsed equivalent class

Return type:

dictionary

rasl_command#

gunfolds.solvers.clingo_rasl.rasl_command(g, urate=0)[source]#

Given a graph generates clingo code

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

  • urate (integer) – maximum undersampling rate to consider

Returns:

clingo code

Return type:

string

rate#

gunfolds.solvers.clingo_rasl.rate(u, uname='u')[source]#

Adds under sampling rate to clingo code

Parameters:
  • u (integer) – maximum under sampling rate

  • uname (string) – name of the parameter

Returns:

predicate for under sampling rate

Return type:

string

weighted_drasl_program#

gunfolds.solvers.clingo_rasl.weighted_drasl_program(directed, bidirected)[source]#

Adjusts the optimization code based on the directed and bidirected priority

Parameters:
  • directed (integer) – priority of directed edges in optimization

  • bidirected (integer) – priority of bidirected edges in optimization graph

Returns:

optimization part of the clingo code

Return type:

string