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
|
Real-objective samples at the initial and final
parameters for noise-floor quantification ( |
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, *, executor: str = 'python', gradient_mode: GradientMode | None = None, fd_step: float = 0.0001) -> EvaluatorFactory
Return an evaluator factory closing over the backend and base FF.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
backend
|
Backend
|
The MM backend the executors evaluate against. |
required |
base_force_field
|
ForceField
|
Structure/topology source for prepared sessions. |
required |
executor
|
str
|
|
'python'
|
gradient_mode
|
GradientMode | None
|
Gradient mode for the Python executor. Defaults to
:attr: |
None
|
fd_step
|
float
|
Central finite-difference step for the Python executor's
:attr: |
0.0001
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If executor is not |