Skip to content

Commit 3a8625f

Browse files
authored
Merge pull request #44 from junniest/master
Changed post-sim rejection count to any rejection.
2 parents ce5e12f + 4ef2cee commit 3a8625f

File tree

7 files changed

+55
-40
lines changed

7 files changed

+55
-40
lines changed

src/master/BeastTreeFromMaster.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,9 @@ public class BeastTreeFromMaster extends Tree implements StateNodeInitialiser {
9595
"A post-simulation condition.",
9696
new ArrayList<>());
9797

98-
public Input<Integer> maxPostSimConditionRejectsInput =
99-
new Input<>("maxPostSimConditionRejects",
100-
"Maximum number of post simulation condition failures" +
98+
public Input<Integer> maxConditionRejectsInput =
99+
new Input<>("maxConditionRejects",
100+
"Maximum number of condition failures" +
101101
"before aborting. (Default is no limit.)");
102102

103103
public Input<Boolean> samplePopulationSizesInput = new Input<>(
@@ -187,7 +187,7 @@ public void initAndValidate() {
187187
for (PostSimCondition postSimCondition : postSimConditionsInput.get())
188188
itraj.setInputValue("postSimCondition", postSimCondition);
189189

190-
itraj.setInputValue("maxPostSimConditionRejects", maxPostSimConditionRejectsInput.get());
190+
itraj.setInputValue("maxConditionRejects", maxConditionRejectsInput.get());
191191

192192
for (InheritanceTrajectoryOutput output : outputsInput.get())
193193
itraj.setInputValue("output", output);

src/master/Ensemble.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,9 @@ public class Ensemble extends Runnable {
9494
"A post-simulation condition.",
9595
new ArrayList<>());
9696

97-
public Input<Integer> maxPostSimConditionRejectsInput =
98-
new Input<>("maxPostSimConditionRejects",
99-
"Maximum number of post simulation condition failures" +
97+
public Input<Integer> maxConditionRejectsInput =
98+
new Input<>("maxConditionRejects",
99+
"Maximum number of condition failures" +
100100
"before aborting. (Default is no limit.)");
101101

102102
// Outputs to write:
@@ -158,8 +158,8 @@ public void initAndValidate() {
158158
for (PostSimCondition condition : postSimConditionsInput.get())
159159
spec.addPostSimCondition(condition);
160160

161-
if (maxPostSimConditionRejectsInput.get() != null)
162-
spec.setMaxPostSimConditionRejects(maxPostSimConditionRejectsInput.get());
161+
if (maxConditionRejectsInput.get() != null)
162+
spec.setMaxConditionRejects(maxConditionRejectsInput.get());
163163

164164
// Set seed if provided, otherwise use default BEAST seed:
165165
if (seedInput.get()!=null)

src/master/EnsembleSummary.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ public class EnsembleSummary extends Runnable {
8787
"A post-simulation condition.",
8888
new ArrayList<>());
8989

90-
public Input<Integer> maxPostSimConditionRejectsInput =
91-
new Input<>("maxPostSimConditionRejects",
90+
public Input<Integer> maxConditionRejectsInput =
91+
new Input<>("maxConditionRejects",
9292
"Maximum number of post simulation condition failures" +
9393
"before aborting. (Default is no limit.)");
9494
// Individual moments:
@@ -156,8 +156,8 @@ public void initAndValidate() {
156156
for (PostSimCondition condition : postSimConditionsInput.get())
157157
spec.addPostSimCondition(condition);
158158

159-
if (maxPostSimConditionRejectsInput.get() != null)
160-
spec.setMaxPostSimConditionRejects(maxPostSimConditionRejectsInput.get());
159+
if (maxConditionRejectsInput.get() != null)
160+
spec.setMaxConditionRejects(maxConditionRejectsInput.get());
161161

162162
// Check for zero-length moment and moment group lists (no point to calculation!)
163163
if (momentGroupsInput.get().isEmpty() && momentsInput.get().isEmpty())

src/master/InheritanceEnsemble.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ public class InheritanceEnsemble extends Runnable {
115115
"A post-simulation condition.",
116116
new ArrayList<>());
117117

118-
public Input<Integer> maxPostSimConditionRejectsInput =
119-
new Input<>("maxPostSimConditionRejects",
118+
public Input<Integer> maxConditionRejectsInput =
119+
new Input<>("maxConditionRejects",
120120
"Maximum number of post simulation condition failures" +
121121
"before aborting. (Default is no limit.)");
122122

@@ -196,8 +196,8 @@ public void initAndValidate() {
196196
for (PostSimCondition condition : postSimConditionsInput.get())
197197
spec.addPostSimCondition(condition);
198198

199-
if (maxPostSimConditionRejectsInput.get() != null)
200-
spec.setMaxPostSimConditionRejects(maxPostSimConditionRejectsInput.get());
199+
if (maxConditionRejectsInput.get() != null)
200+
spec.setMaxConditionRejects(maxConditionRejectsInput.get());
201201

202202
// Set seed if provided, otherwise use default BEAST seed:
203203
if (seedInput.get()!=null)

src/master/InheritanceTrajectory.java

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,8 @@ public void initAndValidate() {
170170
for (PostSimCondition condition : postSimConditionsInput.get())
171171
spec.addPostSimCondition(condition);
172172

173-
if (maxPostSimConditionRejectsInput.get() != null)
174-
spec.setMaxPostSimConditionRejects(maxPostSimConditionRejectsInput.get());
173+
if (maxConditionRejectsInput.get() != null)
174+
spec.setMaxConditionRejects(maxConditionRejectsInput.get());
175175

176176
// Set seed if provided, otherwise use default BEAST seed:
177177
if (seedInput.get()!=null)
@@ -191,7 +191,7 @@ public void run() {
191191
try {
192192
simulate();
193193
} catch (RejectCountExceeded ex) {
194-
System.err.println("Maximum number of post-simulation condition " +
194+
System.err.println("Maximum number of condition " +
195195
"rejections exceeded. Aborting.");
196196
System.exit(1);
197197
}
@@ -236,7 +236,7 @@ private void simulate() throws RejectCountExceeded {
236236
sampleDt = spec.getSampleDt();
237237

238238
boolean postSimReject;
239-
int postSimRejectCount = 0;
239+
int rejectCount = 0;
240240
do { // Perform simulations until no post-simulation rejection occurs
241241

242242
initialiseSimulation();
@@ -288,7 +288,14 @@ private void simulate() throws RejectCountExceeded {
288288
// Rejection: Abort and start a new simulation
289289
if (spec.getVerbosity()>0)
290290
System.err.println("Rejection end condition met "
291-
+ "at time " + t);
291+
+ "at time " + t);
292+
rejectCount += 1;
293+
294+
if (spec.getMaxConditionRejects()>=0 &&
295+
rejectCount > spec.getMaxConditionRejects()) {
296+
throw new RejectCountExceeded();
297+
}
298+
292299
initialiseSimulation();
293300
continue;
294301
} else {
@@ -448,10 +455,10 @@ private void simulate() throws RejectCountExceeded {
448455
if (spec.getVerbosity()>0)
449456
System.err.println("Post-simulation rejection condition met.");
450457

451-
postSimRejectCount += 1;
458+
rejectCount += 1;
452459

453-
if (spec.getMaxPostSimConditionRejects()>=0 &&
454-
postSimRejectCount > spec.getMaxPostSimConditionRejects()) {
460+
if (spec.getMaxConditionRejects()>=0 &&
461+
rejectCount > spec.getMaxConditionRejects()) {
455462
throw new RejectCountExceeded();
456463
}
457464

src/master/Trajectory.java

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ public class Trajectory extends Runnable {
9191
"A post-simulation condition.",
9292
new ArrayList<>());
9393

94-
public Input<Integer> maxPostSimConditionRejectsInput =
95-
new Input<>("maxPostSimConditionRejects",
94+
public Input<Integer> maxConditionRejectsInput =
95+
new Input<>("maxConditionRejects",
9696
"Maximum number of post simulation condition failures" +
9797
"before aborting. (Default is no limit.)");
9898

@@ -167,8 +167,8 @@ public void initAndValidate() {
167167
for (PostSimCondition condition : postSimConditionsInput.get())
168168
spec.addPostSimCondition(condition);
169169

170-
if (maxPostSimConditionRejectsInput.get() != null)
171-
spec.setMaxPostSimConditionRejects(maxPostSimConditionRejectsInput.get());
170+
if (maxConditionRejectsInput.get() != null)
171+
spec.setMaxConditionRejects(maxConditionRejectsInput.get());
172172

173173
// Set seed if provided, otherwise use default BEAST seed:
174174
if (seedInput.get()!=null)
@@ -188,7 +188,7 @@ public void run() {
188188
try {
189189
simulate();
190190
} catch (RejectCountExceeded ex) {
191-
System.err.println("Maximum number of post-simulation condition " +
191+
System.err.println("Maximum number of condition " +
192192
"rejections exceeded. Aborting.");
193193
System.exit(1);
194194
}
@@ -233,7 +233,7 @@ private void simulate() throws RejectCountExceeded {
233233

234234
// Loop until any post-simulation rejection conditions fail.
235235
boolean postSimulationReject;
236-
int postSimRejectCount = 0;
236+
int rejectCount = 0;
237237
do {
238238
sampledStates.clear();
239239
sampledTimes.clear();
@@ -282,7 +282,15 @@ private void simulate() throws RejectCountExceeded {
282282
if (endConditionMet.isRejection()) {
283283
if (spec.verbosity>0)
284284
System.err.println("Rejection end condition met "
285-
+ "at time " + t);
285+
+ "at time " + t);
286+
287+
rejectCount += 1;
288+
289+
if (spec.getMaxConditionRejects()>=0 &&
290+
rejectCount > spec.getMaxConditionRejects()) {
291+
throw new RejectCountExceeded();
292+
}
293+
286294
currentState = new PopulationState(spec.initPopulationState);
287295
clearSamples();
288296
sampleState(currentState, 0.0);
@@ -365,10 +373,10 @@ private void simulate() throws RejectCountExceeded {
365373
if (spec.getVerbosity()>0)
366374
System.err.println("Post-simulation rejection condition met.");
367375

368-
postSimRejectCount += 1;
376+
rejectCount += 1;
369377

370-
if (spec.getMaxPostSimConditionRejects()>=0 &&
371-
postSimRejectCount > spec.getMaxPostSimConditionRejects()) {
378+
if (spec.getMaxConditionRejects()>=0 &&
379+
rejectCount > spec.getMaxConditionRejects()) {
372380
throw new RejectCountExceeded();
373381
}
374382
}

src/master/TrajectorySpec.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public class TrajectorySpec {
6666
// Leaf count post-simulation conditions:
6767
List<PostSimCondition> postSimConditions;
6868

69-
int maxPostSimConditionRejects = -1;
69+
int maxConditionRejects = -1;
7070

7171

7272
// Whether to collect evenly spaced samples or let the state stepper
@@ -201,17 +201,17 @@ public void addPostSimCondition(PostSimCondition condition) {
201201
*
202202
* @param n limit to set
203203
*/
204-
public void setMaxPostSimConditionRejects(int n) {
205-
maxPostSimConditionRejects = n;
204+
public void setMaxConditionRejects(int n) {
205+
maxConditionRejects = n;
206206
}
207207

208208
/**
209209
* Retrieve maximum number of post-sim condition rejects allowed before
210210
* aborting. A value of -1 implies no limit.
211211
*
212212
*/
213-
public int getMaxPostSimConditionRejects() {
214-
return maxPostSimConditionRejects;
213+
public int getMaxConditionRejects() {
214+
return maxConditionRejects;
215215
}
216216

217217
/**

0 commit comments

Comments
 (0)