You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Refusing to set a population size (using the default of population_size=None) leads to an error when the optimisation is run but the docstring for set_population_size suggests this is valid and the value generated by suggested_population_size should be used in this case.
I'm guessing this is just missing functionality from set_population_size, but I did see that the docstring for population_size mentions the possibility of self.population_size=None prior to beginning an optimisation, but I couldn't see any way for opt.run() to set this to default if that was the case
def__init__(self, x0, sigma0=None, boundaries=None):
super(PopulationBasedOptimiser, self).__init__(x0, sigma0, boundaries)
# Set initial population size using heuristicself._population_size=self._suggested_population_size()
defpopulation_size(self):
""" Returns this optimiser's population size. If no explicit population size has been set, ``None`` may be returned. Once running, the correct value will always be returned. """returnself._population_sizedefset_population_size(self, population_size=None):
""" Sets a population size to use in this optimisation. If `population_size` is set to ``None``, the population size will be set using the heuristic :meth:`suggested_population_size()`. """ifself.running():
raiseException('Cannot change population size during run.')
# Check population size or set using heuristicifpopulation_sizeisnotNone:
population_size=int(population_size)
ifpopulation_size<1:
raiseValueError('Population size must be at least 1.')
# Storeself._population_size=population_sizedefsuggested_population_size(self, round_up_to_multiple_of=None):
""" Returns a suggested population size for this method, based on the dimension of the search space (e.g. the parameter space). If the optional argument ``round_up_to_multiple_of`` is set to an integer greater than 1, the method will round up the estimate to a multiple of that number. This can be useful to obtain a population size based on e.g. the number of worker processes used to perform objective function evaluations. """population_size=self._suggested_population_size()
ifround_up_to_multiple_ofisnotNone:
n=int(round_up_to_multiple_of)
ifn>1:
population_size=n* (((population_size-1) //n) +1)
returnpopulation_size
The text was updated successfully, but these errors were encountered:
mjowen
added a commit
to CardiacModelling/ionBench
that referenced
this issue
Nov 14, 2024
Bug
Refusing to set a population size (using the default of
population_size=None
) leads to an error when the optimisation is run but the docstring for set_population_size suggests this is valid and the value generated by suggested_population_size should be used in this case.I'm guessing this is just missing functionality from
set_population_size
, but I did see that the docstring for population_size mentions the possibility ofself.population_size=None
prior to beginning an optimisation, but I couldn't see any way foropt.run()
to set this to default if that was the caseMRE
Relevant parts of pints
The text was updated successfully, but these errors were encountered: