base
base
¶
Workflow protocol + evaluator-factory plumbing.
A workflow is a multi-stage orchestration of optimizer passes. Workflows consume:
- an immutable :class:
~q2mm.models.problem.OptimizationProblem, - an evaluator factory — a
Callable[[ObjectivePlan], ObjectiveEvaluator]that builds a concrete executor (Python or JAX) for a compiled plan, and - a pre-configured optimizer.
They compile :class:~q2mm.objectives.plan.ObjectivePlan objects, drive the
optimizer, and aggregate per-stage diagnostics into the one canonical
:class:~q2mm.models.results.OptimizationResult. Workflows never
construct backends or objectives directly, never mutate a force field, and
never store a force-field snapshot in the result — callers materialize a
force field explicitly via layout.replace(base_ff, result.final_params).
Workflow
¶
Bases: Protocol
Multi-stage force field parameterization workflow.
run
¶
run(problem: OptimizationProblem, make_evaluator: Callable[[ObjectivePlan], ObjectiveEvaluator], optimizer: _Optimizer, *, n_evals: int = 1, regularization: float = 0.0) -> OptimizationResult
Execute the workflow and return the canonical result.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
OptimizationProblem
|
The immutable optimization problem. |
required |
make_evaluator
|
Callable[[ObjectivePlan], ObjectiveEvaluator]
|
Factory that builds an executor from a plan. |
required |
optimizer
|
_Optimizer
|
Pre-configured optimizer. |
required |
n_evals
|
int
|
Configured-executor samples at the initial and final
parameters ( |
1
|
regularization
|
float
|
Non-negative L2 penalty threaded into every
:class: |
0.0
|
Source code in q2mm/workflows/base.py
make_evaluator_factory
¶
make_evaluator_factory(backend: Backend, base_force_field: ForceField, *, settings: ObjectiveSettings) -> EvaluatorFactory
Close over explicit construction choices; each stage gets its own executor.
Source code in q2mm/workflows/base.py
build_workflow
¶
build_workflow(settings: WorkflowSettings) -> Workflow
Construct exactly the declared workflow, without policy resolution.