# Have some user-defined function do stuff with the data.
ifself.grid_options["parse_function"]:
self.grid_options["parse_function"](self,out)
def_process_run_population_grid(self,ID):
"""
Function that loops over the whole generator, but only runs
systems that fit to: if (localcounter+ID) % self.grid_options["amt_cores"] == 0
That way with 4 processes, process 1 runs sytem 0, 4, 8... process 2 runs system 1, 5, 9..., etc
That way with e.g. 4 processes, process 1 runs sytem 0, 4, 8... process 2 runs system 1, 5, 9..., etc
This function is called by _evolve_population_mp
This function is called by _evolve_population_grid
"""
self.process_ID=(
@@ -877,121 +975,6 @@ class Population:
returnoutput_dict
def_evolve_population_mp(self):
"""
Function to evolve the population with multiprocessing approach.
Using pathos to be able to include class-owned functions.
This function will create a pool with <self.grid_options["amt_cores"]> processes, and perform an imap_unordered to run the different `threads`.
Before this was done by giving a generator as the iterable, and have the processes get a certain chunksize each round.
Later on this seemed to be a bad decision, because it is difficult to pass information back to the main controller, and because with each new batch of systems a new object instance was created.
What I do now is I spawn these X amount of processes, and pass a range(self.grid_options["amt_cores"]) as iterable.
In that way, only once do they fetch a `job`, but that job is just a ID number.
With this ID number each thread/process loops over the whole generator,
but only runs the one <ID>'th system (if (localcounter+ID) % self.grid_options["amt_cores"]==0)'
When they are finished, these jobs are instructed to return a set of information (the result dict, TODO: describe what more)
These resultation dictionaries are then merged and stored as object properties again.
"""
# TODO: make further use of a queue to handle jobs or at least
"evolution_type":"mp",# Flag for type of population evolution
"evolution_type":"grid",# Flag for type of population evolution
"_evolution_type_options":[
"mp",
"linear",
],# available choices for type of population evolution
"grid",
],# available choices for type of population evolution. # TODO: fill later with monte carlo, sourcefile
"_system_generator":None,# value that holds the function that generates the system
# (result of building the grid script)
"population_type":"grid",#
"_population_type_options":[
"grid",
"source_file",
],# Available choices for type of population generation. Unused for now. # TODO: fill later with monte carlo etc
"source_file_filename":None,# filename for the source
"_count":0,# count of systems
"_total_starcount":0,# Total count of systems in this generator
@@ -464,8 +458,6 @@ grid_options_descriptions = {
"parse_function":"Function that the user can provide to handle the output the binary_c. This function has to take the arguments (self, output). Its best not to return anything in this function, and just store stuff in the grid_options['results'] dictionary, or just output results to a file",
"condor":"Int flag whether to use a condor type population evolution.",# TODO: describe this in more detail
"slurm":"Int flag whether to use a slurm type population evolution.",# TODO: describe this in more detail
"population_type":"variable storing what kind of population type should be evolved. See population_type_options for the options.",# TODO: make this functionality work properly
"_population_type_options":"List storing the population_type options.",
"weight":"Weight factor for each system. The calculated probability is mulitplied by this. If the user wants each system to be repeated several times, then this variable should not be changed, rather change the _repeat variable instead, as that handles the reduction in probability per system. This is useful for systems that have a process with some random element in it.",# TODO: add more info here, regarding the evolution splitting.
"repeat":"Factor of how many times a system should be repeated. Consider the evolution splitting binary_c argument for supernovae kick repeating.",# TODO: make sure this is used.
"evolution_type":"Variable containing the type of evolution used of the grid. Multiprocessing or linear processing",