Ejemplo n.º 1
0
    def create_latex_tables_for_model(self, config, model_name, dir):
        """Write to directory dir a file containing a LaTeX table describing this model's 
        coefficients, and a file containing a LaTeX table describing this model's specification.
        Files will be named named <model_name>_coefficients.tex and <model_name>_specification.tex.
        """
        config = Configuration(config)
        model_system = ModelSystem()
        input_db, output_db = model_system._get_database_connections(config)
        sql_storage = StorageFactory().get_storage('sql_storage', storage_location=input_db)
        #TODO: only do the next stuff if this model has coefficients
        if 'controller' not in config['models_configuration'][model_name]:
            return
        if 'prepare_for_run' not in config['models_configuration'][model_name]['controller']:
            return
        if 'coefficients' not in config['models_configuration'][model_name]['controller']['prepare_for_run']['output']:
            return
        specification_table_name = config['models_configuration'][model_name].get('specification_table', None)
        coefficents_table_name = config['models_configuration'][model_name].get('coefficients_table', None)
        (specification, coefficients) = prepare_specification_and_coefficients(
            specification_storage=sql_storage,
            specification_table=specification_table_name,
            coefficients_storage=sql_storage,
            coefficients_table=coefficents_table_name)

        self.create_latex_table_for_coefficients_for_model(coefficients, model_name, dir)
        self.create_latex_table_for_specifications_for_model(specification, model_name, dir)
        
Ejemplo n.º 2
0
    def create_latex_tables_for_model(self, config, model_name, dir):
        """Write to directory dir a file containing a LaTeX table describing this model's 
        coefficients, and a file containing a LaTeX table describing this model's specification.
        Files will be named named <model_name>_coefficients.tex and <model_name>_specification.tex.
        """
        config = Configuration(config)
        model_system = ModelSystem()
        input_db, output_db = model_system._get_database_connections(config)
        sql_storage = StorageFactory().get_storage('sql_storage',
                                                   storage_location=input_db)
        #TODO: only do the next stuff if this model has coefficients
        if 'controller' not in config['models_configuration'][model_name]:
            return
        if 'prepare_for_run' not in config['models_configuration'][model_name][
                'controller']:
            return
        if 'coefficients' not in config['models_configuration'][model_name][
                'controller']['prepare_for_run']['output']:
            return
        specification_table_name = config['models_configuration'][
            model_name].get('specification_table', None)
        coefficents_table_name = config['models_configuration'][
            model_name].get('coefficients_table', None)
        (specification, coefficients) = prepare_specification_and_coefficients(
            specification_storage=sql_storage,
            specification_table=specification_table_name,
            coefficients_storage=sql_storage,
            coefficients_table=coefficents_table_name)

        self.create_latex_table_for_coefficients_for_model(
            coefficients, model_name, dir)
        self.create_latex_table_for_specifications_for_model(
            specification, model_name, dir)
    def prepare_for_run(self,
                        specification_storage=None,
                        specification_table=None,
                        coefficients_storage=None,
                        coefficients_table=None,
                        agent_set=None,
                        agents_filter=None,
                        data_objects=None,
                        **kwargs):

        spec, coeff = prepare_specification_and_coefficients(
            specification_storage=specification_storage,
            specification_table=specification_table,
            coefficients_storage=coefficients_storage,
            coefficients_table=coefficients_table,
            **kwargs)

        if agents_filter is not None:
            agent_set.compute_variables(agents_filter,
                                        resources=Resources(data_objects))
            index = where(
                agent_set.get_attribute(
                    VariableName(agents_filter).get_alias()) > 0)[0]

        return (spec, coeff, index)
Ejemplo n.º 4
0
 def prepare_for_run(self, dataset=None, dataset_filter=None, filter_threshold=0, **kwargs):
     spec, coef = prepare_specification_and_coefficients(**kwargs)
     if (dataset is not None) and (dataset_filter is not None):
         filter_values = dataset.compute_variables([dataset_filter], dataset_pool=self.dataset_pool)
         index = where(filter_values > filter_threshold)[0]
     else:
         index = None
     return (spec, coef, index)
 def prepare_for_run(self, 
                     specification_storage=None, 
                     specification_table=None,
                     coefficients_storage=None,
                     coefficients_table=None,
                     data_objects=None,
                     **kwargs):
     
     spec, coeff = prepare_specification_and_coefficients(specification_storage=specification_storage,
                                            specification_table=specification_table, 
                                            coefficients_storage=coefficients_storage,
                                            coefficients_table=coefficients_table, **kwargs)
     return (spec, coeff)
Ejemplo n.º 6
0
 def prepare_for_run(self,
                     dataset=None,
                     dataset_filter=None,
                     filter_threshold=0,
                     **kwargs):
     spec, coef = prepare_specification_and_coefficients(**kwargs)
     if (dataset is not None) and (dataset_filter is not None):
         filter_values = dataset.compute_variables(
             [dataset_filter], dataset_pool=self.dataset_pool)
         index = where(filter_values > filter_threshold)[0]
     else:
         index = None
     return (spec, coef, index)
Ejemplo n.º 7
0
 def prepare_for_run(self, 
                     specification_storage=None, 
                     specification_table=None,
                     coefficients_storage=None,
                     coefficients_table=None,
                     agent_set=None,
                     agents_filter=None,
                     data_objects=None,
                     **kwargs):
     
     spec, coeff = prepare_specification_and_coefficients(specification_storage=specification_storage,
                                            specification_table=specification_table, 
                                            coefficients_storage=coefficients_storage,
                                            coefficients_table=coefficients_table, **kwargs)
     
     if agents_filter is not None:
         agent_set.compute_variables(agents_filter, resources=Resources(data_objects))
         index = where(agent_set.get_attribute(VariableName(agents_filter).get_alias()) > 0)[0]
     
     return (spec, coeff, index)