openModeller
Version 1.4.0
|
00001 /* ************************************** 00002 * GARP Modeling Package 00003 * 00004 * ************************************** 00005 * 00006 * Copyright (c), The Center for Research, University of Kansas, 2385 Irving Hill Road, Lawrence, KS 66044-4755, USA. 00007 * Copyright (C), David R.B. Stockwell of Symbiotik Pty. Ltd. 00008 * 00009 * This program is free software; you can redistribute it and/or modify 00010 * it under the terms of the license that is distributed with the software. 00011 * 00012 * This program is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * license.txt file included with this software for more details. 00016 */ 00017 00018 // RuleSet.h : Declaration of the CRuleSet 00019 00020 #ifndef __RULESET_H_ 00021 #define __RULESET_H_ 00022 00023 #include "Utilities.h" 00024 #include "Rule.h" 00025 00026 #include <openmodeller/om.hh> 00027 00028 class EnvCell; 00029 class EnvCellSet; 00030 class Rule; 00031 00032 // ======================================================================== 00033 // RuleSet 00034 // ======================================================================== 00035 class RuleSet 00036 { 00037 // friend classes 00038 friend class GarpAlgorithm; 00039 00040 private: 00041 Rule * objRules[MAX_RULES]; 00042 int intRules; 00043 00044 int _dim; 00045 00046 // temp data structures to hold verify results 00047 int iConfMatrix[2][2]; 00048 int iTotalPoints; 00049 00050 // counter for the number of cells 00051 int iTotalArea; // total cells not masked 00052 int iPresenceArea; // total cells predicted present 00053 int iAbsenceArea; // total cells predicted absent 00054 int iNonPredictedArea; // total cells non-predicted 00055 00056 void resetConfMatrix(EnvCellSet * objTestDataset); 00057 void addConfMatrix(int iPredictedValue, int iActualValue); 00058 00059 public: 00060 RuleSet(); 00061 virtual ~RuleSet(); 00062 00063 void log(); 00064 00065 void setDimension(int dim) { _dim = dim; } 00066 00067 void loadText(char * strFilename); 00068 void saveText(char * strFilename); 00069 00070 char * toXML(char * id); 00071 00072 // verify related methods 00073 void verify(EnvCellSet * objTestDataset, double dAccLimit); 00074 int getConfMatrix(int iPredictedValue, int iActualValue); 00075 int getTotalPoints(); 00076 int getPredictedPoints(); 00077 int getUnpredictedPoints(); 00078 double getAccuracy(); 00079 double getOverallAccuracy(); 00080 00081 void setActiveGenes(bool * bGeneIsActivePtr, int * iGeneIndexPtr, int iActiveGenesAux); 00082 00083 //void predict(EnvLayer * objPredictionLayer, EnvLayerSet * objPredictionArea, double Accuracylimit); 00084 //void predictRuleCoverage(EnvLayer * objPredictionLayer, EnvLayerSet * objPredictionArea, double Accuracylimit); 00085 int applyRulesToCell(EnvCell * cell, double Accuracylimit) const; 00086 00087 //bool projectRuleSet(EnvLayerSet * oToLayerSet, bool bConservative, RuleSet * oToRuleSet); 00088 00089 void updateRuleUsage(); 00090 00091 int size(); 00092 void add(Rule * objRule); 00093 void set(int index, Rule * objRule); 00094 Rule * get(int index); 00095 00096 Scalar getValue(const Sample& sample) const; 00097 00098 void clear(); 00099 void sort(int intPerfIndex); 00100 void trim(int intMaxRules); 00101 void discardRules(int iPerfIndex, double dValue); 00102 00103 void setEvaluation(bool value); 00104 void setPad(char pad); 00105 int countPad(char pad); 00106 00107 double getOveralPerformance(int iPerfIndex, int iFirstRulesToBeIncluded); 00108 00109 void gatherRuleSetStats(int gen); 00110 00111 }; 00112 00113 // ======================================================================== 00114 00115 #endif //__RULESET_H_