CommunityCoding & Developmentgithub.com

Drug Crystallization Multi-Objective Optimization

Given a set of crystallization process parameters (or a direct optimization request), outputs a complete Pareto front satisfying multiple constraints (yield ≥60%, purity ≥99%, particle size D50∈[10,50]μm, dissolution similarity factor f2≥50), predicted quality metrics, and a quantitative comparison with literature baselines.

What is Drug Crystallization Multi-Objective Optimization?

This skill transforms a crystallization optimization request—starting from a set of parameters or a target process stage—into a quantitative, reproducible optimal process solution that satisfies multiple constraints. The core is an interpretable deterministic kinetic model (digital twin) mapping six process variables to four quality metrics (yield, purity, particle size D50, dissolution similarity factor f2). The workflow includes: identifying the user's need, running the computational core (NSGA-II for multi-objective Pareto optimization with 80 non-dominated solutions, Gaussian process Bayesian optimization, and a five-agent pipeline), interpreting the Pareto front to find the knee point and extremes, and outputting a before/after comparison with literature baselines. It supports platforms where the skill can be invoked via CLI (e.g., agent-based assistants like Claude Code, Cursor, or Codex) and provides full transparency through sensitivity analysis, surrogate model cross-validation, and an independent reviewer agent that validates Pareto non-dominance and feasibility.

Works with~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/DrunkMan9o/agent-skills/tree/HEAD/skills/pharma-crystallization-optimization

Installed? Explore more Coding & Development skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

Ask in your favorite AI

Open a new chat with this agent skill pre-loaded.

Documentation

What does Drug Crystallization Multi-Objective Optimization do?

Purpose

Advances a crystallization process optimization requirement from "having a set of parameters / a target process stage" to "obtaining an optimal process solution (complete Pareto front) that satisfies multiple constraints, is reproducible, and has a quantitative comparison with the baseline."

The core is an interpretable deterministic kinetic model (digital twin) that maps 6 process variables to 4 quality metrics (yield / purity / particle size D50 / dissolution similarity factor f2). This SKILL orchestrates: identifying the requirement → invoking the computational core → interpreting the Pareto front → outputting a before/after optimization comparison.

Core Method (Interpretable Kinetic Engine)

ModuleImplementationLiterature Anchor
Solubility Curvevan't Hoff: C*(T)=4.48·exp[8.3/R·(1/293−1/T)]Grade A: Biowaiver Monograph 2017 (20℃ 4.48 mg/mL)
Nucleation RateB = kb·max(σ−0.3,0)⁴ + kb2·G·μ2·f_mixing(stirring)Primary classical theory + secondary growth coupling; threshold S=4.5 (Tian Binbin 2015)
Growth RateG = kg·σ^m, m=1.9955 (BCF screw dislocation growth)Grade A: Tian Binbin et al., Chemical Engineering 2015 measured
Population Balance Equation (PBE)Moment method μ0…μ4 recursion, concentration-moment fully coupled material balance conservationGrade B: Randolph & Larson moment method

Optimization Method (Multi-Objective + Multi-Agent)

  • Primary Output: NSGA-II 4-objective complete Pareto front (80 non-dominated solutions + knee point + max-f₂/max-yield extremes), objectives = yield↑ / purity↑ / f2↑ / particle size towards 30μm↑.
  • Auxiliary: Gaussian Process (GP, RBF kernel + white noise, hyperparameters learned via log marginal likelihood LML) + Bayesian Optimization (EGO-style EI), for scalarization reference point cross-validation.
  • Five-Agent Pipeline: Literature (literature anchor gatekeeper) → Kinetics Modeler (PBE solver + material balance self-check) → Optimizer (Pareto front) → Risk/Regulatory (regulatory criteria + CQA) → Reviewer (independent review, PASS/FAIL verdict).
  • Sensitivity Analysis: Robustness assessment under temperature ±1°C / pH ±0.1 / cooling rate ±10% perturbations.

Trigger Conditions (When to Load This SKILL)

Triggered when any of the following scenarios are met:

  • User provides crystallization process parameters and requests evaluation of quality metrics or whether targets are met.
  • User requests to "optimize / search / find optimal parameters" for a crystallization process stage.
  • User mentions quality objectives such as yield / purity / particle size D50 / dissolution f2 and it involves crystallization.
  • User requests evaluation of dissolution similarity (f2) between generic and innovator drugs.
  • User provides a reference dissolution curve or literature baseline and requests a comparison.

Trigger Keywords: crystallization process optimization, crystallization parameter optimization, multi-objective process optimization, generic drug crystallization, particle size window, dissolution f2, cooling curve, seeding strategy, supersaturation control, amoxicillin crystallization, Pareto front, population balance.

Input/Output Format

Input

After the SKILL is loaded by the AI in a session, the computational core is driven by running scripts/crystallization.py (passing JSON via stdin). CLI input protocol:

{
  "mode": "evaluate | optimize | sensitivity | agents | dissolution_plot | explain",
  "params": {                       // Required for evaluate mode, 6 process variables
    "T_cryst_C": 15,                // Crystallization temperature ℃, [5, 25]
    "r_cool_C_per_min": 0.2,        // Cooling rate ℃/min, [0.05, 1.0]
    "S0": 1.8,                      // Initial supersaturation (dimensionless), [1.2, 2.5]
    "seed_wt_pct": 2,               // Seed mass %, [0, 5.0]
    "stir_rpm": 300,                // Stirring speed rpm, [100, 600]
    "hold_t_min": 120               // Holding time min, [30, 240]
  },
  "seed": 42                        // Optional for optimize/agents mode, random seed (default 42 for deterministic reproducibility)
}

Output

The computational core outputs a single-line JSON to stdout. Using mode=optimize as an example, core fields:

{
  "params": {"T_cryst_C": 5.9, "r_cool_C_per_min": 0.11, "S0": 1.9, "seed_wt_pct": 4.58, "stir_rpm": 586, "hold_t_min": 238},
  "metrics": {"yield_pct": 67.75, "purity_pct": 99.44, "D50_um": 44.26, "D90_um": 116.0, "f2": 79.13},
  "score": 174.88,
  "pareto": {"n_pareto": 80, "knee_point": {...}, "extremes": {"max_f2": {...}, "max_yield": {...}}, "pareto_front": [...]},
  "agents": {"literature": {...}, "kinetics": {...}, "optimizer": {...}, "risk_regulatory": {...}, "reviewer": {"verdict": "PASS", ...}},
  "sensitivity": {"robustness": {"conclusion": "Robust: f2 remains ≥50 under three-factor ± perturbation", ...}},
  "surrogate_cv": {"r2_mean": 0.74, ...},
  "bo_trace": [...],
  "cqa_coverage": {...}
}

The AI interprets the JSON result into a human-readable comparison conclusion, following the format in this file's "Result Interpretation" section.

Execution Steps (Standard Workflow)

Execute in order; the result of the previous step determines the next action:

  1. Identify Requirement: Confirm target API and process stage; determine if the user wants to "evaluate a single set of parameters" or "search for optimal parameters."
  2. Establish Baseline: Read the classic process baseline from the literature (or user-provided); default amoxicillin baseline is in references/tuning-guide.md.
  3. Multi-Objective Optimization (optimize): Invoke mode=optimize, primary output is the complete Pareto front (NSGA-II 80 non-dominated solutions).
  4. Result Evaluation (evaluate): Call mode=evaluate on candidate solutions, verify checks.all_satisfied and PBE process variables.
  5. Independent Review: Reviewer agent independently verifies Pareto non-dominance and feasibility, issues PASS/FAIL.
  6. Output Conclusion: Provide Pareto front + knee point/extremes + four-metric before/after comparison + sensitivity analysis conclusions + boundary statement.

Dependencies

TypeDependencyDescription
RuntimePython 3 (python3 / python / py whichever available)Runs the computational core
LibraryNumPy 2.5.4GP Gaussian process and NSGA-II vectorized operations (pip install numpy==2.5.4)
Core Filescripts/crystallization.pyInterpretable kinetic core (PBE) + multi-objective optimization + five agents, the only executable logic of this SKILL
Reference Docreferences/install-and-usage.mdInstallation, registration, usage examples
Reference Docreferences/tuning-guide.mdPhysical meaning, value ranges, and impact of all tunable parameters
External ResourcesNoneSelf-contained, no internet connection, no external API calls

Computational Core Invocation (CLI)

# evaluate: evaluate a single parameter set
echo '{"mode":"evaluate","params":{...}}' | python scripts/crystallization.py

# optimize: output complete Pareto front (primary) + GP-BO reference points
echo '{"mode":"optimize","seed":42}' | python scripts/crystallization.py

# sensitivity: sensitivity analysis (T±1°C/pH±0.1/cooling±10%)
echo '{"mode":"sensitivity","params":{...}}' | python scripts/crystallization.py

# explain: full explanation of what optimize ran (model card/search space/weights/constraints fully transparent)
echo '{"mode":"explain"}' | python scripts/crystallization.py

Result Interpretation

  • pareto.n_pareto → Number of non-dominated solutions on the Pareto front; knee_point is the trade-off solution with the smallest distance to the ideal point.
  • metrics.f2 >= 50 → Dissolution curve is "similar" to the innovator reference (FDA/CDE bioequivalence bridge criterion); f2 < 50 is considered dissimilar.
  • agents.reviewer.verdict = PASS → Pareto non-dominance + feasibility + baseline comparison all pass independent review.
  • sensitivity.robustness.f2_stays_above_50 → Whether f2 remains ≥50 under perturbation (operational robustness).
  • bo_trace → 64 evaluations recorded step by step (parameters/scores/source/GP hyperparameters/EI), optimization process fully auditable.

Boundary Statement

This SKILL output is a process search and pre-screening tool based on an interpretable kinetic engine (not a GMP experimental substitute). Final bioequivalence conclusions must be supported by actual experiments and submission data. Yield Definition: This model's yield is based on material balance (precipitated solid / solution solid), which differs from the literature's "overall yield" definition; see references/tuning-guide.md for details.

Individual skills in this repo

This repo contains 1 individual skill — each has its own dedicated page.

Related Skills