This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Based on the Vijini Mallawaarachchi's article in Towards Data Science | |
https://towardsdatascience.com/introduction-to-genetic-algorithms-including-example-code-e396e98d8bf3 | |
*/ | |
"strict mode" | |
function Individual(numOfGenes) { | |
const _genes = Array(numOfGenes).fill(0).map(i => Math.floor(Math.random() * 1000 % 2)); | |
let _fitness = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Array.prototype.shuffle = function () { | |
return this.map(item => { | |
return { | |
index: Math.random(), | |
value: item | |
} | |
}) | |
.sort((item1, item2) => item1.index - item2.index) | |
.map(item => item.value) | |
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.