Sha256: 54d947aa143efc6733bce67ef691fa72a97f71f9bf5396b806b5bec7d7236c5a

Contents?: true

Size: 1.32 KB

Versions: 3

Compression:

Stored size: 1.32 KB

Contents

# Author::    Nicolas Pouillard  <ertai@lrde.epita.fr>.
# Copyright:: Copyright (c) 2004, 2005 Uttk team. All rights reserved.
# License::   LGPL
# $Id: /w/fey/uttk/trunk/lib/uttk/strategies/ProbabilityThreshold.rb 22102 2006-02-21T23:03:39.538964Z pouillar  $


module Uttk

  module Strategies

    # I validate the status of the strategy _test_ if it is under the value of
    # my _threshold_ attribute.
    class ProbabilityThreshold < Proxy
      include Concrete

      def prologue
        super
        if @threshold > 1
          raise ArgumentError, "Threshold too high: #@threshold not in [0..1]"
        elsif @threshold < 0
          raise ArgumentError, "Threshold too low: #@threshold not in [0..1]"
        end
        create(@test)
      end
      protected :prologue


      def assertion
        compute_final_weight
        final = @final_weight.get
        @log.final_weight = final
        fail("Not enough (#{final} < #@threshold)") if @final_weight < @threshold
        pass
      end
      protected :assertion


      attribute :test,      'the strategy',              :mandatory, :invisble
      attribute :threshold, 'the probability threshold', :mandatory, nil
                                                         Weights::Weight

    end # class ProbabilityThreshold

  end # module Strategies

end # module Uttk

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
uttk-0.3.5.0 lib/uttk/strategies/ProbabilityThreshold.rb
uttk-0.3.6.1 lib/uttk/strategies/ProbabilityThreshold.rb
uttk-0.3.1.2 lib/uttk/strategies/ProbabilityThreshold.rb