source_code stringclasses 3
values | execution_order listlengths 6 6 | analysis_question stringclasses 3
values | understanding_answer stringclasses 3
values | control_flow_explanation stringclasses 3
values | timing_and_synchronization_explanation stringclasses 3
values |
|---|---|---|---|---|---|
from typing import Sequence
class StepScheduler:
def __init__(self, components: Sequence[object]):
self.components = components
self.time = 0.0
def run(self, stop_time: float, step: float) -> float:
if step <= 0:
raise ValueError('step must be positive')
while self... | [
"Validate that step is positive; otherwise raise ValueError before scheduling any component.",
"Calculate target as min(self.time + step, stop_time).",
"Call set_time(target) on each component in sequence.",
"Call advance() on each component in sequence, after all components have received the target time.",
... | Explain the scheduler's per-step control flow, the order in which component methods are called, and how it advances and synchronizes simulation time. | The scheduler rejects a nonpositive step, then repeatedly chooses the next target as the smaller of the current time plus the step and the stop time. For each target, it sets that time on every component, calls advance on every component, and then calls wait_until on every component. Only after all waits return does it... | run first checks the step-size guard and raises ValueError if the step is not positive. Otherwise, the while loop continues while self.time is less than stop_time. Each iteration calculates a bounded target and executes three separate loops over components: set_time, advance, and wait_until. Control returns to the loop... | Simulation time starts at 0.0. Each target advances by step unless that would pass stop_time, in which case the target is capped at stop_time. The scheduler calls wait_until(target) for every component before changing its own time and beginning the next iteration. This establishes a per-target waiting phase, though the... |
class GrantScheduler:
def __init__(self, master, components):
self.master = master
self.components = components
def run(self, stop_time: float, quantum: float) -> float:
if quantum <= 0:
raise ValueError('quantum must be positive')
now = 0.0
while now < stop... | [
"Validate that quantum is positive; otherwise raise ValueError.",
"Set the local simulation time to 0.0 and check whether it is below stop_time.",
"Compute requested as min(now + quantum, stop_time), then ask master.request_time(requested) for a grant.",
"Validate that now < granted <= requested; raise Runtim... | Describe how the master controls time advancement, what grant values are accepted, and how the components are scheduled after a grant. | The scheduler starts at time 0.0 and requests a time no later than stop_time, at most quantum beyond now. It accepts a grant only if it is strictly later than now and no later than the requested time; otherwise it raises RuntimeError before calling any component for that iteration. For a valid grant, it computes the el... | run first rejects a nonpositive quantum. Inside the loop, it computes requested and calls master.request_time(requested). The grant-validation branch raises RuntimeError if the grant is outside the open interval after now through requested, so no component step is issued for an invalid grant. For a valid grant, the sch... | The quantum limits the requested advance, while stop_time caps the request at the end of the run. Actual progress is determined by the master's granted time, which must be later than the current time and cannot exceed the request. Each component receives the same granted endpoint and elapsed interval. The code waits fo... |
class EventScheduler:
def __init__(self, components):
self.components = components
def run(self, stop_time: float) -> float:
now = 0.0
while now < stop_time:
next_times = [component.next_event_time(now)
for component in self.components]
... | [
"Initialize now to 0.0 and continue while it is less than stop_time.",
"Call next_event_time(now) on each component and collect the reported times.",
"Choose the minimum of stop_time and the reported event times; raise RuntimeError if the result is not later than now.",
"Call advance_to(target) on every compo... | Explain how the scheduler selects each synchronization boundary and why it has separate advance and event-processing loops. | At each iteration, the scheduler asks every component for its next event time relative to now, then selects the earliest of those times and stop_time. If that target is not later than now, it raises RuntimeError. Otherwise, it advances every component to the selected target before calling process_events_at(target) on a... | The while loop runs while now is below stop_time. A list comprehension gathers next_event_time(now) from each component, and min selects the earliest reported time or stop_time, whichever is earlier. The guard rejects a target at or before now. For a valid target, the first component loop advances all components; only ... | The scheduler advances from one selected boundary to the next rather than using a fixed step. Each boundary is the earliest component-reported event time, capped at stop_time. All components are advanced to the same target before any component processes events there, making the advance phase precede the event-processin... |
Co-Simulation Scheduling and Time Synchronization Code Understanding Dataset
This dataset contains source code understanding samples focused on co-simulation master controllers and scheduling components, including simulation step sizes, execution order, time advancement, and synchronization control. Each sample pairs source code with an analysis question and an answer, and includes explanations of control flow, execution order, and timing relationships. It supports code SFT training and evaluation for understanding scheduling implementations in co-simulation tools, rather than generating or configuring simulation models.
Technical Specifications
| Field | Type | Description |
|---|---|---|
| source_code | string | Source code from a co-simulation master controller or scheduling component to be analyzed. |
| execution_order | array | An ordered list of co-simulation components or scheduling stages, with an explanation of each stage. |
| analysis_question | string | A code understanding task or analysis question about the source code. |
| understanding_answer | string | An accurate answer based on the source code that explains the scheduling implementation and its key behaviors. |
| control_flow_explanation | string | An explanation of the call path, branch conditions, loop behavior, and changes in control flow across scheduling-related functions or modules. |
| timing_and_synchronization_explanation | string | An explanation of simulation step sizes, time advancement methods, synchronization conditions, and timing relationships between components. |
Compliance Statement
| Authorization Type | CC-BY-NC-SA 4.0 (Attribution–NonCommercial–ShareAlike) |
| Commercial Use | Requires exclusive subscription or authorization contract (monthly or per-invocation charging) |
| Privacy and Anonymization | No PII, no real company names, simulated scenarios follow industry standards |
| Compliance System | Compliant with China's Data Security Law / EU GDPR / supports enterprise data access logs |
Source & Contact
- Downloads last month
- 50