openModeller  Version 1.4.0
rules_negrange.cpp
Go to the documentation of this file.
00001 
00036 #include <openmodeller/Random.hh>
00037 #include <math.h>
00038 #include <string.h>
00039 
00040 #include <openmodeller/Log.hh>
00041 
00042 #include "rules_negrange.hh"
00043 
00044 
00045 // ==========================================================================
00046 //  NegatedRangeRule implelentation
00047 // ==========================================================================
00048 NegatedRangeRule::NegatedRangeRule() : 
00049   RangeRule() 
00050 {}
00051 
00052 NegatedRangeRule::NegatedRangeRule(int numGenes) : 
00053   RangeRule(numGenes) 
00054 { }
00055 
00056 NegatedRangeRule::NegatedRangeRule(Scalar prediction, int numGenes, 
00057                             const Sample& chrom1, const Sample& chrom2, 
00058                             const double * performances) : 
00059   RangeRule(prediction, numGenes, chrom1, chrom2, performances) 
00060 {}
00061 
00062 // ==========================================================================
00063 NegatedRangeRule::~NegatedRangeRule() {} 
00064 
00065 // ==========================================================================
00066 bool NegatedRangeRule::applies(const Sample& sample) const
00067 {
00068   int i;
00069   
00070   // visit each of the genes
00071   for (i = 0; i < _numGenes; i++)
00072     {
00073       if (!(equalEps(_chrom1[i], -1.0) && equalEps(_chrom2[i], +1.0)))
00074         if (!between(sample[i], _chrom1[i], _chrom2[i]))
00075     return true;
00076     }
00077   
00078   return false;
00079 }
00080 
00081 // ==========================================================================
00082 int NegatedRangeRule::getStrength(const Sample& sample) const
00083 {
00084   int strength, neg_strength;
00085   
00086   strength     = RangeRule::getStrength(sample);
00087   neg_strength = 1 - strength;
00088   
00089   return neg_strength;
00090 }
00091 
00092 // ==========================================================================
00093 void NegatedRangeRule::log()
00094 {
00095   Log::instance()->info( "Negated: " );
00096   GarpRule::log();
00097 }
00098 
00099 // ==========================================================================