Commit Graph

127 Commits

Author SHA1 Message Date
fb213f04dd Added more structure methods and some quality of life changes
Overall cleaned up a lot of comments.

EasyGA:
- Code cleanup.

Population:
- Added sort_by_best_fitness
- Added parent/mating pool methods.
- Renamed some methods for consistency.

Chromosome:
- Added get_gene(index).

Parent Selection:
- Improved selection methods to use the ga.selection_probability so that the roulette selection actually works well.
- Added stochastic selection.

Survivor Selection:
- Added fill_in_random and fill_in_parents_then_random.

Crossover/Mutation:
- Cleaned up code.
2020-10-13 12:48:20 -04:00
645f704b19 Fixed broken defaults and changed fitness function to is_it_5 2020-10-13 00:10:06 -04:00
b42034c402 Added structure directory and improved sort by fitness 2020-10-12 23:43:28 -04:00
72ae3ec1e7 Even better sort by fitness 2020-10-12 22:51:13 -04:00
86fbd1a9c0 Improved the sort by fitness function 2020-10-12 22:43:41 -04:00
b6ae77c7ea Several Changes
Crossover/Mutation:
- Split into individual and population subclasses.
- Added sequential population crossover selection.
- Renamed and reimplemented mutation methods.

EasyGA:
- Improved make_obj methods for the chromosomes and populations to take arguments.

Initialization:
- Improved to shorter code.
- Fixed repeated error messages

Chromosome:
- Changed get/set_genes to get/set_gene_list.
2020-10-12 21:39:17 -04:00
3424fd4da7 Added blank lines and fixed run_testing 2020-10-12 19:57:57 -04:00
e52b32f23c Fixed some errors with the new updates 2020-10-12 17:14:24 -04:00
94d7c52666 Added comments & fixed small bug
Mostly added comments, but also fixed a small bug in parent selection where the tournament size would be much smaller than it should be.
2020-10-12 09:23:41 -04:00
c3d9ef8bd1 Updated sort_by_best_fitness 2020-10-08 23:16:29 -04:00
dcc3684202 Updated tournament selection
On small populations, there is now a lower bound on the tournament size.
2020-10-08 22:48:45 -04:00
88927f7415 File name changes to match the rest of framework. generation goal was setup twice in EasyGA. 2020-10-08 15:53:35 -04:00
3649293133 Updated GA attribute structure, separated selection file structure
Updated GA attribute structure, separated selection file structure
2020-10-06 22:11:40 -04:00
59f0d03f72 Merge branch 'master' into ryley_beta 2020-10-06 21:11:22 -04:00
af88e4c348 Changed some hard-coded stuf to GA attribute
Changed some hard-coded stuf to GA attribute
2020-10-06 20:58:20 -04:00
2f78c9f464 Roulette Selection added 2020-10-06 18:46:34 -04:00
49c98ba27c First generation now only does initialization stuff
First generation now only does initialization stuff
2020-10-06 18:12:20 -04:00
e7ac0e23f4 Optimizations/updates
1. Deleted duplicate functions in EasyGA
2. Added new index-dependent fitness example
3. GA now auto-sorts by best fitness immediately after the fitness is calculated across the board
4. Removed 'selected' status flag from the Chromosome flag
5. Added mating_pool attribute to the population
6. Changed other code to be in line with 4 and 5
7. Optimized tournament selection method
2020-10-06 17:55:17 -04:00
04c749d95c Add files via upload 2020-10-06 14:50:46 -04:00
4799722a12 Add files via upload 2020-10-06 14:48:51 -04:00
665062fdf1 Updated Implementation Framework
Updated to cover changes made by Dan to Master regarding general design changes

Also added remove_two_worst survivor selection method
2020-10-05 20:46:25 -04:00
68af88df92 Some how we lost the crossover folder 2020-10-05 19:03:16 -04:00
68db360b94 Alot of name changes and file name changes 2020-10-04 23:56:51 -04:00
e05aa7f62b Changed implementation framework
Instead of a nested approach, selection/crossover/mutation are all called separately and directly by the GA. selection_impl was also separated into parent_selection_impl and survivor_selection_impl, as both are needed separately.
2020-10-04 17:59:59 -04:00
c18a531034 Updated selection implementation, added with/without replacement variation 2020-10-04 15:54:38 -04:00
4b375659bb Removed weird github thing with old implementation
Why
2020-10-04 14:35:19 -04:00
7e587d48d0 Test Implementation for selection/crossover/mutation
The current test implementation includes random mutation, single point crossover, and tournament selection. The implementation, in short, is a nested approach. The selection method is the only thing actually called by the GA. Both crossover and mutation occur within the selection method. As long as these three systems all follow a standard input/output system, any implementation we build, as well as any user implementations, will work perfectly. The selection function must take GA as a parameter and output a new population. Crossover takes in GA and outputs a population. Mutation takes a chromosome set and outputs a new chromosome set.

Many of the changes in this commit are regarding this test implementation. I have also changed many of the file names from "x_examples" to "x_types" and updated the class names to follow capitalziation standards. I did this because I feel personally like the built-in mutation, crossover, and selection implementations are less "examples" and more just already built implementations to make the code required from the user smaller.
2020-10-04 08:00:33 -04:00
80ebe8ca0c Comments 2020-10-01 01:33:34 -04:00
7ed6e55e4c Implemented the always get fitness = True / False feature 2020-10-01 00:43:43 -04:00
42f49c43ee Fixed names 2020-09-30 23:39:14 -04:00
aa0c5320c8 Requested file name changes 2020-09-30 23:25:44 -04:00
8377650c58 Changes from meeting 2020-09-30 19:33:23 -04:00
625143da7d Added the termination features 2020-09-30 00:05:39 -04:00
d531888d78 Fixed import problems 2020-09-29 21:23:18 -04:00
5883208c68 fixed 2020-09-29 20:54:18 -04:00
bd76e967ff Added fitness function and changed evolve function 2020-09-29 20:52:06 -04:00
51e3e145da Update EasyGA.py 2020-09-28 11:57:28 -04:00
472c9c2379 Changed example 2020-09-27 23:25:16 -04:00
4b21dc45f6 Update EasyGA.py 2020-09-27 17:42:41 -04:00
e66b4d7fd0 Commented EasyGA.py 2020-09-27 17:26:56 -04:00
d1334090a8 Update EasyGA.py 2020-09-27 16:58:42 -04:00
a302169415 Changed names of impl 2020-09-27 16:40:44 -04:00
6aec9770b6 Further optimizations, error-checking, user-input conversions
1) The initialization now accepts "general" inputs that should apply to each gene. For example, rather than a gene input of [1,100] being interpreted to mean gene 1 hsould be 1 and gene 2 should be 100, it will apply a range of [1,100] to each gene.
2) The initialization now accepts "general" gene_input_types. For example, if the user had a set of index-dependent number values, they could just say ga.gene_input_type = "domain" and the package will propagate that across all genes in the chromosome. The user still has the option of defining the entire array or just defining a specific element if they so choose. For later commits, the general gene_input_type will have to be checked for validity; for example, a string can never be a range.
3) Fixed an issue in the ordering of the initialization function call.
4) Added comments surrounding the signfiicant changes to the initialization.
5) Added example tests to the testing file.
2020-09-25 18:02:45 -04:00
9b77d3619b Remove random gene function 2020-09-25 16:52:09 -04:00
922d046b72 Code optimizations, float-range implementation
Random gene initialization now supports float ranges (assumed by default if gene input includes float). Backend was also optimized and cleaned up greatly.
2020-09-25 16:10:28 -04:00
9d9d0b750c Change domain feature 2020-09-25 15:12:02 -04:00
ed1b2bbe03 Updated gene input checks
Updated the check of incoming data to ensure validity - if the user enters a single digit, say "5", it will automatically be converted to a list like [5,5]. This already worked before with range, but it now works with domain as well.
2020-09-25 11:24:47 -04:00
129925bbdd Cleaned up backend & user interaction with EasyGA
In the initial commit, string inputs would implicitly be seen as domain, and all integer inputs would be seen as range. If the user wanted to assign any integer inputs as domain, they would have to call the entire gene_input_type, even if only to change a single element to domain. It has now been updated to where the user can specifically call the element they want to update. The testing file new_initialization_method_testing.py reflects this.
2020-09-25 11:14:09 -04:00
5821e709a3 New Initialization Method
This is a test implementation of a potential new initialization method. A testing file - new_initialization_method_testing.py - is included to allow for quick testing.

In summary here is are the major points:
1) Two new attributes of GA were created - gene_input and gene_input_type. gene_input holds the user's custom range(s)/domain(s) after it gets passed to the initialize() function. gene_input_type holds an array with the same length as the chromosomes that holds the input type of the user's gene_input on a gene-by-gene basis. It does this in the same exact way that index-dependent gene ranges/domains are handled. By making the gene_input_type array the same size as the chromosome, the elements can be paired very easily. The acceptable values for this are either "range" or "domain". With a range, any value between the two can be generated; with domain, only the two elements included can be selected from randomly.
2) As mentioned in change 1, the user now has to pass their range(s)/domain(s) to the initialize() function.
3) The package is capable of implicitly determining if a certain input from the user is a range or domain. Strings can only ever be a domain – if given an element that only includes integers, the program assumes range.
4) If the user wishes to use numbers only as a domain, they can specify this by directly interacting with the ga.gene_input_type (or through a setter function).
5) the initialize() function in the GA object determines the implicit range/domain assignments if the user doesn’t do so themselves.
6) The random_initialization() function is effectively the same, except there is now an if/else to determine if the user is using the built-in gene creation function or not. If they are, then pass the gene_input, gene_input_type, and current gene index as arguments to the gene function. If they are using their own function, random_initialization() functions exactly the same way as it does in the current master branch.
7) Based on all the settings mentioned above, the random_gene() function will create a value before passing it back to random_initialization().
2020-09-25 01:15:53 -04:00
5c5d6920b2 Domain update
Can set the domain to either a range or a list of values.
2020-09-24 23:51:21 -04:00