How to use the expression.Operations.get_binary_operations function in Expression

To help you get started, we’ve selected a few Expression examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github StanislavUshakov / ArtificialImmuneSystem / immune.py View on Github external
def binary_mutation(self):
        """
        Changes one binary operations to another
        """
        binary_operations = self._get_all_nodes_by_filter(lambda n: n.is_binary())
        if not binary_operations: return

        selected_binary = random.choice(binary_operations)
        selected_binary.operation = random.choice(Operations.get_binary_operations())
github StanislavUshakov / ArtificialImmuneSystem / expression.py View on Github external
def generate_operator(cls, only_binary:bool=False):
        """
        Returns randomly selected allowed operations.
        The possibility of a binary operation is higher than possibility
        of an unary operation.
        IF isBinary = True returns binary operation
        """
        if only_binary or random.random() < 0.75:
            return random.choice(Operations.get_binary_operations())
        else:
            return random.choice(Operations.get_unary_operations() +
                                 Operations.get_binary_operations())
github StanislavUshakov / ArtificialImmuneSystem / expression.py View on Github external
def generate_operator(cls, only_binary:bool=False):
        """
        Returns randomly selected allowed operations.
        The possibility of a binary operation is higher than possibility
        of an unary operation.
        IF isBinary = True returns binary operation
        """
        if only_binary or random.random() < 0.75:
            return random.choice(Operations.get_binary_operations())
        else:
            return random.choice(Operations.get_unary_operations() +
                                 Operations.get_binary_operations())