Sha256: f37fd9210ae2f12ec347c7cf28a0bb9926b7a62761a659affc07292cf9a17df5

Contents?: true

Size: 1.45 KB

Versions: 4

Compression:

Stored size: 1.45 KB

Contents

# encoding: utf-8

module Veritas
  class Optimizer
    module Function
      class Predicate

        # Abstract base class representing GreaterThan optimizations
        class GreaterThan < self
          include Comparable

          # Optimize when the operands are a contradiction
          class Contradiction < self
            include Predicate::Contradiction

            # Test if the operands are a contradiction
            #
            # @return [Boolean]
            #
            # @api private
            def optimizable?
              left.equal?(right) ||
              GreaterThanOrEqualTo::Contradiction.new(operation).optimizable?
            end

          end # class Contradiction

          # Optimize when the operands are a tautology
          class Tautology < self
            include Predicate::Tautology

            # Test if the operands are a tautology
            #
            # @return [Boolean]
            #
            # @api private
            def optimizable?
              operation.class.call(Util.min(left), Util.max(right))
            end

          end # class Tautology

          Veritas::Function::Predicate::GreaterThan.optimizer = chain(
            ConstantOperands,
            Contradiction,
            Tautology,
            NormalizableOperands,
            UnoptimizedOperands
          )

        end # class GreaterThan
      end # class Predicate
    end # module Function
  end # class Optimizer
end # module Veritas

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
veritas-optimizer-0.0.7 lib/veritas/optimizer/function/predicate/greater_than.rb
veritas-optimizer-0.0.6 lib/veritas/optimizer/function/predicate/greater_than.rb
veritas-optimizer-0.0.5 lib/veritas/optimizer/function/predicate/greater_than.rb
veritas-optimizer-0.0.4 lib/veritas/optimizer/function/predicate/greater_than.rb