Sha256: 1f08a2c1a77892dc7e4d4e6989c97095174d1b4c96d95aea5e0fedf30cc817b8

Contents?: true

Size: 1.58 KB

Versions: 4

Compression:

Stored size: 1.58 KB

Contents

# encoding: utf-8

module Veritas
  class Optimizer
    module Function
      class Predicate

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

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

            # Test if the operands are a contradiction
            #
            # @return [Boolean]
            #
            # @api private
            def optimizable?
              super || LessThan::Tautology.new(operation.inverse).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 = self.operation
              GreaterThan::Tautology.new(operation).optimizable? ||
              Equality::Tautology.new(operation).optimizable?
            end

          end # class Tautology

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

        end # class GreaterThanOrEqualTo
      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_or_equal_to.rb
veritas-optimizer-0.0.6 lib/veritas/optimizer/function/predicate/greater_than_or_equal_to.rb
veritas-optimizer-0.0.5 lib/veritas/optimizer/function/predicate/greater_than_or_equal_to.rb
veritas-optimizer-0.0.4 lib/veritas/optimizer/function/predicate/greater_than_or_equal_to.rb