Source code for mealpy.utils.transfer

#!/usr/bin/env python
# Created by "Thieu" at 21:32, 05/11/2023 ----------%
#       Email: nguyenthieu2102@gmail.com            %
#       Github: https://github.com/thieu1995        %
# --------------------------------------------------%

import numpy as np
from scipy.special import erf


# ________________________V-shaped transfer functions______________________


[docs]def vstf_01(x): return np.abs(erf((np.sqrt(np.pi) / 2) * x))
[docs]def vstf_02(x): return np.abs(np.tanh(x))
[docs]def vstf_03(x): return np.abs(x / np.sqrt(1. + np.square(x)))
[docs]def vstf_04(x): return np.abs((2. / np.pi) * np.arctan((np.pi / 2) * x))
##______________________S-shaped transfer functions_______________________
[docs]def sstf_01(x): return 1 / (1 + np.exp(-2. * x))
[docs]def sstf_02(x): return 1. / (1 + np.exp(-x))
[docs]def sstf_03(x): return 1. / (1 + np.exp(-x / 3.))
[docs]def sstf_04(x): return 1. / (1 + np.exp(-x / 2.))