openModeller  Version 1.5.0
RuleSet.h
Go to the documentation of this file.
1 /* **************************************
2  * GARP Modeling Package
3  *
4  * **************************************
5  *
6  * Copyright (c), The Center for Research, University of Kansas, 2385 Irving Hill Road, Lawrence, KS 66044-4755, USA.
7  * Copyright (C), David R.B. Stockwell of Symbiotik Pty. Ltd.
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the license that is distributed with the software.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * license.txt file included with this software for more details.
16  */
17 
18 // RuleSet.h : Declaration of the CRuleSet
19 
20 #ifndef __RULESET_H_
21 #define __RULESET_H_
22 
23 #include "Utilities.h"
24 #include "Rule.h"
25 
26 #include <openmodeller/om.hh>
27 
28 class EnvCell;
29 class EnvCellSet;
30 class Rule;
31 
32 // ========================================================================
33 // RuleSet
34 // ========================================================================
35 class RuleSet
36 {
37  // friend classes
38  friend class GarpAlgorithm;
39 
40 private:
42  int intRules;
43 
44  int _dim;
45 
46  // temp data structures to hold verify results
47  int iConfMatrix[2][2];
49 
50  // counter for the number of cells
51  int iTotalArea; // total cells not masked
52  int iPresenceArea; // total cells predicted present
53  int iAbsenceArea; // total cells predicted absent
54  int iNonPredictedArea; // total cells non-predicted
55 
56  void resetConfMatrix(EnvCellSet * objTestDataset);
57  void addConfMatrix(int iPredictedValue, int iActualValue);
58 
59 public:
60  RuleSet();
61  virtual ~RuleSet();
62 
63  void log();
64 
65  void setDimension(int dim) { _dim = dim; }
66 
67  void loadText(char * strFilename);
68  void saveText(char * strFilename);
69 
70  char * toXML(char * id);
71 
72  // verify related methods
73  void verify(EnvCellSet * objTestDataset, double dAccLimit);
74  int getConfMatrix(int iPredictedValue, int iActualValue);
75  int getTotalPoints();
76  int getPredictedPoints();
78  double getAccuracy();
79  double getOverallAccuracy();
80 
81  void setActiveGenes(bool * bGeneIsActivePtr, int * iGeneIndexPtr, int iActiveGenesAux);
82 
83  //void predict(EnvLayer * objPredictionLayer, EnvLayerSet * objPredictionArea, double Accuracylimit);
84  //void predictRuleCoverage(EnvLayer * objPredictionLayer, EnvLayerSet * objPredictionArea, double Accuracylimit);
85  int applyRulesToCell(EnvCell * cell, double Accuracylimit) const;
86 
87  //bool projectRuleSet(EnvLayerSet * oToLayerSet, bool bConservative, RuleSet * oToRuleSet);
88 
89  void updateRuleUsage();
90 
91  int size();
92  void add(Rule * objRule);
93  void set(int index, Rule * objRule);
94  Rule * get(int index);
95 
96  Scalar getValue(const Sample& sample) const;
97 
98  void clear();
99  void sort(int intPerfIndex);
100  void trim(int intMaxRules);
101  void discardRules(int iPerfIndex, double dValue);
102 
103  void setEvaluation(bool value);
104  void setPad(char pad);
105  int countPad(char pad);
106 
107  double getOveralPerformance(int iPerfIndex, int iFirstRulesToBeIncluded);
108 
109  void gatherRuleSetStats(int gen);
110 
111 };
112 
113 // ========================================================================
114 
115 #endif //__RULESET_H_
int countPad(char pad)
Definition: RuleSet.cpp:245
void log()
Definition: RuleSet.cpp:439
void sort(int intPerfIndex)
Definition: RuleSet.cpp:257
char * toXML(char *id)
Definition: RuleSet.cpp:83
int iTotalPoints
Definition: RuleSet.h:48
double Scalar
Type of map values.
Definition: om_defs.hh:39
int size()
Definition: RuleSet.cpp:157
void saveText(char *strFilename)
Definition: RuleSet.cpp:127
void setPad(char pad)
Definition: RuleSet.cpp:238
Scalar getValue(const Sample &sample) const
Definition: RuleSet.cpp:411
int iAbsenceArea
Definition: RuleSet.h:53
void verify(EnvCellSet *objTestDataset, double dAccLimit)
Definition: RuleSet.cpp:281
void setDimension(int dim)
Definition: RuleSet.h:65
void setEvaluation(bool value)
Definition: RuleSet.cpp:231
void resetConfMatrix(EnvCellSet *objTestDataset)
Definition: RuleSet.cpp:319
double getOveralPerformance(int iPerfIndex, int iFirstRulesToBeIncluded)
Definition: RuleSet.cpp:382
int iNonPredictedArea
Definition: RuleSet.h:54
int applyRulesToCell(EnvCell *cell, double Accuracylimit) const
Definition: RuleSet.cpp:622
void gatherRuleSetStats(int gen)
Definition: RuleSet.cpp:889
void setActiveGenes(bool *bGeneIsActivePtr, int *iGeneIndexPtr, int iActiveGenesAux)
Definition: RuleSet.cpp:72
int iTotalArea
Definition: RuleSet.h:51
int getPredictedPoints()
Definition: RuleSet.cpp:353
RuleSet()
Definition: RuleSet.cpp:35
const int MAX_RULES
Definition: Utilities.h:55
void addConfMatrix(int iPredictedValue, int iActualValue)
Definition: RuleSet.cpp:339
double Accuracylimit
Definition: Rule.h:37
int iConfMatrix[2][2]
Definition: RuleSet.h:47
double getOverallAccuracy()
Definition: RuleSet.cpp:370
int getConfMatrix(int iPredictedValue, int iActualValue)
Definition: RuleSet.cpp:330
int iPresenceArea
Definition: RuleSet.h:52
void clear()
Definition: RuleSet.cpp:55
void discardRules(int iPerfIndex, double dValue)
Definition: RuleSet.cpp:194
int getTotalPoints()
Definition: RuleSet.cpp:348
int intRules
Definition: RuleSet.h:42
int getUnpredictedPoints()
Definition: RuleSet.cpp:359
void loadText(char *strFilename)
Rule * objRules[MAX_RULES]
Definition: RuleSet.h:41
void add(Rule *objRule)
Definition: RuleSet.cpp:165
int _dim
Definition: RuleSet.h:44
void trim(int intMaxRules)
Definition: RuleSet.cpp:179
void updateRuleUsage()
Definition: RuleSet.cpp:376
virtual ~RuleSet()
Definition: RuleSet.cpp:49
void set(int index, Rule *objRule)
Definition: RuleSet.cpp:161
double getAccuracy()
Definition: RuleSet.cpp:365
Definition: Sample.hh:25