8
8
#include " Probability.h"
9
9
#include " Real.h"
10
10
#include " RealPos.h"
11
+ #include " RlBoolean.h"
11
12
#include " RlClade.h"
12
13
#include " RlString.h"
13
14
#include " RlTaxon.h"
@@ -20,8 +21,7 @@ using namespace RevLanguage;
20
21
*
21
22
* The default constructor does nothing except allocating the object.
22
23
*/
23
- Dist_ConstrainedTopology::Dist_ConstrainedTopology () : TypedDistribution<TimeTree>()
24
- {
24
+ Dist_ConstrainedTopology::Dist_ConstrainedTopology () : TypedDistribution<TimeTree>() {
25
25
26
26
}
27
27
@@ -32,8 +32,8 @@ Dist_ConstrainedTopology::Dist_ConstrainedTopology() : TypedDistribution<TimeTre
32
32
*
33
33
* \return A new copy of the process.
34
34
*/
35
- Dist_ConstrainedTopology* Dist_ConstrainedTopology::clone ( void ) const
36
- {
35
+ Dist_ConstrainedTopology* Dist_ConstrainedTopology::clone ( void ) const {
36
+
37
37
return new Dist_ConstrainedTopology (*this );
38
38
}
39
39
@@ -48,19 +48,27 @@ Dist_ConstrainedTopology* Dist_ConstrainedTopology::clone( void ) const
48
48
*
49
49
* \return A new internal distribution object.
50
50
*/
51
- RevBayesCore::TopologyConstrainedTreeDistribution* Dist_ConstrainedTopology::createDistribution ( void ) const
52
- {
51
+ RevBayesCore::TopologyConstrainedTreeDistribution* Dist_ConstrainedTopology::createDistribution ( void ) const {
53
52
53
+ std::cout << " baseDistribution=" << baseDistribution << std::endl;
54
+ std::cout << " constraints=" << constraints << std::endl;
55
+ std::cout << " backbone=" << backbone << std::endl;
56
+ std::cout << " invertConstraint=" << invertConstraint << std::endl;
57
+
54
58
// get the parameters
55
- const RevBayesCore::RbVector<RevBayesCore::Clade>& c = static_cast <const ModelVector<Clade> &>( constraints->getRevObject () ).getValue ();
56
- const Distribution& rlDistribution = static_cast <const Distribution &>( baseDistribution->getRevObject () );
57
- RevBayesCore::TypedDistribution<RevBayesCore::Tree>* base = static_cast <RevBayesCore::TypedDistribution<RevBayesCore::Tree>* >( rlDistribution.createDistribution () );
58
- RevBayesCore::TypedDagNode<RevBayesCore::Tree>* bb = NULL ;
59
+ const RevBayesCore::RbVector<RevBayesCore::Clade>& c = static_cast <const ModelVector<Clade> &>( constraints->getRevObject () ).getValue ();
60
+ const Distribution& rlDistribution = static_cast <const Distribution &>( baseDistribution->getRevObject () );
61
+ RevBayesCore::TypedDistribution<RevBayesCore::Tree>* base = static_cast <RevBayesCore::TypedDistribution<RevBayesCore::Tree>* >( rlDistribution.createDistribution () );
62
+ RevBayesCore::TypedDagNode<RevBayesCore::Tree>* bb = NULL ;
59
63
if ( backbone != NULL && backbone->getRevObject () != RevNullObject::getInstance () )
60
- {
64
+ {
61
65
bb = static_cast <const TimeTree &>( backbone->getRevObject () ).getDagNode ();
62
- }
66
+ }
63
67
68
+ // SEBASTIAN: Uncomment tne next two lines to see the problem. Because invertConstraint is NULL, we have a problem. Unfortunately, I don't understand
69
+ // why invertConstraint is NULL.
70
+ // const bool inv = static_cast<const RlBoolean &>( invertConstraint->getRevObject() ).getValue();
71
+ // std::cout << "inverse=" << inv << std::endl;
64
72
65
73
// create the internal distribution object
66
74
RevBayesCore::TopologyConstrainedTreeDistribution* d = new RevBayesCore::TopologyConstrainedTreeDistribution (base, c, bb);
@@ -74,11 +82,9 @@ RevBayesCore::TopologyConstrainedTreeDistribution* Dist_ConstrainedTopology::cre
74
82
*
75
83
* \return The class' name.
76
84
*/
77
- const std::string& Dist_ConstrainedTopology::getClassType ( void )
78
- {
85
+ const std::string& Dist_ConstrainedTopology::getClassType ( void ) {
79
86
80
87
static std::string rev_type = " Dist_ConstrainedTopology" ;
81
-
82
88
return rev_type;
83
89
}
84
90
@@ -88,11 +94,9 @@ const std::string& Dist_ConstrainedTopology::getClassType( void )
88
94
*
89
95
* \return TypeSpec of this class.
90
96
*/
91
- const TypeSpec& Dist_ConstrainedTopology::getClassTypeSpec ( void )
92
- {
97
+ const TypeSpec& Dist_ConstrainedTopology::getClassTypeSpec ( void ) {
93
98
94
99
static TypeSpec rev_type_spec = TypeSpec ( getClassType (), new TypeSpec ( TypedDistribution<TimeTree>::getClassTypeSpec () ) );
95
-
96
100
return rev_type_spec;
97
101
}
98
102
@@ -102,11 +106,10 @@ const TypeSpec& Dist_ConstrainedTopology::getClassTypeSpec( void )
102
106
*
103
107
* \return Rev aliases of constructor function.
104
108
*/
105
- std::vector<std::string> Dist_ConstrainedTopology::getDistributionFunctionAliases ( void ) const
106
- {
109
+ std::vector<std::string> Dist_ConstrainedTopology::getDistributionFunctionAliases ( void ) const {
110
+
107
111
// create alternative constructor function names variable that is the same for all instance of this class
108
112
std::vector<std::string> a_names;
109
-
110
113
return a_names;
111
114
}
112
115
@@ -118,11 +121,10 @@ std::vector<std::string> Dist_ConstrainedTopology::getDistributionFunctionAliase
118
121
*
119
122
* \return Rev name of constructor function.
120
123
*/
121
- std::string Dist_ConstrainedTopology::getDistributionFunctionName ( void ) const
122
- {
124
+ std::string Dist_ConstrainedTopology::getDistributionFunctionName ( void ) const {
125
+
123
126
// create a distribution name variable that is the same for all instance of this class
124
127
std::string d_name = " ConstrainedTopology" ;
125
-
126
128
return d_name;
127
129
}
128
130
@@ -137,26 +139,18 @@ std::string Dist_ConstrainedTopology::getDistributionFunctionName( void ) const
137
139
*
138
140
* \return The member rules.
139
141
*/
140
- const MemberRules& Dist_ConstrainedTopology::getParameterRules (void ) const
141
- {
142
+ const MemberRules& Dist_ConstrainedTopology::getParameterRules (void ) const {
142
143
143
144
static MemberRules memberRules;
144
145
static bool rules_set = false ;
145
-
146
146
if ( !rules_set )
147
- {
148
-
147
+ {
149
148
memberRules.push_back ( new ArgumentRule ( " treeDistribution" , TypedDistribution<TimeTree>::getClassTypeSpec (), " The base distribution for the tree." , ArgumentRule::BY_VALUE, ArgumentRule::ANY ) );
150
- memberRules.push_back ( new ArgumentRule ( " constraints" , ModelVector<Clade>::getClassTypeSpec (), " The topological constraints." , ArgumentRule::BY_VALUE, ArgumentRule::ANY, new ModelVector<Clade>() ) );
151
-
152
- // RevBayesCore::Tree* backbonePtr = NULL;
153
- // AbstractModelObject* nullPtr;
154
- // memberRules.push_back( new ArgumentRule( "backbone", TimeTree::getClassTypeSpec(), "The backbone topology.", ArgumentRule::BY_VALUE, ArgumentRule::ANY, new TimeTree(nullPtr) ) );
155
- memberRules.push_back ( new ArgumentRule ( " backbone" , TimeTree::getClassTypeSpec (), " The backbone topology." , ArgumentRule::BY_VALUE, ArgumentRule::ANY, NULL ) );
156
-
149
+ memberRules.push_back ( new ArgumentRule ( " constraints" , ModelVector<Clade>::getClassTypeSpec (), " The topological constraints." , ArgumentRule::BY_VALUE, ArgumentRule::ANY, new ModelVector<Clade>() ) );
150
+ memberRules.push_back ( new ArgumentRule ( " backbone" , TimeTree::getClassTypeSpec (), " The backbone topology." , ArgumentRule::BY_VALUE, ArgumentRule::ANY, NULL ) );
151
+ memberRules.push_back ( new ArgumentRule ( " inverse" , RlBoolean::getClassTypeSpec (), " Should the constraint be inverted?" , ArgumentRule::BY_VALUE, ArgumentRule::ANY, new RlBoolean ( false ) ) );
157
152
rules_set = true ;
158
- }
159
-
153
+ }
160
154
return memberRules;
161
155
}
162
156
@@ -166,11 +160,9 @@ const MemberRules& Dist_ConstrainedTopology::getParameterRules(void) const
166
160
*
167
161
* \return The type spec of this object.
168
162
*/
169
- const TypeSpec& Dist_ConstrainedTopology::getTypeSpec ( void ) const
170
- {
163
+ const TypeSpec& Dist_ConstrainedTopology::getTypeSpec ( void ) const {
171
164
172
165
static TypeSpec ts = getClassTypeSpec ();
173
-
174
166
return ts;
175
167
}
176
168
@@ -185,24 +177,26 @@ const TypeSpec& Dist_ConstrainedTopology::getTypeSpec( void ) const
185
177
* \param[in] name Name of the member variable.
186
178
* \param[in] var Pointer to the variable.
187
179
*/
188
- void Dist_ConstrainedTopology::setConstParameter (const std::string& name, const RevPtr<const RevVariable> &var)
189
- {
180
+ void Dist_ConstrainedTopology::setConstParameter (const std::string& name, const RevPtr<const RevVariable>& var) {
190
181
191
182
if ( name == " constraints" )
192
- {
183
+ {
193
184
constraints = var;
194
- }
185
+ }
195
186
else if ( name == " treeDistribution" )
196
- {
187
+ {
197
188
baseDistribution = var;
198
- }
189
+ }
199
190
else if ( name == " backbone" )
200
- {
191
+ {
192
+ backbone = var;
193
+ }
194
+ else if ( name == " inverse" )
195
+ {
201
196
backbone = var;
202
- }
197
+ }
203
198
else
204
- {
199
+ {
205
200
TypedDistribution<TimeTree>::setConstParameter (name, var);
206
- }
207
-
201
+ }
208
202
}
0 commit comments