Skip to content

Local optimization run

Download the notebook (executed for this page) · source

LBFGSB optimizes an exact bounded group parameterization. A feasible result can still be nonconverged, so inspect all status fields. This smooth MSE example permits negative beta weights. The toy configuration uses the JAXopt lbfgsb method; the production default is scipy-slsqp (SciPy SLSQP with exact constraints and analytic JAX gradients).

from pathlib import Path
import os, sys
ROOT = next(p for p in [Path.cwd(), *Path.cwd().parents] if (p / 'pixi.toml').exists())
os.environ['TFOPT_CONFIG'] = str(ROOT / 'notebooks/data/toy.toml')
os.environ.setdefault('MPLBACKEND', 'Agg')
if str(ROOT) not in sys.path:
    sys.path.insert(0, str(ROOT))
import tfopt
import numpy as np
import pandas as pd
from notebooks.tutorial import build_problem, optimize, OUTPUT
p = build_problem()
result=optimize(p)
print({key:getattr(result,key) for key in ['success','fun','nit','final_error','constr_violation','runtime_s','method']})
assert result.success and result.fun<1e-10
assert result.constr_violation<1e-8
{'success': True, 'fun': 3.637271479030326e-15, 'nit': 23, 'final_error': 5.348436532548462e-08, 'constr_violation': 0.0, 'runtime_s': 6.703442684999999, 'method': 'lbfgsb'}

Interpretation

Check both fit and feasibility. For biological data, identifiability, scaling and regulatory coverage need domain review. Results and figures belong only in notebooks/outputs/.