Beispiel #1
0
    def create_config_files(self, config_file_name):
        # first, read the config file to find out the number of cores, etc.
        control_config = Config()
        control_config.read_xml_config_file(config_file_name)

        template_config_file_name = control_config.static_parameters[
            'template_config_file']
        template_config = Config()
        template_config.read_xml_config_file(template_config_file_name)

        # create config files computes the optimal split of a template config file with N parameter runs across K cores
        self.num_runs = int(control_config.static_parameters['num_runs'])

        # the number of config files we create equals the number of cores
        self.num_cores = int(control_config.static_parameters['num_cores'])

        # the number of simulations we run on each core is the total number of simulations divided by the number of
        # cores minus one. the remainder of the modulo will be run on the last core to make sure we end up with
        # exactly N simulations in total
        self.runs_per_core = int(
            math.floor(self.num_runs / (self.num_cores - 1)))
        self.runs_last_core = self.num_runs % (self.num_cores - 1)

        # now create config files for all cores
        for i in range(0, self.num_cores):
            out_str = self.create_parallel_config_file(control_config,
                                                       template_config, i)
            # write the output file
            if out_str != None:
                output_file_name = control_config.static_parameters[
                    'output_basefile_name'] + "-" + str(i) + ".xml"
                with open(output_file_name, "w") as f:
                    f.write(out_str)
Beispiel #2
0
    def create_config_files(self, config_file_name):
        # first, read the config file to find out the number of cores, etc.
        control_config = Config()
        control_config.read_xml_config_file(config_file_name)

        template_config_file_name = control_config.static_parameters['template_config_file']
        template_config = Config()
        template_config.read_xml_config_file(template_config_file_name)

        # create config files computes the optimal split of a template config file with N parameter runs across K cores
        self.num_runs = int(control_config.static_parameters['num_runs'])

        # the number of config files we create equals the number of cores
        self.num_cores = int(control_config.static_parameters['num_cores'])

        # the number of simulations we run on each core is the total number of simulations divided by the number of
        # cores minus one. the remainder of the modulo will be run on the last core to make sure we end up with
        # exactly N simulations in total
        self.runs_per_core = int(math.floor(self.num_runs / (self.num_cores-1)))
        self.runs_last_core = self.num_runs % (self.num_cores-1)

        # now create config files for all cores
        for i in range(0, self.num_cores):
            out_str = self.create_parallel_config_file(control_config, template_config, i)
            # write the output file
            if out_str != None:
                output_file_name = control_config.static_parameters['output_basefile_name'] + "-" + str(i) + ".xml"
                output_file = open(output_file_name, "w")
                output_file.write(out_str)
                output_file.close()
Beispiel #3
0
#!/usr/bin/env python2.7
# -*- coding: utf-8 -*-

__author__ = """Co-Pierre Georg ([email protected])"""

#-------------------------------------------------------------------------
#
#  conftools.py is a simple module to manage .xml configuration files
#
#-------------------------------------------------------------------------
if __name__ == '__main__':

    #
    # VARIABLES
    #
    import sys

    from src.conftools import Config

    args = sys.argv
    config_file_name = args[1]

    config = Config()
    config.read_xml_config_file(config_file_name)

    print "ConfTools version: " + str(config.__version__)
    print config.static_parameters
    print config.variable_parameters
Beispiel #4
0
#!/usr/bin/env python2.7
# -*- coding: utf-8 -*-

__author__ = """Co-Pierre Georg ([email protected])"""

#-------------------------------------------------------------------------
#
#  conftools.py is a simple module to manage .xml configuration files
#
#-------------------------------------------------------------------------
if __name__ == '__main__':

#
# VARIABLES
#
    import sys

    from src.conftools import Config

    args = sys.argv
    config_file_name = args[1]

    config = Config()
    config.read_xml_config_file(config_file_name)

    print "ConfTools version: " + str(config.__version__)
    print config.static_parameters
    print config.variable_parameters