Beispiel #1
0
 def test_get_sensitivity_args(self):
     global user_core_models
     global settings_file_1
     global sg_args
     global variables
     global config_data
 
     filename    = settings_file_1
     
     #Get arguments for simulation
     result = ssg.get_strike_goldd_args(filename, user_core_models=user_core_models)
     
     #Expect models, params, config_data = result
     assert len(result) == 3
     
     try:
        sg_args, config_data, variables = result
     except:
         sg_args, config_data, variables = result.values()   
Beispiel #2
0
    '''
    #Set up core models and sampler arguments
    #Details in Tutorial 7 Part 1
    model_files = [
        'LogicGate_Not_Single.ini',
        'LogicGate_Not_Double.ini',
        'LogicGate_Not_Double_MaturationSecond.ini',
    ]

    user_core_models = [mh.from_config(filename) for filename in model_files]
    user_core_models = {
        core_model['system_type']: core_model
        for core_model in user_core_models
    }

    sg_args, config_data, variables = ssg.get_strike_goldd_args(
        model_files, user_core_models=user_core_models)
    '''
    The optional argument dst allows you to supply your own dictionary to which the
    results will be added after each iteration. This allows you to thread and/or
    save the results before all the iterations have been completed. Just use an
    empty dictionary for dst.
    '''
    #Run strike-goldd algorithm
    #Details in Tutorial 7 Part 2
    dst = {}
    sg_results = sg.analyze_sg_args(sg_args, dst=dst)
    outfile = 'sg_results.yaml'
    yaml_dict = ir.export_sg_results(sg_results,
                                     variables,
                                     config_data,
                                     user_core_models=user_core_models,
import setup_bmss as lab
import BMSS.models.setup_sg as ssg
import BMSS.strike_goldd_simplified as sg
import BMSS.models.ia_results as ir
import BMSS.models.model_handler as mh
'''
Tutorial 6 Part 2: A priori Identifiability Analysis with Strike-Goldd
- Call the function required to run the strike_goldd algorithm.
'''

if __name__ == '__main__':
    filename = 'settings_sg.ini'

    sg_args, config_data, variables = ssg.get_strike_goldd_args(filename)
    '''
    We can now run the strike-goldd algorithm. This returns a dictionary where 
    the result for each model is indexed under model_num.
    
    The optional argument dst allows you to supply your own dictionary to which the
    results will be added after each iteration. This allows you to thread and/or
    save the results before all the iterations have been completed. Just use an
    empty dictionary.
    '''
    dst = {}
    sg_results = sg.analyze_sg_args(sg_args, dst=dst)

    print('Result from strike_goldd')
    print(sg_results[1])
    print()
    '''
    The results can be exported as a human-readable report as a .yaml file
Beispiel #4
0
    9. A Priori Identifiability Analysis
    '''
    '''
    BMSS allows you perform algebraic identifiability analysi using the STRIKE-GOLDD
    algorithm developed by Villaverde et al. which makes use of symbolic algebra
    and Lie derivatives to assess parameter identifiability.
    '''

    ssg.make_settings_template(system_types_settings_names,
                               filename='settings_template_sg.ini',
                               user_core_models=user_core_models)
    '''
    Once again, template files for the settings can be generated.
    '''

    sg_args, config_data, variables = ssg.get_strike_goldd_args(
        'settings_sg.ini', user_core_models=user_core_models, write_file=True)
    '''
    The optional argument dst allows you to supply your own dictionary to which the
    results will be added after each iteration. This allows you to thread and/or
    save the results before all the iterations have been completed. Just use an
    empty dictionary for dst.
    '''
    #Run strike-goldd algorithm
    #Details in Tutorial 7 Part 2
    dst = {}
    sg_results = sg.analyze_sg_args(sg_args, dst=dst)
    outfile = 'sg_results.yaml'
    yaml_dict = ir.export_sg_results(sg_results,
                                     variables,
                                     config_data,
                                     user_core_models=user_core_models,
import importlib

import setup_bmss as lab
import BMSS.models.setup_sg as ssg
'''
Tutorial 6 Part 3: Generating .py Files
- Create standalone .py files for running strike-goldd
'''

if __name__ == '__main__':
    '''
    Just as .py files for integration can be generated for core models, so can .py
    for running strike_goldd. Simply set the write_file argument in 
    get_strike_goldd_args to True. 
    '''

    filename = 'settings_sg.ini'

    sg_args, variables, config_data = ssg.get_strike_goldd_args(
        filename, write_file=True)
    '''
    The newly written .py files are have the prefix 'sg_' in front of them. Open 
    files and take a look inside!
    '''

    mod = importlib.import_module('sg_TestModel_Monod_Inducible')

    result = mod.run_strike_goldd()

    print('Result')
    print(result)
    1. Reading the Settings File
    '''
    filename = 'settings_sg.ini'
    config_data = ssg.from_config(filename)
    '''
    Note: In order to speed up calculations, provide parameter vaues for 
    fixed_parameters where possible.
    '''
    '''
    2. Compiling Arguments
    '''
    core_model = mh.from_config('Monod_Inducible.ini')

    user_core_models = {core_model['system_type']: core_model}

    sg_args, config_data, variables = ssg.get_strike_goldd_args(
        filename, user_core_models=user_core_models, write_file=False)

    print('Keys in sg_args[1]: ')
    print(sg_args[1].keys())
    print()
    '''
    sg_args is a dictionary in the form {model_num: model} where a model contains
    information on the system of equations, the number of unknown parameters and
    other arguments required for running the strike-goldd algorithm.
    
    The keys are as follows:
    'h'      : A 1 column Matrix of states that measured during the experiment.
    'x'      : A 1 column Matrix of states in for the model
    'p'      : A 1 column Matrix of unknown parameters.
    'f'      : A 1 column Matrix of differential equations for each state in order.
    'u'      : A dictionary where the keys are the inputs and the values are the number of non-zero derivatives.