code: def evalNQueens(individual):
      """Evaluation function for the n-queens problem.
  
      The problem is to determine a configuration of n queens
      on a nxn chessboard such that no queen can be taken by
      one another. In this version, each queens is assigned
      to one column, and only one queen can be on each line.
      The evaluation function therefore only counts the number
      of conflicts along the diagonals.
      """
      size = len(individual)
      # Count the number of conflicts with other queens.
      # The conflicts can only be diagonal, count on each diagonal line
      left_diagonal = [0] * (2 * size - 1)
      right_diagonal = [0] * (2 * size - 1)
  
      # Sum the number of queens on each diagonal:
      for i in range(size):
          left_diagonal[i + individual[i]] += 1
          right_diagonal[size - 1 - i + individual[i]] += 1
  
      # Count the number of conflicts on each diagonal
      sum_ = 0
      for i in range(2 * size - 1):
          if left_diagonal[i] > 1:
              sum_ += left_diagonal[i] - 1
          if right_diagonal[i] > 1:
              sum_ += right_diagonal[i] - 1
      return (sum_,)
  
file_path: deap/examples/ga/nqueens.py
imports: import random
  import numpy
  from deap import algorithms
  from deap import base
  from deap import creator
  from deap import tools
label_desc: Use image node_id 1 for calling a global function with example usage: evalNQueens(individual) and returns: sum_