This repository contains 4 different project implementing different topics regarding Artificial Inteligence.
Algorithm was created for problem of Facility Layout Optimization (examlpe below).
Grid 3x4, 9 machines need to be set up, each pair has a cost depending on destination between machines on grid + extra parameters. Sample data is stored in .json files in folder, README for .json.
- selection - tournamet and roulette
- crossover - partially matched
- mutation - shuffling random part of flattened array
Sample genetic algorithm implementation.
CSP implemented for solving two problems:
- 0 or 1 for each cell
- max sequence of same numbers of length less than 3
- each row and column is unique
- each row and column has same number of 0 and 1
Rules for solving futoshiki problem can be found here.
- CSP_Problem - original problem, intact (Binary or Futoshiki)
- CSP_PartialSolution - attempt of solving CSP_Problem, not neccesserly completed or correct
- CSP_Solver - one of two CSP solving approaches:
- Backtracking - setting next element till constraints are broken, then go back
- ForwardChecking - after each step update domains for each cell to see wheather any element can be selected, if not then go back
Overview of interfaces and their implementations.
Additionaly for each problem are avaliable different heuristics for ordering cells to fill and ordering their domains.
Both problems:
- in order (left to right, up to down) (+ domain order swapped)
- smallest domain first (+ domain order swapped)
Binary:
- most in rows first (+ domain order swapped)
Futoshiki:
- most constraints first (+ domain order swapped)
- most constraints first unless domain size of any equals 1 (+ domain order swapped)
Implementation of checkers engine for human player and bots. Avaliable bots:
- Random (for comparison)
- Min-max
- Aplha-beta
For accessment of grid avaliable are two approaches:
- simple - counting figures (with weights normal=1, crowned=5)
- complex - counting figures + the closer to the border the better
Game is avaliable in version:
- only in console (good for bot vs bot): implementation
- clicable gui + console for displaying wrong inputs and past moves: implementation
Creating models for recognizing book genre from it's description.
For books avaliable in booksummaries.txt, in format:
620 /m/0hhy Animal Farm George Orwell 1945-08-17 {"/m/016lj8": "Roman \u00e0 clef", "/m/06nbt": "Satire", "/m/0dwly": "Children's literature", "/m/014dfn": "Speculative fiction", "/m/02xlf": "Fiction"} Old Major, … malleable propaganda.
843 /m/0k36 A Clockwork Orange Anthony Burgess 1962 {"/m/06n90": "Science Fiction", "/m/0l67h": "Novella", "/m/014dfn": "Speculative fiction", "/m/0c082": "Utopian and dystopian fiction", "/m/06nbt": "Satire", "/m/02xlf": "Fiction"} Alex, a teenager living … fatalistically.
...
We process data choosing 4 most popular genres (book count, books with multiple genres from the list were excluded):
Science Fiction 2395
Fantasy 1641
Children's literature 1287
Crime Fiction 970
Books were saved in file normalised_genres.csv, in format:
id title Children's literature Science Fiction Fantasy Crime Fiction description
/m/0hhy Animal Farm 1 0 0 0 Old Major, … malleable propaganda.
/m/0k36 A Clockwork Orange 0 1 0 0 Alex, a teenager living … fatalistically.
...
For text lametization WordNetLemmatizer from library nltk with stopwords was used, implementation.
Before:
Old Major, the old boar on the Manor Farm, calls the animals on the farm for a meeting, where he compares the humans to parasites and teaches the animals a revolutionary song, 'Beasts of England'. …
After:
old major old boar manor farm call animal farm meeting compare human parasite teach animal revolutionary song england …
Method taking model type and number of best feacutes is implemented here.
For purposes of comparing different models as well as testing texts from outside the avaliable ones (using trained models) see here.