check_interval_01
This function checks if a design variable is out of the limits established x_ lower and x_ upper and updates the variable if necessary.
check_interval_01(x_i_old, x_lower, x_upper)
Input variables
Name | Description | Type |
x_i_old | Current design variables of the i agent | List |
x_lower | Lower limit of the design variables | List |
x_upper | Upper limit of the design variables | List | </table> Output variables {: .label .label-yellow } Name | Description | Type |
x_i_new | Update variables of the i agent | List |
Example 1 {: .label .label-blue } Use the `check_interval_01` function to generate a new list with the values inside the range $\mathbf{x}_L = [1, 2, 3]$ and $\mathbf{x}_U = [5, 5, 5]$. Consider current solution $\mathbf{x}_i = [6, -1, 2.5]$. ```python # Import # pip install metapy-toolbox or pip install --upgrade metapy-toolbox from metapy_toolbox import check_interval_01 # or import * # Data xL = [1, 2, 3] xU = [5, 5, 5] xI = [6, -1, 2.5] # Call function xINew = check_interval_01(xI, xL, xU) # Output details print(xINew, type(xINew)) ``` ```bash [5.0, 2.0, 3.0] <class 'list'> ``` Example 2 {: .label .label-blue } Use the `check_interval_01` function to generate a new list with the values inside the range $\mathbf{x}_L = [1, 2, 3]$ and $\mathbf{x}_U = [5, 5, 5]$. Consider current solution $\mathbf{x}_i = [6, 6, 6]$. ```python # Import # pip install metapy-toolbox or pip install --upgrade metapy-toolbox from metapy_toolbox import check_interval_01 # or import * # Data xL = [1, 2, 3] xU = [5, 5, 5] xI = [6, 6, 6] # Call function xINew = check_interval_01(xI, xL, xU) # Output details print(xINew, type(xINew)) ``` ```bash [5, 5, 5] <class 'list'> ``` Example 3 {: .label .label-blue } Use the `check_interval_01` function to generate a new list with the values inside the range $\mathbf{x}_L = [1, 2, 3]$ and $\mathbf{x}_U = [5, 5, 5]$. Consider current solution $\mathbf{x}_i = [-1, -1, -1]$. ```python # Import # pip install metapy-toolbox or pip install --upgrade metapy-toolbox from metapy_toolbox import check_interval_01 # or import * # Data xL = [1, 2, 3] xU = [5, 5, 5] xI = [-1, -1, -1] # Call function xINew = check_interval_01(xI, xL, xU) # Output details print(xINew, type(xINew)) ``` ```bash [1, 2, 3] <class 'list'> ```