-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdefdemorgan.h
71 lines (55 loc) · 2.19 KB
/
defdemorgan.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#ifndef DEFDEMORGAN_H
#define DEFDEMORGAN_H
// {{SMILE_PUBLIC_HEADER}}
#include "nodedef.h"
#include "dmatrix.h"
#include "doublearray.h"
// different types of parents
#define DSL_DEMORGAN_INHIBITOR 0
#define DSL_DEMORGAN_REQUIREMENT 1
#define DSL_DEMORGAN_CAUSE 2
#define DSL_DEMORGAN_BARRIER 3
class DSL_demorgan : public DSL_nodeDefinition
{
public:
DSL_demorgan();
DSL_demorgan(int myHandle, DSL_network *theNetwork);
DSL_demorgan(DSL_nodeDefinition &likeThisOne);
virtual ~DSL_demorgan() { CleanUp(); }
int operator =(DSL_nodeDefinition &likeThisOne);
int AddParent(int theParent);
int RemoveParent(int theParent);
void CheckReadiness(int deep = 0);
int ReCreateFromNetworkStructure();
int Clone(DSL_nodeDefinition &thisGuy);
void CleanUp(int deep=0);
DSL_idArray* GetOutcomesNames();
int SetParentWeights(DSL_doubleArray& weights);
int SetParentWeight(int numParent, double value);
double GetParentWeight(int numParent);
int SetParentTypes(const DSL_intArray& types);
int SetParentType(int numParent, int value);
int GetParentType(int numParent);
double GetPriorBelief() { return prior_belief; }
int SetPriorBelief(double value);
const char *GetTypeName() const { return "DEMORGAN"; }
int GetType() const { return DSL_DEMORGAN; }
int GetSize() { return table.GetSize(); }
int GetNumberOfOutcomes() { return 2; }
int OrderOfParentsGetsChanged(DSL_intArray &newOrder);
int GetDefinition(DSL_Dmatrix **here) { *here=&table; return DSL_OKAY; }
int GetDefinition(DSL_doubleArray **here) { *here=&table.GetItems(); return DSL_OKAY; }
DSL_Dmatrix &GetProbabilities() { return table; }
DSL_intArray &GetParentTypes() { return parent_types; }
DSL_doubleArray &GetParentWeights() { return parent_weights; }
void DoCopyParameters(DSL_nodeDefinition &target) const;
private:
int ResizeTable();
void UpdateTable();
void UpdateTableColumn(int index);
DSL_Dmatrix table; // stores CPT
DSL_intArray parent_types; // stores the type of each parent
DSL_doubleArray parent_weights; // stores the weight of each parent
double prior_belief; // stores the prior belief for this node
};
#endif