Repository navigation
Closed
Description
Simulating above the root, as implemented in #2396, causes infinite waiting time for smc modules when:
- There is no recombination or gene conversion
- for the smc_k model: sometimes it still wont work unless the hull_offset is set to a positive value (even a very small one)
- for example:
sample size =10, sequence_length=10, and recombination_rate=0.001,works with0hull offsetsample size =10, sequence_length=10, and recombination_rate>0.001,requires a+vehull offset (even a very small fraction)
- for example:
Error log:
---------------------------------------------------------------------------
LibraryError Traceback (most recent call last)
Cell In[60], line 1
----> 1 ts = msprime.sim_ancestry(
2 10,
3 #population_size=10,
4 stop_at_local_mrca=False,
5 end_time=1000,
6 random_seed=1,
7 sequence_length=10,
8 recombination_rate=0.01,
9 model=msprime.SmcKApproxCoalescent()
10 #model=msprime.SmcApproxCoalescent()
11 #model=msprime.BetaCoalescent(alpha=1.2)
12 #model='dtwf'
13 )
14 ts.draw_svg(y_axis=True)
File ~/Documents/msprime/msprime/ancestry.py:1332, in sim_ancestry(samples, demography, sequence_length, discrete_genome, recombination_rate, gene_conversion_rate, gene_conversion_tract_length, population_size, ploidy, model, initial_state, start_time, end_time, record_migrations, record_full_arg, additional_nodes, coalescing_segments_only, num_labels, random_seed, num_replicates, replicate_index, record_provenance, stop_at_local_mrca)
1309 provenance_dict = provenance.get_provenance_dict(parameters)
1310 sim = _parse_sim_ancestry(
1311 samples=samples,
1312 sequence_length=sequence_length,
(...) 1330 stop_at_local_mrca=stop_at_local_mrca,
1331 )
-> 1332 return _wrap_replicates(
1333 sim,
1334 num_replicates=num_replicates,
1335 replicate_index=replicate_index,
1336 provenance_dict=provenance_dict,
1337 )
File ~/Documents/msprime/msprime/ancestry.py:681, in _wrap_replicates(simulator, num_replicates, replicate_index, provenance_dict, mutation_rate)
675 iterator = simulator.run_replicates(
676 num_replicates,
677 mutation_rate=mutation_rate,
678 provenance_dict=provenance_dict,
679 )
680 if replicate_index is not None:
--> 681 deque = collections.deque(iterator, maxlen=1)
682 return deque.pop()
683 else:
File ~/Documents/msprime/msprime/ancestry.py:1629, in Simulator.run_replicates(self, num_replicates, mutation_rate, provenance_dict)
1627 for replicate_index in range(num_replicates):
1628 logger.info("Starting replicate %d", replicate_index)
-> 1629 self.run()
1630 if mutation_rate is not None:
1631 # This is only called from simulate() or the ms interface,
1632 # so does not need any further parameters.
1633 mutations._simple_mutate(
1634 tables=self.tables,
1635 random_generator=self.random_generator,
1636 sequence_length=self.sequence_length,
1637 rate=mutation_rate,
1638 )
File ~/Documents/msprime/msprime/ancestry.py:1594, in Simulator.run(self, event_chunk, debug_func)
1592 raise ValueError("Model durations must be >= 0")
1593 end_time = min(self.time + model_duration, self.end_time)
-> 1594 exit_reason = self._run_until(end_time, event_chunk, debug_func)
1595 if exit_reason == ExitReason.COALESCENCE or self.time == self.end_time:
1596 logger.debug("Skipping remaining %d models", len(self.models) - j - 1)
File ~/Documents/msprime/msprime/ancestry.py:1559, in Simulator._run_until(self, end_time, event_chunk, debug_func)
1557 ret = ExitReason.MAX_EVENTS
1558 while ret == ExitReason.MAX_EVENTS:
-> 1559 ret = ExitReason(super().run(end_time, event_chunk))
1560 if self.time > end_time:
1561 # Currently the Pedigree and Sweeps models are "non-reentrant"
1562 # We can change this to an assertion once these have been fixed.
1563 raise RuntimeError(
1564 f"Model {self.model['name']} does not support interruption. "
1565 "Please open an issue on GitHub"
1566 )
LibraryError: Infinite waiting time until next simulation event.
Activity
jeromekelleher commentedon Sep 2, 2025
Ah, so we're returning this specific error reliably or the simulation just keeps going forever?
jeromekelleher commentedon Dec 3, 2025
Can you verify this is fixed in #2396 once it's merged please @hossam26644 ?
jeromekelleher commentedon Jan 23, 2026
Can you update here please @hossam26644 ?
hossam26644 commentedon Jan 26, 2026
Fixed. I will close this issue.