GenTL uses genetic search to build scheduled, integer-time timeline plans. The root planner reads the domain from DDL and the planning instance from JSON. It runs on Python 3.10+ with the standard library.
python3 -m gentl models/satellite_simple_v1.0.ddl models/satellite_simple_instance.json --seed 0 --guided-rate 0.5 --report-dir reports/quick-start
python3 -m unittest -vThe example starts PointingMode in Earth and uses the occurrence goal and fixed visibility intervals in the checked-in JSON instance. In the original three-token regression case, seed 0 reaches zero fitness in generation 3 after 96 evaluations with history [1, 1, 1, 0]. The regression suite compares the complete schedules, histories and evaluation counts with v0.2 for ten baseline seeds and ten guided seeds. The CLI returns 0 for a valid plan, 1 for a spent search budget and 2 for invalid input. A spent budget provides no proof of infeasibility.
| Location | Responsibility |
|---|---|
| main.py, gentl/main.py | CLI entry points. Load the domain and instance, call the solver, and print or export the result. Run main.py from PyCharm with the same arguments shown above and the repository root as the working directory. |
| gentl/model.py | Domain and instance types, immutable genes and tokens, decoding, constraint validation, and default fitness. |
| gentl/ddl.py | Parse the supported DDL fragment into a Domain. A Python caller can also construct the same model directly. |
| gentl/operators.py | Sample locally feasible paths and implement the default initialization, crossover, and mutation strategies. |
| gentl/search.py | Manage generations, evaluate and rank candidates, choose parents, retain elites, apply variation, and decide when to stop. |
| gentl/reporting.py, gentl/visualize.py | Export measurements and schedules, draw the plan, and render the recorded lineage for browser playback. |
| models/ | Satellite DDL domain and a JSON planning instance. The planner uses their timeline and value names as data. |
| test_gentl.py | Root planner regression tests, including paired v0.2 comparisons and non-satellite cases for custom strategies and fixed tokens. |
| v0.1/, v0.2/ | Historical prototypes, their documented assumptions, and recorded results. |
| reports/ | Example exports and raw data from the horizon sweep. |
The domain defines the state variables, value sets, transition graph, duration bounds, and synchronization rules. A Problem combines that domain with a horizon, initial values, fixed schedules, anchored tokens, and occurrence goals. solve(problem, ...) works on this in-memory model, so custom strategies can use it without the CLI, JSON loader, or reporting tools.
- Each timeline covers
[0, horizon)with contiguous positive-duration tokens. Values specify inclusive duration bounds and permitted successor values. The last token needs no successor. - The DDL reader supports parameterless singleton state-variable types, primitive component timelines,
MEETStransitions, and conjunctive synchronization declarations withBEFORE,AFTER,DURINGandCONTAINS. Each alias binds a distinct-from-trigger witness. All relations on an alias must hold on the same witness, and a witness may be reused across aliases or trigger occurrences. For the scheduled fragment, both DDL dependency markers use existential support semantics. The reader rejects unsupported syntax. - JSON
initialmaps timeline names to initial values. Eachgoalsentry names a timeline and value and specifies a minimum token count and optional maximum. Equal minimum and maximum specify an exact count. - JSON
fixedmaps a timeline name to its immutable, gap-free schedule as[value, duration]pairs or as an object withgap_valueandintervals. Each interval is a[value, start, duration]triple. The loader sorts intervals and fills each uncovered stretch with a single token ofgap_value. The resulting timeline must satisfy the model’s duration and transition rules. JSONanchorsfixes individual tokens on evolving timelines as[value, start, end]triples. The optional JSONhorizonoverrides the DDL horizon. - The Python model also lets you mark variables or values with
controllable=False. Such variables require a fixed schedule. Such values on evolving timelines can occur only at supplied anchors. All supplied external times are known at search time. The planner uses no flexible temporal networks, uncertain durations or dynamic-controllability reasoning.
A gene is the immutable pair Gene(value, duration). The value names a modeled state on the gene’s timeline. The duration is the positive integer time assigned to that occurrence. The same value may appear in several genes, with each gene representing a separate occurrence. The model supplies the admissible duration bounds and successor values, so those constraints are shared across candidates.
A segment is a tuple of genes for one timeline. A chromosome is a tuple of segments ordered by the domain’s timeline declarations. Timeline identity comes from the segment index. For example, with timeline order mode, signal and horizon 10, one chromosome could be encoded as follows:
(
(Gene("Idle", 3), Gene("Work", 4), Gene("Idle", 3)),
(Gene("Off", 2), Gene("On", 6), Gene("Off", 2)),
)Segments contain only active genes and can vary in length between individuals. Each valid segment has total duration equal to the horizon. v0.2 allocated padded segments and used sentinel genes for unused slots. The current representation stores the same scheduled occurrences in variable-length tuples.
A fixed timeline occupies the same segment position in every individual and carries its complete input schedule. An anchored token occurs on an otherwise evolvable timeline. Its value, start, and end are part of the instance, and the corresponding gene must appear at the exact cumulative time specified by the anchor. Default operators evolve only non-fixed segments and reject proposed changes that move or remove an anchor.
Decoding each segment starts a clock at zero. For gene i with duration d[i], the token starts at the sum of all earlier durations and ends at its start plus d[i]. The decoder then advances the clock to that end. Start and end are derived coordinates, so there is no separate start-time gene to keep aligned with preceding tokens.
| Timeline | Decoded tokens |
|---|---|
mode |
Idle [0, 3), Work [3, 7), Idle [7, 10) |
signal |
Off [0, 2), On [2, 8), Off [8, 10) |
The half-open intervals share a boundary without overlapping. Positive durations and cumulative decoding give contiguous coverage, while the sum of durations determines the final end. This is why the default operators work with equal-duration edits or a shared time boundary. Those edits retain the horizon even when the number of genes changes. Use decode(segment) to obtain tokens for one segment and decode_plan(chromosome, problem) to obtain the named timelines.
For each evolvable timeline, a memoized local feasibility check asks whether an interval of a given duration can be filled from a predecessor to a successor, optionally forcing the first value. Initialization uses this check to sample only choices that admit a feasible continuation. It fills gaps between anchors as separate intervals and copies complete fixed schedules into the chromosome. Each sampled segment chooses a short-biased, uniform, or long-biased duration sampling mode to vary token counts across the population. Local generation handles duration bounds, transitions, initial values, and horizon coverage. Synchronization and occurrence goals are evaluated on the complete candidate.
The default fitness minimizes the number of violations returned by validate. Validation checks the decoded schedules against local constraints, fixed data, synchronization rules, and occurrence goals. For each triggering token, the validator looks for the witnesses required by its synchronization rule. For each count goal, missing or surplus occurrences contribute one violation each. A score of zero under the default fitness means the candidate is valid. With custom fitness, the solver checks validity separately.
The default crossover operates on one randomly chosen evolvable timeline. It computes the cumulative boundary times for both parents, then considers only interior times that are boundaries in both segments. At each candidate cut, it checks that the first value in the second parent’s suffix is an allowed successor to the last value in the first parent’s prefix. It samples a compatible cut and joins that prefix and suffix. All other segments come from the first parent.
For example, consider two locally valid segments on the same timeline:
Parent 1 Idle(3) Work(4) | Idle(3)
Parent 2 Idle(5) Work(2) | Cool(3)
Child Idle(3) Work(4) | Cool(3)
The cut is at time 7 even though the earlier token boundaries differ. The splice is legal if Work → Cool is allowed. The prefix still covers [0, 7) and the suffix still covers [7, 10). Both chunks retain their original durations and internal transitions, so only the transition across the cut needs a new check. This lets crossover reuse scheduled subsequences without shifting everything after the cut. It can still break synchronization with other timelines, which is why the resulting candidate is scored again. With no compatible cut, no evolvable timeline, or an anchor violation, the operator returns the first parent.
Mutation samples one evolvable timeline and applies one of two local edits:
- Boundary shift. For a segment with at least two genes, there is a 35% chance of trying this edit within baseline mutation. The operator shuffles adjacent pairs and looks for a legal redistribution of their combined duration. For example,
Idle(3) Work(4)can becomeIdle(4) Work(3)if both new durations are allowed. The order and token count stay the same. Only their shared boundary moves. This lets search adjust temporal relationships while preserving the surrounding schedule. - Equal-duration replacement. Otherwise, or if the shift finds no admissible duration pair, the operator tries up to ten contiguous subsequences. For each chosen interval, it asks the local generator for a different path with the same duration, checking both neighbouring values and any required initial value when the edit starts at time zero. For example, a seven-unit block
Idle(3) Work(4)could becomeIdle(2) Work(3) Cool(2)if durations and transitions, including the transitions to the surrounding tokens, permit it. This edit can insert or delete tokens, change values, and reschedule the interior while leaving the rest of the timeline at the same times.
The selected edit may yield the original chromosome if a legal change cannot be found or its proposal would alter an anchor. Baseline mutation samples from local feasibility and leaves goal and synchronization trade-offs to fitness.
When mutation is selected, guided_rate is the conditional probability of choosing the guided operator. It defaults to zero. The operator looks for a DURING rule with an evolvable, controllable trigger and a matching support token on a fully fixed timeline. It samples a proposed trigger interval inside that support and checks its duration bounds and every relation on the chosen support alias. It then tries to retain an existing compatible prefix, generate a bridge to the trigger, and regenerate a feasible suffix to the horizon.
For the satellite instance this can place a communication within a known visibility window. It targets one temporal relation while leaving occurrence goals and other synchronization constraints to validation and selection. If no eligible support or compatible construction is found, the operator falls back to baseline mutation. The fixed support schedule stays immutable, and the same anchor check applies to the proposed result.
Generation zero is the initialized population. Each generation is evaluated in full. By default, the solver ranks candidates by ascending score and returns the first valid candidate in that order. If search continues, it copies the elites, samples parents by tournament, and creates offspring with independently sampled crossover and mutation attempts. The next generation includes the elites, which are evaluated again.
| Setting | Default | Effect |
|---|---|---|
seed |
7 | Initializes the random generator shared by built-in selection and variation. |
population_size |
24 | Candidates evaluated per generation. |
max_generations |
300 | Maximum number of generations after initialization. The evaluation cap is population_size × (max_generations + 1). |
tournament_size |
3 | Number of distinct population indices sampled per default parent selection. The lowest score wins. |
elite_count |
1 | Number of top-ranked candidates copied into the next generation. |
crossover_rate |
0.8 | Probability that a non-elite child receives a crossover attempt. |
mutation_rate |
0.85 | Probability that a non-elite child receives a mutation attempt. |
guided_rate |
0.0 | Probability of guided mutation conditional on the built-in mutation branch being selected. |
The CLI exposes --seed, --population, --generations, and --guided-rate. The Python API exposes all settings and callbacks. For an ablation, set crossover_rate=0 for mutation-only evolution. For independent random samples, set max_generations=0 and allocate the evaluation budget to the initial population.
Pass any combination of the following callables to solve. Defaults apply to omitted callbacks.
| Callback | Contract and application |
|---|---|
initialize(operators) |
Return one chromosome. Called separately for each initial individual. Use it to seed hand-built schedules or sample with a different token density. |
score(candidate, problem) |
Return an orderable score, where lower is better. Use scalar numeric scores with the CSV and lineage reporters, which compute score statistics and serialize scores. |
select(population, scores, rng) |
Return a parent from the current population. Scores and candidates share indices. Return the actual population object to retain its identity in lineage output. |
crossover(first, second, operators) |
Return one child chromosome when crossover is selected. |
mutate(candidate, operators) |
Return the resulting chromosome when mutation is selected. This callback takes over the entire mutation decision, including any choice between baseline and guided operators. |
stop(candidate, score, problem) |
Return true to stop on that ranked candidate. Use a candidate-level validity check when a solution must be feasible. Returning false throughout runs to the budget, at which point the solver returns the lowest-scoring valid plan it found, if any. |
observer(event) |
Receive one Generation record after each population is evaluated. It contains scores, validity flags, cumulative evaluations, distinct candidate count, and elapsed time. Set trace_lineage=True to include parent indices and operator labels. |
Operator callbacks receive an Operators instance with problem, the shared seeded rng, and a generators mapping keyed by evolvable timeline index. They can call the built-in operators or reuse LocalGenerator.segment(remaining, previous, following, forced_first, density) to construct a locally valid interval. Return immutable chromosome tuples in domain order and preserve fixed schedules and anchors. Default variation assumes locally feasible inputs, so custom initialization and variation should preserve duration bounds, legal transitions, and coverage when combined with those defaults.
For example, the following custom crossover inherits one complete evolvable timeline from the second parent. Whole-segment inheritance keeps the selected parent’s timing and local feasibility intact while testing a different combination of timelines. The score weighs synchronization errors more heavily, and the custom stop spends the full budget so that valid plans can compete on token count.
from gentl import solve, validate
def whole_timeline_crossover(first, second, operators):
if not operators.generators:
return first
index = operators.rng.choice(tuple(operators.generators))
return operators.replace(first, index, second[index])
def score_with_token_count(candidate, problem):
errors = validate(candidate, problem)
hard_cost = sum(3 if "synchronization" in error else 1 for error in errors)
token_count = sum(len(segment) for segment in candidate)
return hard_cost + token_count / (1 + len(problem.domain.variables) * problem.horizon)
result = solve(
problem,
score=score_with_token_count,
crossover=whole_timeline_crossover,
guided_rate=0.5,
stop=lambda candidate, score, problem: False,
seed=0,
)For locally feasible chromosomes each timeline has at most horizon tokens, so the fractional term is below one and breaks ties without outweighing a whole hard-cost point. This example continues to use the default initialization, selection, and mutation. Use result.valid to check the outcome and result.history to inspect the best score per generation.
v0.1 tested whether a model-driven encoding, initialization and variation could preserve local feasibility while evolution resolved count goals and synchronization. It used one timeline and checked that every science observation had a later communication. v0.2 restored the external visibility timeline, required full containment for communications, and added optional visibility-guided mutation as an experimental factor. Both versions allowed several observations to share a communication and treated the number of communications as irrelevant to feasibility. The documented research agenda calls for comparing random search, mutation-only evolution and full genetic search under matched budgets, then measuring the impact of guided mutation and alternative fitness functions. Earlier GenTL interaction transcripts were unavailable in the local session records examined.
Set the optional report object in your planning instance to generate a report:
"report": {
"directory": "reports/run-001",
"gantt": true,
"lineage": true
}Use a separate directory for each run. --report-dir PATH overrides the JSON directory and also enables CSV and JSON reporting on its own. Relative paths are resolved from the working directory. Both visualization flags default to false. If either is enabled without an output directory, GenTL writes to gentl-report.
| Output | Contents |
|---|---|
summary.json |
Solver settings, input hashes, environment, validity, violations, first feasible generation, evaluations, elapsed time, token counts, and per-timeline spans and counts by value |
generations.csv |
Cumulative evaluations and elapsed time, best, mean, median, worst and population standard deviation of scores, valid candidate count, and distinct chromosome count |
tokens.csv |
One row per scheduled token with timeline, token index, value, start, end, and duration |
plan.svg |
Vector Gantt chart with one row per timeline and a shared time axis |
lineage.jsonl, lineage.html |
Streamed candidate ancestry log and an interactive browser replay with a generation slider, playback, and clickable candidates |
GenTL appends generation statistics and, when enabled, lineage data as it searches. Open the Gantt and lineage files in a browser after the run. The lineage view shows the most recent eight generations at the slider position and records attempted operators, including crossover or mutation attempts that leave a chromosome unchanged. Elites link to their previous-generation entries. Run metrics measure elapsed wall time through population evaluation, including initialization and breeding and excluding report writes. Evaluation counts include reevaluated elites.
Makespan is the latest token end minus the earliest token start, for the full plan or the specified timeline. Under the current gap-free, full-horizon semantics it equals the horizon for every valid timeline. Token counts and counts by value can distinguish two valid plans for the same instance. Metrics from unsuccessful runs describe the returned best candidate and carry a separate validity status and violations.
The raw run data uses the current satellite instance with ten required Science tokens, the same visibility intervals and five seeds (0 through 4) at each horizon. Population was 24, guided mutation rate 0.5, and the budget was 60 evolutionary generations (1,464 evaluations including initialization).
| Horizon | Valid runs | Median seconds, all runs | Median evaluations, valid runs |
|---|---|---|---|
| 100 | 5/5 | 0.043 | 192 |
| 150 | 5/5 | 0.124 | 432 |
| 200 | 3/5 | 0.165 | 384 |
The longer horizons extend the final gap in the fixed visibility schedule. This is a small, single-domain pilot. Report success rate and budget-exhausted runs alongside time or evaluations to first feasible plan when comparing configurations. The example Gantt chart and lineage replay show a successful run at horizon 100.