# it3708 - bio-inspired artificial intelligence ## assignment 1 this project is written in [odin](https://odin-lang.org/) and [uiua](https://www.uiua.org/) ([uiua-plot](https://github.com/Omnikar/uiua-plot)) with [nix](https://nixos.org/) for dependency management. with nix installed, just run ``` $ nix run ``` and it will run through the pipeline. it will generate data/image files in `output/`. ### implementation overview i implement a genetic algorithm to solve the binary knapsack problem. 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`.