Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clausules.vector <- c();
- fitness.3-SAT <- function(chromosome) {
- counter <- 0;
- for (i in seq(1, length(clausules.vector), by = 3)) {
- temp.vector <- c(0, 0, 0);
- for (j in 0:2) {
- temp.element <- clausules.vector[i+j];
- if (temp.element < 0) {
- temp.vector[i+j] <- negate(chromosome[abs(temp.element)]);
- } else {
- temp.vector[i+j] <- chromosome[abs(temp.element)];
- }
- }
- if (1 %in% temp.vector) {
- counter <- counter + 1;
- }
- }
- return (-counter);
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement