diff --git a/README.md b/README.md index 94e3bcf..c4ae76d 100644 --- a/README.md +++ b/README.md @@ -10,21 +10,23 @@ $ nix run ``` and it will run through the pipeline. it will generate data/image files in `output/`. -### implementation overview +## how to use -i implement a genetic algorithm to solve the binary knapsack problem. +in `src/common.odin` there are multiple (hyper)parameters that can be set to influence how the genetic algorithm will run. here i will go through the available options to set. -this is done by -- first generating a population of individuals/chromosomes, modeled as bit_arrays for memory performance. -- then continue for some fixed amount of generations - - calculate the fitness of each chromosome in the population by calculating the distance to the capacity. to avoid negative fitness values, chromosomes that overshoot the capacity are penalized. - - create offspring by - - selecting two parents using a tournament selection - - then performing single point crossover between the parents to create two children - - then mutate each child with random bit-flip mutations. - - create a new population via elitism survivor selection -- repeat - -each generation, the fitness value maximum, minimum and mean values are logged in `output/data.csv`. - -this data is read through uiua `src/plot.ua` to plot the data to `output/plot.png`. +| parameter | possible values | note | +|---|---|---| +| `PROBLEM_TYPE` | `"knapsack"`, `"feature_selection"` | part 1 or part 2 of the task | +| `GENERATIONS` | int > 0 | how many generations to simulate for | +| `POPULATION_SIZE` | int > 0 | how many individuals in population. remains constant. | +| `ELITISM_COUNT` | unsigned int | how many elites to bypass selection pipeline | +| `SKEW` | unsigned int | reproductive skew, influences how many parents and children compete for selection | +| `TOURNAMENT_SIZE` | unsigned int | how many to participate in tournament, if tournament selection is used | +| `CROSSOVER_RATE` | [0, 1] | chance of performing crossover | +| `MUTATION_RATE` | [0, 1] | chance of random mutation occuring | +| `PARENT_SELECTION_POLICY` | `random_selection`, `roulette_selection`, `tournament_selection` | what operator to use | +| `CROSSOVER_POLICY` | `single_point_crossover`, `two_point_crossover`, `uniform_crossover` | | +| `MUTATION_POLICY` | `bit_flip_mutation`, `swap_mutation`, `inversion_mutation` | | +| `SURVIVOR_SELECTION_POLICY` | `generational_replacement`, `deterministic_crowding`, `probabilistic_crowding` | | +| `RANDOM_SEED` | unsigned int | random seed if set to 0 | +| `OUTPUT_FILE` | string path | where to store data. for simplicity, `plot.ua` expects `output/data.csv` as the output path. |