Skip to main content

GAdapt: Self-Adaptive Genetic Algorithm

A comprehensive and customizable genetic algorithm library.

Table of Contents

Introduction

GAdapt is an open-source Python library for Genetic Algorithm optimization. It implements innovative concepts for adaptive mutation of decision variables and candidate solutions.

What Innovations Does GAdapt Bring?

GAdapt introduces self-adaptive determination of how many and which candidate solutions and decision variables will be mutated. In addition, it determines the decision variable alteration type. This determination is based on the diversity of parents, diversity of cost, and variable-columnar-diversity of decision variables in the population. The higher diversity and lower convergence necessitate fewer mutated candidate solutions. A high diversity level also allows for more mutated decision variables within each candidate solution. At this stage, variable value alterations are encouraged to be unbiased, favoring a uniform distribution of values. This approach ensures that mutations are not overly frequent, but selected candidate solutions can undergo significant changes, promoting the exploration of potential solutions. As diversity decreases and convergence increases, the frequency of mutated candidate solutions rises, the number of mutated decision variables inside candidate solutions decreases, and variable value changes are biased towards previously attained values, encouraging greater exploitation and fine-tuning of existing solutions. Throughout this process, the selection of mutated candidate solutions and variable values should prioritize those with lower diversity and higher convergence levels, maintaining exploration and preventing GA from getting stuck in some local optimums.

The proposed method refines mutation selection, rate determination, and alteration processes, potentially surpassing the limitations of traditional mutation techniques and opening up new possibilities for significantly improved GA performance.

Installation

To install GAdapt, use pip with the following command:

pip install gadapt

GAdapt requires Python 3.10 or newer. NumPy is installed automatically as a dependency.

Releases

The latest releases of GAdapt can be found at the PyPI repository: GAdapt on PyPI

Source Code

The source code is available on GitHub: GAdapt on GitHub

API Documentation

For detailed API documentation, refer to: GAdapt API Documentation

Usage

Below is an example optimizing variable values for a complex trigonometric function:

from gadapt.ga import GA
import math

#trigonometric function definition
def trig_func(args):    
    return math.sqrt(abs(math.cos(args[0]))) + math.pow(math.cos(args[1]), 2) + math.sin(args[2]) + math.pow(args[3], 2) + math.sqrt(args[4]) + math.cos(args[5]) - (args[6]*math.sin(pow(args[6], 3)) + 1) + math.sin(args[0]) / (math.sqrt(args[0])/3 + (args[6]*math.sin(pow(args[6], 3)) + 1) ) / math.sqrt(args[4]) + math.cos(args[5])

#Instantiation of genetic algorithm for desired function
ga = GA(cost_function=trig_func)

#Adding variables (minimal value, maximal value and step)
ga.add(1.0, 4.0, 0.01)
ga.add(37.0, 40.0, 0.01)
ga.add(78.0, 88.0, 0.1)
ga.add(-5.0, 4.0, 0.1)
ga.add(1.0, 100.0, 1)
ga.add(1.0, 4.0, 0.01)
ga.add(-1, -0.01, 0.005)

#Execution of the genetic algorithm
results = ga.execute()

#Printing results
print(results)

The possible output:

Min cost: -3.370583074871819
Number of iterations: 286
Parameter values:
0: 1.57
1: 39.27
2: 86.4
3: 0.0
4: 1.0
5: 3.14
6: -1.0

In this example, the genetic algorithm searches for the combination of seven parameters, bringing the lowest value for the passed function. The only mandatory attribute to the genetic algorithm is cost_function, and other attributes in this example took default values. Parameters to be optimized are added by the "add" method. There are seven parameters to be optimized in this example.

Parameter Settings

GAdapt genetic algorithm can receive parameters through constructor, properties, or a combination of both. Below are the supported parameters:

Passing parameters through the class constructor:

ga = GA(cost_function=trig_func,
    population_size=32,
    population_mutation="cost_diversity,parent_diversity",
    number_of_mutation_candidate_solutions=6,
    number_of_mutation_decision_variables=2,
    exit_check="min_cost",
    max_attempt_no=20,
    logging=True,
    timeout=3600)

Passing parameters through the class properties:

ga = GA()
ga.cost_function = trig_func
ga.population_size=32
ga.population_mutation="cost_diversity,parent_diversity"
ga.number_of_mutation_candidate_solutions=6
ga.number_of_mutation_decision_variables=2
ga.exit_check="min_cost"
ga.max_attempt_no=20
ga.logging=True
ga.timeout=3600

Passing parameters through the class constructor and properties:

ga = GA(cost_function=trig_func, population_size=32)
ga.population_mutation="cost_diversity,parent_diversity"
ga.number_of_mutation_candidate_solutions=6
ga.number_of_mutation_decision_variables=2
ga.exit_check="min_cost"
ga.max_attempt_no=20
ga.logging=True
ga.timeout=3600

Parameters Description

cost_function=None - Custom function for the cost calculation (fitness). The optimisation goal is minimising the output of the cost function. cost_function must be the function with one argument - a list of values, where the index is the ordinal of adding parameters and the item is the parameter's value to be optimised. When adding parameters, there should be as many parameters as the function uses. The cost_function is the only mandatory parameter.

population_size=32 - Number of candidate solutions in the population.

keep_elitism_percentage=50 - The percentage of the best candidate solutions (by cost value) that are kept in the population from one generation to the next. The remaining candidate solutions are replaced by the offspring of the kept ones. For example, with population_size of 32 and keep_elitism_percentage of 50, the 16 best candidate solutions are kept and 16 new ones are created in each generation.

number_of_crossover_parents=-1 - The number of candidate solutions in the mating pool, i.e. the number of parents selected for crossover in each generation. If its value is lower than 2, all kept candidate solutions (see keep_elitism_percentage) are used as parents.

exit_check="avg_cost" - A criteria for the exit for the genetic algorithm.
Supported values:

  • "avg_cost" - The optimisation exit is triggered when the average cost of the kept part of the population (see keep_elitism_percentage) is not improved in the specified number of generations
  • "min_cost" - The optimisation exit is triggered when the minimal cost in the population is not improved in the specified number of generations
  • "requested" - The optimisation exit is triggered when the requested value reached
  • "generations" - The optimisation exit requested number of generations defined by "number_of_generations" parameter is reached

max_attempt_no=2 - This parameter only takes place when exit_check has value "avg_cost" or "min_cost". It determines the number of generations in which there is no improvement in the average/minimal cost.

requested_cost=sys.float_info.max - This parameter only takes place when exit_check has value "requested". It determines the requested value which causes the exit from the genetic algorithm

number_of_generations=200 - This parameter only takes place when exit_check has value “generations”. It determines the number of generations after which the genetic algorithm exits

timeout=600 - A number of seconds after which the genetic algorithm optimisation will exit, regardless of whether exit_check criteria is reached. When the timeout expires, messages in the results contain a warning.

exit_function=None - A function without arguments that is called in each generation. If it returns True, the genetic algorithm exits, regardless of the exit_check criteria. It can be used, for example, to stop the optimisation from the outside.

parent_selection="roulette_wheel" - The algorithm for parent selection.
Supported values:

  • "roulette_wheel" - Roulette Wheel selection algorithm (also known as "Weighted Random Pairing"). The probabilities assigned to the candidate solutions in the mating pool are inversely proportional to their cost. A candidate solution with the lowest cost has the greatest probability of mating, while the candidate solution with the highest cost has the lowest probability of mating.
  • "tournament" - Tournament selection algorithm. It randomly picks small subsets (groups) of candidate solutions from the mating pool, and candidate solutions with the lowest cost in subsets become a parent. "tournament" can have an additional parameter separated from the "tournament" keyword by the comma. The other value represents a group size. For example, "tournament,8" means that the tournament parent selection algorithm is chosen, and each group contains up to 8 members. The default group size is 4.
  • "from_top_to_bottom" - From Top To Bottom selection algorithm starts at the top of the list and pairs the candidate solutions two at a time until the top kept candidate solutions are selected for mating. Thus, the algorithm pairs odd rows with even rows.
  • "random" - Random selection algorithm uses a uniform random number generator to select candidate solutions.

crossover="blending" - The crossover algorithm, optionally followed by a method for determining the crossover probability, separated by a comma.
Supported crossover algorithms:

  • "blending" - Blending crossover combines variable values from the two parents into new variable values in offsprings. One value of the offspring variable comes from a combination of the two corresponding values of the parental decision variables
  • "uniform" - Uniform crossover combines candidate solutions in a uniform way.

Supported methods for determining the crossover probability (the probability that the values of a decision variable are crossed between the two parents):

  • "fixed" - The probability is defined by the crossover_probability parameter. This is used when no method is specified.
  • "cost_diversity" - The probability is adaptive. It lies between crossover_min_probability and crossover_max_probability, and it is higher when the diversity of costs in the population is higher.
  • "variable_columnar_diversity" - The probability is adaptive. It lies between crossover_min_probability and crossover_max_probability, and it is higher when the diversity of variable values in the population is higher.

For example, "blending,cost_diversity" means that blending crossover is used, with the probability determined by the cost diversity. If more methods are specified, one of them is randomly chosen for each pair of parents.

crossover_probability=0.5 - The probability for crossing the values of a decision variable between the two parents. It applies when the probability is determined by the "fixed" method (the default).

crossover_min_probability=0.5 and crossover_max_probability=1.0 - The lower and the upper bound for the adaptive crossover probability. They apply when the probability is determined by the "cost_diversity" or the "variable_columnar_diversity" method.

percentage_of_mutation_candidate_solutions=50.0 - The percentage of mutated candidate solutions in the population. This value is applied to the population_size value and rounded to an integer value, giving the number of mutation candidate solutions. For example, if population_size has a value of 32, and percentage_of_mutation_candidate_solutions has a value of 10, the number of mutation candidate solutions will be 3. The calculated value is an upper bound - the actual number of mutated candidate solutions can vary from 1 to the calculated value. percentage_of_mutation_candidate_solutions only applies if number_of_mutation_candidate_solutions does not have a valid integer value equal to or higher than 0.

number_of_mutation_candidate_solutions=-1 - The number of mutation candidate solutions in the population. In case it's value is equal to or higher than 0, it overrides percentage_of_mutation_candidate_solutions. This value is the upper bound - the actual number of mutated candidate solutions can vary from 1 to number_of_mutation_candidate_solutions.

percentage_of_mutation_decision_variables=20 - The percentage of mutated decision variables in each candidate solution. It applies to the candidate solution size (number of decision variables in each candidate solution), and the calculated value rounds to an integer value. The calculated value is the upper bound - the actual number of mutated decision variables can vary from 1 to the calculated value. percentage_of_mutation_decision_variables only applies if number_of_mutation_decision_variables does not have a valid integer value equal to or higher than 0.

number_of_mutation_decision_variables=-1 - The number of mutated decision variables in each candidate solution. In case it's value is equal to or higher than 0, it overrides percentage_of_mutation_decision_variables. This value is the upper bound - the number of mutated decision variables can vary from 1 to number_of_mutation_decision_variables.

population_mutation="cost_diversity,parent_diversity" - A type of mutation for the entire population. Based on the value of this parameter, the number of mutation candidate solutions can be determined, along with how candidate solutions for the mutation will be selected. Supported values:

  • "cost_diversity" - It applies to the number of mutation candidate solutions. "cost_diversity" determines the number of mutated candidate solutions adaptively, using the diversity of costs in the population. Lower cost diversity means a higher number of mutated candidate solutions. The minimal value of mutated candidate solutions is 0, and the maximal value is determined by the value of number_of_mutation_candidate_solutions or percentage_of_mutation_candidate_solutions parameters. If population_mutation has a value other than "cost_diversity", the number of mutation candidate solutions is a random value from 1 to number_of_mutation_candidate_solutions value (or to value determined by percentage_of_mutation_candidate_solutions value). "cost_diversity" means that the "parent_diversity" method is selected to select candidate solutions to be mutated. This method only determines the number of mutated candidate solutions, but not how candidate solutions are selected for the mutation.
  • "variable_columnar_diversity" - It applies to the number of mutation candidate solutions. Determines the number of mutated candidate solutions based on dispersion of variable values. The lower dispersion indicates the higher number of mutated candidate solutions. The minimal value of mutated candidate solutions is 0, and the maximal value is determined by the value of number_of_mutation_candidate_solutions or percentage_of_mutation_candidate_solutions parameters.
  • "parent_diversity" - It applies to the way how mutation candidate solutions will be selected. "parent_diversity" selects candidate solutions to be mutated using the diversity of their parents. The more similar parents (lower parent diversity) mean a higher probability of mutation for the child. Based on the calculated parent diversity, candidate solutions may be selected by one of the selection methods, which is determined by the value of the parent_diversity_mutation_candidate_solution_sampling parameter.
  • "random" - It applies to the number of mutation candidate solutions and to the way how mutation candidate solutions will be selected. "random" selects candidate solutions to be mutated randomly, and randomly determines the number of mutated candidate solutions (with the upper bound of number_of_mutation_candidate_solutions)
  • "strict" - It applies to the number of mutation candidate solutions. The strict number of candidate solutions will be mutated, determined by number_of_mutation_candidate_solutions parameter.

Population_mutation may have more values, separated by a comma. It means that more than one method can be chosen for the mutation of candidate solutions in the population. For example, "cost_diversity,parent_diversity" means that number of mutation candidate solutions will be determined by the cost diversity and the selection of candidate solutions to be mutated will be defined by parent diversity. "cost_diversity,random" means that the cost diversity will determine the number of mutation candidate solutions, and the selection of candidate solutions to be mutated will be chosen randomly.

parent_diversity_mutation_candidate_solution_sampling="roulette_wheel" - The selection algorithm for mutating candidate solutions when population_mutation contains value "parent_diversity". It only applies when population_mutation has value "parent_diversity". It determines the way how candidate solutions are to be selected based on the diversity of their parents.
Supported values:

  • "roulette_wheel" - The Roulette Wheel selection algorithm (also known as "Weighted Random Pairing"). The probabilities assigned to the candidate solutions to be mutated are proportional to the similarity of their parents (inversely proportional to the parent diversity). A candidate solution with the lowest parent diversity has the greatest probability of mutation, while the candidate solution with the highest parent diversity has the lowest probability of mutation.
  • "tournament" - The Tournament selection algorithm. It randomly picks small subsets (groups) of candidate solutions, and candidate solutions with the lowest parent diversity (highest parent similarity) in subsets are chosen to be mutated. "tournament" can have an additional parameter separated from the "tournament" keyword by the comma. The other value represents a group size. For example, "tournament,8" means that the tournament mutation selection algorithm is chosen, and each group contains up to 8 members. The default group size is 4.
  • "from_top_to_bottom" - From Top To Bottom selection algorithm starts at the top of the list and selects candidate solutions for mutation.
  • "random" - Random selection algorithm uses a uniform random number generator to select candidate solutions for mutation. In this case, selection for mutation will not depend on parent diversity.

must_mutate_for_same_parents=True - Indicates if completely the same parents must influence mutation for their children. In other words, each child will be mutated if it has parents with a diversity of value of 0. If must_mutate_for_same_parents has the value True, the number of mutated candidate solutions can outreach value determined by number_of_mutation_candidate_solutions or percentage_of_mutation_candidate_solutions

candidate_solution_mutation="variable_columnar_diversity,random" - The type of decision variable selection in candidate solutions for mutation
Supported values:

  • "variable_columnar_diversity" - Considers the diversity of decision variables of the same type in the population. Lower diversity can mean that this decision variable approaches some local minimums, and therefore such decision variables increase the chance for mutation. Based on the calculated variable-columnar-diversity, candidate solutions may be selected by one of the selection methods, which is determined by the value of the variable_columnar_diversity_mutation_decision_variable_sampling parameter.
  • "random" - Decision variables are randomly selected for the mutation. Random number of decision variables for mutation is determined, up to number_of_mutation_decision_variables
  • "strict" - Strict number of decision variables will be mutated, determined by number_of_mutation_decision_variables parameter.

decision_variable_mutation="variable_columnar_diversity,random" - The type of assigning mutated values to decision variables Supported values:

  • "normal_distribution" - assigns normally distributed random number to the variable selected for mutation
  • "variable_columnar_diversity" - assigns normally distributed random number to the variable selected for mutation, with standard deviation based on the variable-columnar-diversity coefficient
  • "cost_diversity" - assigns normally distributed random number to the variable selected for mutation, with standard deviation based on the diversity of costs in the population. Higher cost diversity means a higher standard deviation.
  • "random" - Random values are assigned to decision variables

normal_distribution_mutation_min_std_dev=0.001 and normal_distribution_mutation_max_std_dev=0.6 - The lower and the upper bound of the standard deviation of normally distributed mutated values. They apply when decision_variable_mutation contains "variable_columnar_diversity" or "cost_diversity". The values are relative to the range of the variable (between 0 and 1), so 0.6 means 60% of the difference between the maximal and the minimal value of the variable. The maximum must be higher than the minimum. Otherwise, the default values are used.

variable_columnar_diversity_mutation_decision_variable_sampling="roulette_wheel" - the selection algorithm for mutating candidate solutions when candidate_solution_mutation has value "variable_columnar_diversity". It only applies when candidate_solution_mutation has value "variable_columnar_diversity" . It determines the way how decision variables are to be selected based on the variable-columnar-diversity.
Supported values:

  • "roulette_wheel" - The Roulette Wheel selection algorithm (also known as "Weighted Random Pairing"). The probabilities assigned to the decision variables to be mutated are inversely proportional to their variable-columnar-diversity. A variable value with the lowest variable-columnar-diversity has the greatest probability of mutation, while the decision variable with the highest variable-columnar-diversity has the lowest probability of mutation.
  • "tournament" - The Tournament selection algorithm. It randomly picks small subsets (groups) of decision variables, and decision variables with the lowest variable-columnar-diversity in subsets are chosen to be mutated. "tournament" can have an additional parameter separated from the "tournament" keyword by the comma. The other value represents a group size. For example, "tournament,3" means that the tournament mutation selection algorithm is chosen, and each group contains up to 3 members. The default group size is 4.
  • "from_top_to_bottom" - From Top To Bottom selection algorithm starts at the top of the list and selects decision variables for mutation.
  • "random" - Random selection algorithm uses a uniform random number generator to select decision variables for mutation. In this case, selection for the mutation will not depend on the variable-columnar-diversity of the decision variable.

immigration_number=0 - Refers to the "Random Immigrants" concepts. This strategy introduces a certain number of individuals into the population during the evolution process. These new individuals are generated randomly and injected into the population.

ensure_unique_individuals=None - If this parameter has a True value, the genetic algorithm ensures that no two individuals have the same variable values: offspring and mutated candidate solutions that repeat values already seen during the optimisation are regenerated, so the cost function is not evaluated twice for the same values. Duplicates are only likely when the variables take values from a grid defined by the step, so the default (None) means True when all variables have a step, and False when any variable is continuous (added without a step). Set it explicitly to True or False to override this. Ensuring uniqueness adds some computation per generation, especially late in the optimisation, which is usually negligible compared to the cost function execution time.

logging=False - If this parameter has a True value, the log file will be created in the current working directory. The log file contains the flow of genetic algorithm execution, along with values of candidate solutions, decision variables and cost functions in each generation

Previous Parameter Names

In earlier versions, the terms chromosome, gene, allele and cross diversity were used. They are now called candidate solution, decision variable, variable value and variable columnar diversity. The previous GA parameter names are still accepted, both in the constructor and as properties, but they are deprecated: using them emits a DeprecationWarning, and they will be removed in a future release.

Previous name Current name
number_of_mutation_chromosomes number_of_mutation_candidate_solutions
percentage_of_mutation_chromosomes percentage_of_mutation_candidate_solutions
parent_diversity_mutation_chromosome_sampling parent_diversity_mutation_candidate_solution_sampling
chromosome_mutation candidate_solution_mutation
gene_mutation decision_variable_mutation
number_of_mutation_genes number_of_mutation_decision_variables
percentage_of_mutation_genes percentage_of_mutation_decision_variables
cross_diversity_mutation_gene_sampling, cross_diversity_mutation_decision_variable_sampling variable_columnar_diversity_mutation_decision_variable_sampling

The same applies to the value "cross_diversity" of population_mutation, candidate_solution_mutation, decision_variable_mutation and crossover, which is now "variable_columnar_diversity". The previous value is replaced by the current one and a DeprecationWarning is emitted.

ga = GA(cost_function=trig_func, chromosome_mutation="cross_diversity,random")  # works, but emits DeprecationWarnings
ga.number_of_mutation_genes = 2                                                    # works, but emits a DeprecationWarning

Passing both a previous name and its replacement with different values raises a TypeError. Only the GA parameters and their option values have aliases: the module paths and class names used by custom factories (see GA Customisation) and the value property of a variable value (previously variable_value) changed without aliases.

Adding Variables

Variables to be optimized can be added by calling the add method of the GA object. Parameters of this method are the minimum value, the maximum value, and the step. The minimum and maximum value determine a range of possible variable values. The step parameter specifies the step that will be used in changing the variables values during the optimization. The step is optional: a variable added without a step is continuous, and can take any value in the range.

For example:

ga.add(1.0, 4.0, 0.01)

means that the corresponding parameter can have values between 1.0 and 4.0, and the step for changing variable values in optimization is 0.01.

The order in which the variables are added must match the indices of the variables in the cost function. For example, for the given function:

def some_func(args):
      return math.sqrt(abs(args[0])) + math.pow(args[1], 2)

and instantiation of the genetic algorithm object:

ga = GA(cost_function=some_func)

, adding variables may look as it follows:

ga.add(-25, 25, 1) # Refers to args[0]
ga.add(-5, 5, 0.1) # Refers to args[1]

GA Execution and Optimisation Results

Genetic algorithm optimization executes by calling execute method, without parameters. This method returns the object of type GAResults, which contain following properties:

  • success - Indicates if genetic algorithm optimisation executed successfully.
  • min_cost - The minimal cost for optimized variables
  • number_of_iterations - The number of generations executed before the optimisation exited
  • result_values - The dictionary that contains variables' optimized values. The key of this dictionary is the sequence number of variable adding, and also the argument index in the cost function. The value of this dictionary is the optimized value for the variable.
  • messages - Additional messages of the optimizations. This is a tuple structure where first value is a message level ("INFO", "WARNING" or "ERROR"), and the second value is the message text.

For example, for the given function:

def some_func(args):
      return math.sqrt(abs(args[0])) + math.pow(args[1], 2)

, instantiation of the genetic algorithm object:

ga = GA(cost_function=some_func)

, and variables adding:

ga.add(-25, 25, 1.0) # Refers to args[0]
ga.add(-5, 5, 0.1) # Refers to args[1]

, the genetic algorithm execution can return results as it follows:

results = ga.execute()
if results.success: # indicates if the optimisation succeeded
    print("Minimal cost: " + str(results.min_cost))
    print("Number of iterations: " + str(results.number_of_iterations))
    print("Parameter values:")
    for x in results.result_values:
        print(str(x) + ": " + str(results.result_values[x]))               
else:
    print("Calculation not successful.")

for m in results.messages:
    print(m[0] + ": " + m[1])

The output may look like it follows:

Minimal cost: 0.0
Number of iterations: 19
Parameter values:
0: 0.0
1: 0.0

In the case of some inadequate setting, e.g. adding not enough parameters, the output might look like it follows:

Calculation not succesful.
ERROR: Inadequate number of parameters for the passed function!

Casting results to string returns a readable strings containing all relevant data. For example:

s = str(results)
print(s)

might return the following output:

Min cost: 0.0
Number of iterations: 21
Parameter values:
0: 0.0
1: 0.0

GA Customisation

GAdapt follows clean architecture and SOLID principles, allowing easy customization. Create new implementations of abstract classes and pass them to the genetic algorithm through a factory object.

The factory creates all objects used by the genetic algorithm (selectors, mutators, crossover, exit checker, etc.), based on the parameters of the GA object. To replace one of them, subclass GAFactory and override the corresponding get... method. The factory is initialized by the GA object when execute is called, so objects that depend on the GA parameters should be created inside the overridden method.

For example, customizing the candidate solution mutation selector:

import math
from gadapt.factory.ga_factory import GAFactory
from gadapt.ga import GA
from gadapt.operations.mutation.population_mutation.base_candidate_solution_mutation_selector import BaseCandidateSolutionMutationSelector


class BottomMutationSelector(BaseCandidateSolutionMutationSelector):
    """
    Candidate solution mutation selector which selects mutating candidate solutions from the bottom of
    existing unallocated candidate solutions sorted by the cost function value
    """

    def _get_candidate_solutions_for_mutation(self):
        unallocated_candidate_solutions = self._get_unallocated_candidate_solutions(
            lambda candidate_solution: self.population.options.cost_function([g.value for g in candidate_solution])
        )
        return unallocated_candidate_solutions[len(unallocated_candidate_solutions) - self.number_of_mutation_candidate_solutions:]


class BottomMutationFactory(GAFactory):
    def _get_candidate_solution_mutation_selector(self):
        rate_determinator, _ = self._get_candidate_solution_mutation_rate_determinators()
        return BottomMutationSelector(rate_determinator, self.get_decision_variable_mutation_selector())


def some_func(args):
    return math.sqrt(abs(args[0])) + math.pow(args[1], 2)


ga = GA(cost_function=some_func, factory=BottomMutationFactory())
ga.add(-25, 25, 1)
ga.add(-5, 5, 0.1)

print(ga.execute())

Metadata

Release files for gadapt 0.5.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gadapt 0.5.1
File Size Uploaded
gadapt-0.5.1.tar.gz 76.0 kB Details

Release files / gadapt-0.5.1.tar.gz

Download URL gadapt-0.5.1.tar.gz
Size 76.0 kB
Tags Source
SHA-256 checksum
How to use checksums
f1d46ef80ae66800806db380ce33bdfc617506f63ab997a291abde2d623b0121
BLAKE2b-256 checksum
How to use checksums
7a1340a210de6fb933870a63115fe8992df54ebf211f118aa8a30a26afa4549d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.0

Release history Release notifications | RSS feed

0.5.2

1 release file

This release

0.5.1 This release

1 release file

0.5.0

1 release file

0.4.30

1 release file

0.4.29

1 release file

0.4.28

1 release file

0.4.27

1 release file

0.4.26

1 release file

0.4.25

1 release file

0.4.24

1 release file

0.4.23

1 release file

0.4.21

1 release file

0.4.19

1 release file

0.4.18

1 release file

0.4.17

1 release file

0.4.16

1 release file

0.4.15

1 release file

0.4.14

1 release file

0.4.13

1 release file

0.4.12

1 release file

0.4.11

1 release file

0.4.10

1 release file

0.4.9

1 release file

0.4.8

1 release file

0.4.7

1 release file

0.4.6

1 release file

0.4.4

1 release file

0.4.3

1 release file

0.4.2

1 release file

0.4.1

1 release file

0.4.0

1 release file

0.3.6

1 release file

0.3.5

1 release file

0.3.4

1 release file

0.3.3

1 release file

0.3.2

1 release file

0.3.1

1 release file

0.3.0

1 release file

0.2.21

1 release file

0.2.20

1 release file

0.2.19

1 release file

0.2.18

1 release file

0.2.17

1 release file

0.2.16

1 release file

0.2.15

1 release file

0.2.14

1 release file

0.2.13

1 release file

0.2.12

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page