Sha256: 1ec1bb5c1d7d9f77f96b09efc8ae64003798eb7ca28da8d48615d5cbc6b4d6c5

Contents?: true

Size: 1.52 KB

Versions: 3

Compression:

Stored size: 1.52 KB

Contents

# encoding: utf-8

module Axiom
  class Optimizer
    module Function
      class Predicate

        # Abstract base class representing LessThanOrEqualTo optimizations
        class LessThanOrEqualTo < 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 || GreaterThan::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?
              LessThan::Tautology.new(operation).optimizable? ||
              Equality::Tautology.new(operation).optimizable?
            end

          end # class Tautology

          Axiom::Function::Predicate::LessThanOrEqualTo.optimizer = chain(
            ConstantOperands,
            Contradiction,
            Tautology,
            NormalizableOperands,
            UnoptimizedOperands
          )

        end # class LessThanOrEqualTo
      end # class Predicate
    end # module Function
  end # class Optimizer
end # module Axiom

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
axiom-optimizer-0.2.0 lib/axiom/optimizer/function/predicate/less_than_or_equal_to.rb
axiom-optimizer-0.1.1 lib/axiom/optimizer/function/predicate/less_than_or_equal_to.rb
axiom-optimizer-0.1.0 lib/axiom/optimizer/function/predicate/less_than_or_equal_to.rb