2026-02-01 13:28:32 +01:00
2026-02-01 12:11:38 +01:00
2026-02-01 13:50:03 +01:00
2026-01-30 20:21:23 +01:00
2026-01-31 18:57:20 +01:00
2026-01-31 19:14:58 +01:00

it3708 - bio-inspired artificial intelligence

assignment 1

this project is written in odin and uiua (uiua-plot) with nix 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.

Description
bio-inspired artificial intelligence
Readme 550 KiB
Languages
Odin 94.1%
Nix 5.9%