# Author:: Nicolas Pouillard . # Copyright:: Copyright (c) 2004, 2005 Uttk team. All rights reserved. # License:: LGPL # $Id: /w/fey/uttk/trunk/lib/uttk/strategies/Threshold.rb 23188 2006-04-01T12:55:14.164563Z ertai $ module Uttk module Strategies # I validate the status of the strategy _test_ if it is under the value of # my _threshold_ attribute. class Threshold < 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 Threshold end # module Strategies end # module Uttk