def sphere(x):
    # When using hypercomplex numbers, we always need to span them
    # before feeding into the function
    x_span = h.span(x, lower_bound, upper_bound)

    # Declaring Sphere's function
    y = x_span**2

    return np.sum(y)
def test_span():
    array = np.array([[0.5, 0.75, 0.5, 0.9]])

    lb = [0]

    ub = [10]

    span_array = hypercomplex.span(array, lb, ub)

    assert span_array > 0
Beispiel #3
0
        def __hyper_spanning(x):
            """Wraps the objective function for calculating its output.

            Args:
                x (np.array): Array of hyper-values.

            Returns:
                The objective function itself.

            """

            # Spans `x` between lower and upper bounds
            x = h.span(x, lb, ub)

            return f(x)
Beispiel #4
0
import numpy as np

import opytimizer.math.hypercomplex as h

# Creating an array with ones
a = np.ones((2, 4))
print(f'Array: {a}')

# Declaring lower bounds
lb = np.array([-5, -5])

# Also, we need to declare upper bounds
ub = np.array([-2, -2])

# Calculating the hypercomplex number norm
norm = h.norm(a)
print(f'Norm Array: {norm}')

# Spanning it into lower and upper bounds
span = h.span(a, lb, ub)
print(f'Spanned Array: {span}')