delphi.GrFN package
Submodules
delphi.GrFN.linking module
delphi.GrFN.networks module
- class ComputationalGraph(*args, **kwargs)[source]
Bases:
networkx.classes.digraph.DiGraph
- run(inputs: Dict[str, Union[float, Iterable]]) Union[float, Iterable] [source]
Executes the GrFN over a particular set of inputs and returns the result.
- Parameters:
inputs – Input set where keys are the names of input nodes in the GrFN and each key points to a set of input values (or just one).
- Returns:
A set of outputs from executing the GrFN, one for every set of inputs.
- class GroundedFunctionNetwork(G, scope_tree, outputs)[source]
Bases:
delphi.GrFN.networks.ComputationalGraph
Representation of a GrFN model as a DiGraph with a set of input nodes and currently a single output. The DiGraph is composed of variable nodes and function nodes. Function nodes store an actual Python function with the expected set of ordered input arguments that correspond to the variable inputs of that node. Variable nodes store a value. This value can be any data type found in Python. When no value exists for a variable the value key will be set to None. Importantly only function nodes can be children or parents of variable nodes, and the reverse is also true. Both variable and function nodes can be inputs, but the output will always be a variable node.
- traverse_nodes(node_set, depth=0)[source]
BFS traversal of nodes that returns name traversal as large string.
- Parameters:
node_set – Set of input nodes to begin traversal.
depth – Current traversal depth for child node viewing.
- Returns:
type – String containing tabbed traversal view.
- classmethod from_json_and_lambdas(file: str, lambdas)[source]
Builds a GrFN from a JSON object.
- Parameters:
cls – The class variable for object creation.
file – Filename of a GrFN JSON file.
lambdas – A lambdas module
- Returns:
type – A GroundedFunctionNetwork object.
- classmethod from_dict(data: Dict, lambdas_path)[source]
Builds a GrFN object from a set of extracted function data objects and an associated file of lambda functions.
- Parameters:
cls – The class variable for object creation.
data – A set of function data object that specify the wiring of a GrFN object.
lambdas_path – Path to a lambdas file containing functions to be computed during GrFN execution.
- Returns:
A GroundedFunctionNetwork object.
- static create_container_dict(G: networkx.classes.digraph.DiGraph)[source]
- classmethod from_python_file(python_file, lambdas_path, json_filename: str, stem: str)[source]
Builds GrFN object from Python file.
- classmethod from_python_src(pySrc, python_file: str, fortran_file: str, module_log_file_path: str, mod_mapper_dict: list, processing_modules: bool)[source]
- classmethod from_fortran_file(fortran_file: str, tmpdir: str = '.')[source]
Builds GrFN object from a Fortran program.
- classmethod from_fortran_src(fortran_src: str, dir: str = '.')[source]
Create a GroundedFunctionNetwork instance from a string with raw Fortran code.
- Parameters:
fortran_src – A string with Fortran source code.
dir – (Optional) - the directory in which the temporary Fortran file will be created (make sure you have write permission!) Defaults to the current directory.
- Returns:
A GroundedFunctionNetwork instance
- class ForwardInfluenceBlanket(G: delphi.GrFN.networks.GroundedFunctionNetwork, shared_nodes: Set[str])[source]
Bases:
delphi.GrFN.networks.ComputationalGraph
This class takes a network and a list of a shared nodes between the input network and a secondary network. From this list a shared nodes and blanket network is created including all of the nodes between any input/output pair in the shared nodes, as well as all nodes required to blanket the network for forward influence. This class itself becomes the blanket and inherits from the ComputationalGraph class.
- classmethod from_GrFN(G1, G2)[source]
Creates a ForwardInfluenceBlanket object representing the intersection of this model with the other input model.
- Parameters:
G1 – The GrFN model to use as the basis for this FIB
G2 – The GroundedFunctionNetwork object to compare this model to.
- Returns:
A ForwardInfluenceBlanket object to use for model comparison.
- run(inputs: Dict[str, Union[float, Iterable]], covers: Dict[str, Union[float, Iterable]]) Union[float, Iterable] [source]
Executes the FIB over a particular set of inputs and returns the result. :param inputs: Input set where keys are the names of input nodes in the
GrFN and each key points to a set of input values (or just one).
- Returns:
A set of outputs from executing the GrFN, one for every set of inputs.
delphi.GrFN.sensitivity module
delphi.GrFN.utils module
delphi.GrFN.visualization module
- class SensitivityVisualizer(S: list)[source]
Bases:
object
This class is responsible for generating plots of the first and second order sensitivity indices as well as the runtime of each computation as a function of the logarithm of the sample sizes.
- 'S1', 'S2', 'sampling time', 'execution time', 'analysis time'.
- N -- sample size
- Type:
log 10 scale
- S1 -- numpy array of First Order Sensitivity Indices
- S2 -- pandas dataframe of Second Order Sensitivity Indices
- sampling time -- time taken to complete the sampling process after
- invoking a method from the SALib library
- execution time -- time taken for executing the GrFN
- analysis time -- time taken for the computation of Sensitivity Indices
- create_S1_plot(filename='s1_plot.pdf')[source]
Creates a plot of S1 versus log (base 10) of sample sizes. :param filename: Filename to save plot to.