Skip to content

Commit

Permalink
some typos in comments and 1 variable fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
nbro committed Dec 30, 2020
1 parent 31d94fb commit e523587
Show file tree
Hide file tree
Showing 20 changed files with 46 additions and 46 deletions.
8 changes: 4 additions & 4 deletions src/agent/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ def __init__(self, ip):
# Interaction probability received in constructor
self.interaction_probability = ip

# Only initialize singel individual. Single agent can only have single genetic information
# Only initialize single individual. Single agent can only have single genetic information
self.individual = initialisation(1)

# Evaluate the fitness for the the individual
self.individual = evaluate_fitness(self.individual)

# Flag which store the boolean value for other nebouring agents found or not
# Flag which store the boolean value for other neighbouring agents found or not
self.agents_found = False


Expand Down Expand Up @@ -83,12 +83,12 @@ def act(self):
# Sort the individuals list
individuals.sort(reverse=True)

# Get the higest performing individual from the sorted population
# Get the highest performing individual from the sorted population
self.new_individual = individuals[0]

def update(self):
#Update the information if the agent has sense nearby agents
if self.agents_found:

# Repalce the individual with the higest performing individual obtained from act method
# Replace the individual with the highest performing individual obtained from act method
self.individual = [self.new_individual]
4 changes: 2 additions & 2 deletions src/algorithm/distributed_algorithm/search_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ def create_agents(n,p):

def search_loop():
"""
This loop is used when the multiagent parameter is passed
This loop is used when the multi-agent parameter is passed
"""
# Create a list of agents based on the paramater passed
# Create a list of agents based on the parameter passed
agents = create_agents(params['AGENT_SIZE'],params['INTERACTION_PROBABILITY'])

##Multi-Agent based GE
Expand Down
2 changes: 1 addition & 1 deletion src/algorithm/hill_climbing.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from utilities.stats import trackers


"""Hill-climbing is just about the simplest metaheuristic there
"""Hill-climbing is just about the simplest meta-heuristic there
is. It's of interest in GP/GE because of the lingering suspicion among
many researchers that crossover just doesn't work. This goes back to
90s work by Chellapilla and by O'Reilly. Today, many papers are
Expand Down
2 changes: 1 addition & 1 deletion src/algorithm/mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def map_ind_from_genome(genome):
The number of used codons.
"""

# Create local variables to avoide multiple dictionary lookups
# Create local variables to avoid multiple dictionary lookups
max_tree_depth, max_wraps = params['MAX_TREE_DEPTH'], params['MAX_WRAPS']
bnf_grammar = params['BNF_GRAMMAR']

Expand Down
8 changes: 4 additions & 4 deletions src/algorithm/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,12 @@
# encourage diversity in the population.
'MUTATE_DUPLICATES': False,

# MULTIAGENT Parameters
# True or False for Multiagent
# MULTI-AGENT Parameters
# True or False for multi-agent
'MULTIAGENT': False,
# Agent Size. Number of agents having their own copy of genetic material
'AGENT_SIZE': 100,
# Interaction Probablity. How frequently the agents can interaction with each other
# Interaction Probability. How frequently the agents can interaction with each other
'INTERACTION_PROBABILITY': 0.5,

# OTHER
Expand All @@ -201,7 +201,7 @@ def load_params(file_name):
try:
open(file_name, "r")
except FileNotFoundError:
s = "algorithm.paremeters.load_params\n" \
s = "algorithm.parameters.load_params\n" \
"Error: Parameters file not found.\n" \
" Ensure file extension is specified, e.g. 'regression.txt'."
raise Exception(s)
Expand Down
4 changes: 2 additions & 2 deletions src/algorithm/search_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def search_loop():
"""

if params['MULTICORE']:
# initialize pool once, if mutlicore is enabled
# initialize pool once, if multi-core is enabled
params['POOL'] = Pool(processes=params['CORES'], initializer=pool_init,
initargs=(params,)) # , maxtasksperchild=1)

Expand Down Expand Up @@ -55,7 +55,7 @@ def search_loop_from_state():
individuals = trackers.state_individuals

if params['MULTICORE']:
# initialize pool once, if mutlicore is enabled
# initialize pool once, if multi-core is enabled
params['POOL'] = Pool(processes=params['CORES'], initializer=pool_init,
initargs=(params,)) # , maxtasksperchild=1)

Expand Down
2 changes: 1 addition & 1 deletion src/fitness/base_ff_classes/moo_ff.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def value(fitness_vector, objective_index):
:param fitness_vector: A vector/list of fitnesses.
:param objective_index: The index of the desired fitness.
:return: The fitness at the objective index of the fitness vecror.
:return: The fitness at the objective index of the fitness vector.
"""

if not isinstance(fitness_vector, list):
Expand Down
4 changes: 2 additions & 2 deletions src/fitness/multi_objective/singlefit_multiobj.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
class singlefit_multiobj(base_ff):
"""
An example of a single fitness class that generates
two fitness values for multiobjective optimisation
two fitness values for multi-objective optimisation
"""

maximise = True
Expand Down Expand Up @@ -57,7 +57,7 @@ def value(fitness_vector, objective_index):
:param fitness_vector: A vector/list of fitnesses.
:param objective_index: The index of the desired fitness.
:return: The fitness at the objective index of the fitness vecror.
:return: The fitness at the objective index of the fitness vector.
"""

if not isinstance(fitness_vector, list):
Expand Down
2 changes: 1 addition & 1 deletion src/fitness/progsys.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def __init__(self):
params['GRAMMAR_FILE'])
self.eval = self.create_eval_process()
if params['MULTICORE']:
print("Warming: Multicore is not supported with progsys "
print("Warming: multi-core is not supported with progsys "
"as fitness function.\n"
"Fitness function only allows sequential evaluation.")

Expand Down
2 changes: 1 addition & 1 deletion src/fitness/regex/RegexEval.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def __init__(self):

if params['MULTICORE']:
s = "fitness.regex.RegexEval.RegexEval\n" \
"Error: Multicore evaluation cannot be used with RegexEval " \
"Error: multi-core evaluation cannot be used with RegexEval " \
"fitness function, as this fitness function already manages " \
"processes using the multiprocessing library."
raise Exception(s)
Expand Down
2 changes: 1 addition & 1 deletion src/fitness/sequence_match.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def compress(s):

def compressibility(s):
"""
Compressability is in [0, 1]. It's high when the compressed string
Compressibility is in [0, 1]. It's high when the compressed string
is much shorter than the original.
:param s:
Expand Down
4 changes: 2 additions & 2 deletions src/operators/subtree_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def combine_snippets():
# Get new snippets list.
updated_snippets = sorted(trackers.snippets.keys())

# Initialise counter for reduction interations.
# Initialise counter for reduction iterations.
no_passes = 1

while updated_snippets != original_snippets:
Expand Down Expand Up @@ -454,7 +454,7 @@ def check_reductions(alt_cs, pre, aft, idx, children):
children)

elif all([i != [] for i in children]):
# We have compiled a full set of potneital
# We have compiled a full set of potential
# children to reduce_trees. Generate a key and check
# if it exists.
generate_key_and_check(pre, aft, reduce,
Expand Down
2 changes: 1 addition & 1 deletion src/representation/individual.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def evaluate(self):
evaluation on either training or test distributions. Sets fitness
value.
:return: Nothing unless multicore evaluation is being used. In that
:return: Nothing unless multi-core evaluation is being used. In that
case, returns self.
"""

Expand Down
10 changes: 5 additions & 5 deletions src/scripts/GE_LR_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,18 @@ def parse_terminals(target):
for T in sorted(terms.keys()):
# Iterate over all Terminals.

# Find all occurances of this terminal in the target string.
occurrances = []
# Find all occurrences of this terminal in the target string.
occurrences = []
index = 0
while index < len(target):
index = target.find(T, index)
if index not in occurrances and index != -1:
occurrances.append(index)
if index not in occurrences and index != -1:
occurrences.append(index)
index += len(T)
else:
break

for idx in occurrances:
for idx in occurrences:
# Check each occurrence of this terminal in the target string.

for NT in terms[T]:
Expand Down
10 changes: 5 additions & 5 deletions src/utilities/algorithm/NSGA2.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def compute_pareto_metrics(population):


def sort_non_dominated(population):
"""Sort the first *k* *population* into different nondomination levels
"""Sort the first *k* *population* into different non-domination levels
using the "Fast Nondominated Sorting Approach" proposed by Deb et al.,
see [Deb2002]_. This algorithm has a time complexity of :math:`O(MN^2)`,
where :math:`M` is the number of objectives and :math:`N` the number of
Expand All @@ -32,7 +32,7 @@ def sort_non_dominated(population):
:param population: A list of individuals to select from.
:returns: A list of Pareto fronts (lists), the first list includes
nondominated individuals.
non-dominated individuals.
.. [Deb2002] Deb, Pratab, Agarwal, and Meyarivan, "A fast elitist
non-dominated sorting genetic algorithm for multi-objective
Expand Down Expand Up @@ -100,13 +100,13 @@ def sort_non_dominated(population):

def dominates(individual1, individual2):
"""
Returns whether or not *indvidual1* dominates *indvidual2*. An individual
Returns whether or not *individual1* dominates *individual2*. An individual
dominates another if all fitness values are at least as good on all
objectives, and strictly better than on at least one objective.
:param individual1: The individual that would be dominated.
:param individual2: The individual dominant.
:returns: :obj:`True` if indvidual_1 dominates indvidual_2,
:returns: :obj:`True` if *individual1* dominates *individual2*,
:obj:`False` otherwise.
"""

Expand Down Expand Up @@ -235,7 +235,7 @@ def crowded_comparison_operator(self, other, pareto):
:return: True if *self* is better than *other* and False otherwise.
"""

# Between two solutions with differing nondomination ranks, we prefer the
# Between two solutions with differing non-domination ranks, we prefer the
# solution with the lower (better) rank. Otherwise, if both solutions
# belong to the same front, then we prefer the solution that is located in
# a lesser crowded region, i.e., with the larger crowding distance.
Expand Down
12 changes: 6 additions & 6 deletions src/utilities/algorithm/command_line_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,14 @@ def __call__(self, parser, namespace, value, option_string=None):
parser.add_argument('--codon_size',
dest='CODON_SIZE',
type=int,
help='Sets the range from 0 to condon_size to be used '
help='Sets the range from 0 to codon_size to be used '
'in genome, requires int value')
parser.add_argument('--max_genome_length',
dest='MAX_GENOME_LENGTH',
type=int,
help='Sets the maximum chromosome length for the '
'algorithm, requires int value. The default max '
'genome length is set to None, i.e. gemomes can '
'genome length is set to None, i.e. genomes can '
'grow indefinitely. This can also be set by '
'specifying the max genome length to be 0.')
parser.add_argument('--max_wraps',
Expand Down Expand Up @@ -234,7 +234,7 @@ def __call__(self, parser, namespace, value, option_string=None):
parser.add_argument('--tournament_size',
dest='TOURNAMENT_SIZE',
type=int,
help='Sets the number of indivs to contest tournament,'
help='Sets the number of individuals to contest tournament,'
' requires int.')
parser.add_argument('--selection_proportion',
dest='SELECTION_PROPORTION',
Expand Down Expand Up @@ -348,12 +348,12 @@ def __call__(self, parser, namespace, value, option_string=None):
dest='MULTICORE',
action='store_true',
default=None,
help='Turns on multicore evaluation.')
help='Turns on multi-core evaluation.')
parser.add_argument('--cores',
dest='CORES',
type=int,
help='Specify the number of cores to be used for '
'multicore evaluation. Requires int.')
'multi-core evaluation. Requires int.')

# REPLACEMENT
parser.add_argument('--replacement',
Expand Down Expand Up @@ -473,7 +473,7 @@ def __call__(self, parser, namespace, value, option_string=None):
dest='MULTIAGENT',
action='store_true',
default=None,
help='This enable the multiagent mode. If this mode is'
help='This enable the multi-agent mode. If this mode is'
' enabled the search_loop and step parameter are'
' overridden with search_multiagent and step_multiagent'
' respectively')
Expand Down
6 changes: 3 additions & 3 deletions src/utilities/algorithm/initialise_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,15 @@ class name matches the file name.
else:
# Just module name specified. Use default location.

# If multiagent is specified need to change
# If multi-agent is specified need to change
# how search and step module is called
# Loop and step functions for multiagent is contained
# Loop and step functions for multi-agent is contained
# inside algorithm search_loop_distributed and
# step_distributed respectively

if params['MULTIAGENT'] and \
( op == 'SEARCH_LOOP' or op == 'STEP' ) :
# Define the directory structure for the multiagent search
# Define the directory structure for the multi-agent search
# loop and step
multiagent_ops = {'search_loop':'distributed_algorithm.search_loop' \
,'step':'distributed_algorithm.step'}
Expand Down
4 changes: 2 additions & 2 deletions src/utilities/fitness/error_metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def hinge(y, yhat):
if 0 in y_vals:
y[y == 0] = -1

# Our definition of hinge loss cannot be used for multiclass
# Our definition of hinge loss cannot be used for multi-class
assert len(y_vals) == 2

# NB not np.max. maximum does element-wise max. Also we use the
Expand Down Expand Up @@ -104,7 +104,7 @@ def f1_score(y, yhat):
if -1 in y_vals:
y[y == -1] = 0

# We binarize with a threshold, so this cannot be used for multiclass
# We binarize with a threshold, so this cannot be used for multi-class
assert len(y_vals) == 2

# convert real values to boolean {0, 1} with a zero threshold
Expand Down
2 changes: 1 addition & 1 deletion src/utilities/fitness/math_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def percentile(sorted_list, p):
in a sorted list
:param sorted_list: The sorted list
:param p: The percetile
:param p: The percentile
:return: The element corresponding to the percentile
"""

Expand Down
2 changes: 1 addition & 1 deletion src/utilities/representation/check_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def check_ind_from_parser(ind, target):
Checks the mapping of an individual generated by the GE parser against
the specified target string to ensure the GE individual is correct.
:param ind: An instance of the representation.individaul.Individual class.
:param ind: An instance of the representation.individual.Individual class.
:param target: A target string against which to match the phenotype of
the individual.
:return: Nothing.
Expand Down

0 comments on commit e523587

Please sign in to comment.