""" Global configuration for BatchMind OS. All paths, constants, and settings in one place. Import this in every layer: from config import CFG """ import os class CFG: # ── Paths ────────────────────────────────────────────────────── BASE_DIR = os.path.dirname(os.path.abspath(__file__)) RAW_DIR = os.path.join(BASE_DIR, "data", "raw") PROC_DIR = os.path.join(BASE_DIR, "data", "processed") MODEL_DIR = os.path.join(BASE_DIR, "data", "models") SIG_DIR = os.path.join(BASE_DIR, "data", "golden_signatures") PROCESS_FILE = os.path.join(RAW_DIR, "_h_batch_process_data.xlsx") PROD_FILE = os.path.join(RAW_DIR, "_h_batch_production_data.xlsx") # ── Data columns ─────────────────────────────────────────────── SIGNAL_COLS = [ "Temperature_C", "Pressure_Bar", "Humidity_Percent", "Motor_Speed_RPM", "Compression_Force_kN", "Flow_Rate_LPM", "Power_Consumption_kW", "Vibration_mm_s" ] STAT_SIGNALS = [ "Temperature_C", "Pressure_Bar", "Power_Consumption_kW", "Vibration_mm_s", "Motor_Speed_RPM", "Compression_Force_kN" ] TARGET_COLS = [ "Hardness", "Friability", "Disintegration_Time", "Dissolution_Rate", "Content_Uniformity" ] PHASES = [ "Preparation", "Granulation", "Drying", "Milling", "Blending", "Compression", "Coating", "Quality_Testing" ] PARAM_COLS = [ "Granulation_Time", "Binder_Amount", "Drying_Temp", "Drying_Time", "Compression_Force", "Machine_Speed", "Lubricant_Conc", "Moisture_Content" ] # ── Feature engineering ──────────────────────────────────────── N_FINAL_FEATURES = 50 CHRONOS_MODEL = "amazon/chronos-t5-small" CHRONOS_SEQ_LEN = 200 PCA_MAX_COMPONENTS = 12 PCA_MIN_VARIANCE = 0.85 # If below this, reduce to 8 components # ── Model training ───────────────────────────────────────────── TEST_SPLIT = 0.2 # 20% holdout = 12 batches RANDOM_STATE = 42 LGB_PARAMS = { "objective": "regression", "n_estimators": 200, "learning_rate": 0.05, "max_depth": 4, "num_leaves": 15, "reg_alpha": 0.3, "reg_lambda": 0.3, "min_child_samples": 5, "subsample": 0.8, "colsample_bytree": 0.8, "verbose": -1, "random_state": 42, } # ── Carbon ───────────────────────────────────────────────────── INDIA_GRID_FACTOR = 0.82 # kg CO2e per kWh (India CEA 2024) ELECTRICITY_RATE = 8.0 # INR per kWh industrial ANNUAL_BATCHES = 60 # ── Optimization ─────────────────────────────────────────────── OPTUNA_TRIALS_FULL = 200 OPTUNA_TRIALS_DEMO = 30 # Use this during live demo OPTUNA_TIMEOUT_SEC = 60 PARAM_SPACE = { "Granulation_Time": (10, 25), "Binder_Amount": (5.0, 12.0), "Drying_Temp": (50.0, 75.0), "Drying_Time": (15, 40), "Compression_Force": (8.0, 20.0), "Machine_Speed": (80, 200), "Lubricant_Conc": (0.5, 2.0), "Moisture_Content": (1.0, 4.0), } # ── Default constraints ──────────────────────────────────────── DEFAULT_CONSTRAINTS = { "hardness_min": 80.0, "friability_max": 1.0, "dissolution_min": 85.0, "max_energy_kwh": 999.0, # No limit until carbon target set } # ── Matrix Profile ───────────────────────────────────────────── MP_WINDOW_SIZE = 10 # ── PSI Drift ────────────────────────────────────────────────── PSI_STABLE = 0.1 PSI_MONITOR = 0.2 # ── Signatures ───────────────────────────────────────────────── SIG_FILE = os.path.join(SIG_DIR, "signatures.json") SIG_TOLERANCE = 0.05 # ±5% tolerance bands # ── API ──────────────────────────────────────────────────────── API_HOST = "localhost" API_PORT = 8000 @classmethod def make_dirs(cls): """Create all required directories.""" for d in [cls.RAW_DIR, cls.PROC_DIR, cls.MODEL_DIR, cls.SIG_DIR]: os.makedirs(d, exist_ok=True)