ProGED
SRToolkit.approaches.ProGED
ProGED approach — probabilistic grammar-based equation discovery by Brence et al.
ProGEDConfig
dataclass
ProGED
Bases: SR_approach
A slimmed-down version of ProGED — probabilistic grammar-based equation discovery.
Randomly samples expressions from a probabilistic context-free grammar (PCFG). The grammar defines both which expressions are structurally valid (hard constraints via registered Constraint objects) and a probability distribution over them (soft constraints via production rule weights), biasing sampling toward shorter or domain-appropriate expressions. Providing a domain-specific grammar is the main strength of this approach — it encodes prior knowledge about the expected form of the target expression and makes the search significantly more efficient. The full version of the approach is available at https://github.com/brencej/ProGED.
References
Examples:
>>> from SRToolkit.dataset import Feynman
>>> benchmark = Feynman()
>>> dataset = benchmark.create_dataset('I.16.6')
>>> dataset.max_evaluations = 100
>>> model = ProGED()
>>> # Since we don't put a custom grammar into ProGED we will need an automatically created PCFG.
>>> model.adapt(dataset.X, dataset.symbol_library)
>>> results = dataset.evaluate_approach(model, num_experiments=1, initial_seed=18, verbose=False)
>>> r = results[0]
>>> r.dataset_name
'I.16.6'
>>> r.approach_name
'ProGED'
>>> r.best_expr
'C-X_0/C-X_0'
>>> r.num_evaluated
63
>>> bool(r.success)
False
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
grammar
|
Optional[Union[str, Grammar, SymbolLibrary]]
|
Grammar used for sampling. Its production rule weights define a probability distribution over expressions — higher-weight rules are sampled more often, acting as a soft prior. Registered constraints impose hard structural limits. Providing a carefully designed, domain-specific grammar is strongly recommended, as it is the primary way to incorporate prior knowledge and improve search efficiency. One of:
|
None
|
Source code in SRToolkit/approaches/ProGED.py
prepare
search
Randomly sample expressions from the grammar and evaluate them until the budget is exhausted or the success threshold is reached.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sr_evaluator
|
SR_evaluator
|
SR_evaluator used to score candidate expressions. |
required |
seed
|
Optional[int]
|
Optional random seed for reproducible sampling. |
None
|
Returns:
| Type | Description |
|---|---|
None
|
None |