From 6263560315d945b5d0f76280b712df1f4c4076ac Mon Sep 17 00:00:00 2001 From: Fredrik Robertsen Date: Sat, 31 Jan 2026 19:14:43 +0100 Subject: [PATCH] add README.md --- README.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..94e3bcf --- /dev/null +++ b/README.md @@ -0,0 +1,30 @@ +# 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`.