code: def get_particle_obj(X, **kwargs):
      """Calculates the objective function value which is
      total revenue minus penalty of capacity violations"""
      # X is the decision variable. X is vector in the lenght of number of items
      # $ value of items
      value = kwargs["value"]
      # weight of items
      weight = kwargs["weight"]
      # Total revenue
      revenue = sum([value[i] * np.round(X[i]) for i in item_range])
      # Total weight of selected items
      used_capacity = sum(
          [kwargs["weight"][i] * np.round(X[i]) for i in item_range]
      )
      # Total capacity violation with 100 as a penalty cofficient
      capacity_violation = 100 * min(0, capacity - used_capacity)
      # the objective function minimizes the negative revenue, which is the same
      # as maximizing the positive revenue
      return -1 * (revenue + capacity_violation)
  
file_path: pyswarms/tests/optimizers/test_tolerance.py
imports: import pytest
  import random
  import numpy
  from pyswarms.backend.topology import Star
  from pyswarms.single import GlobalBestPSO, LocalBestPSO, GeneralOptimizerPSO
label_desc: Use image node_id 1 for calling a global function with example usage: get_particle_obj(X) and returns: unknown