Advertisement
Guest User

Untitled

a guest
Nov 17th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 0.48 KB | None | 0 0
  1. clausules.vector <- c();
  2.  
  3. fitness.3SAT <- function(chromosome) {
  4.     counter <- 0;
  5.     for (i in seq(1, length(clausules.vector), by = 3)) {
  6.         temp.vector <- c(0, 0, 0);
  7.         for (j in 0:2) {
  8.             temp.element <- clausules.vector[i+j];
  9.             if (temp.element < 0) {
  10.                 temp.vector[i+j] <- negate(chromosome[abs(temp.element)]);
  11.             } else {
  12.                 temp.vector[i+j] <- chromosome[abs(temp.element)];
  13.             }
  14.         }
  15.         if (1 %in% temp.vector) {
  16.             counter <- counter + 1;
  17.         }
  18.     }
  19.     return (-counter);
  20. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement