# SR Analysis: Symbolic Regression Report

## 1. Problem Definition

Deep reinforcement learning (DRL) can discover effective flow control strategies, but the resulting policies remain black boxes: they map high-dimensional sensor observations to actuator commands through opaque neural networks. This limits interpretability, transferability, and trust.

This work addresses the problem of **post-hoc white-box extraction** from trained DRL policies. Given a PPO policy that successfully achieves hydrodynamic cloaking or illusion on the fluidic pinball, we use symbolic regression (PySR) to discover compact, interpretable control laws of the form:

```
alpha = f(obs_features)
```

where `alpha = omega / U0` is the non-dimensional cylinder rotation, and `obs_features` are physically meaningful dimensionless quantities (forces, velocities, their derivatives).

The chain we analyze is:

```
obs -> act -> flow structure -> signature
```

Symbolic regression directly handles only `obs -> act`, but its value lies in revealing the physical feedback mechanisms the DRL agent has learned.

## 2. Methodology

### 2.1 Feature System

We construct three levels of dimensionless physical features from raw CFD sensor data:

| Level | Features | Dim | Description |
|-------|----------|:---:|-------------|
| Static | u_m, u_a, u_c, v_a, Cd_tot, Cd_rear, Cl_tot, Cl_diff | 8 | Current-step physics only |
| Phase-state | u_a, du_a/dt, Cl_tot, dCl_tot/dt, Cd_tot, Cd_rear | 6 | Oscillation phase + rate + drag feedback |
| Illusion-phase | Phase-state + Cd_err, Cl_err, dCd_err/dt, dCl_err/dt | 10 | Phase + error-state tracking |

### 2.2 Structural Constraints (v23)

To enforce physical consistency, we impose two constraints:

1. **Front no-bias**: `alpha_F = 0` when all features = 0. In a clean uniform flow, no corrective action should be needed.

2. **Rear shared-head with G-mirror**: The top and bottom cylinders are symmetric under the mirror operation G: `[aF, aT, aB] -> [-aF, -aB, -aT]`. The same function `h()` predicts `alpha_T`, and `alpha_B = -h(G(x))`.

### 2.3 PySR Symbolic Regression

PySR is a multi-population evolutionary algorithm that discovers symbolic expressions by optimizing a loss function. Key settings:

- **Output**: non-dimensional alpha (not physical omega), so formulas are scale-free
- **Operators**: +, -, *, /, sin, cos, exp
- **Constraints**: max complexity 20-40, Pareto front optimization
- **Validation**: one-step R-squared on held-out data, followed by CFD closed-loop as the final arbiter

### 2.4 CFD Closed-Loop Validation

The final judge of any formula is CFD closed-loop performance: the formula replaces the PPO policy to control the pinball cylinders, and the resulting sensor signals are compared to the target via DTW similarity. This catches issues invisible to one-step metrics (e.g., drift accumulation, distribution shift).

## 3. Karman Cloak Results

### 3.1 Cross-Re Joint Formula

Training on data from four Reynolds numbers (Re=50, 100, 200, 400) jointly yields:

**Front**:
```
alpha_F = daF_dt - 14.952 * mu * Cl_tot
```

**Top**:
```
alpha_T = 3.414  (constant)
```

**Physical interpretation**: The front cylinder action is driven by two terms:
1. `daF_dt`: Action momentum (rate of change of front action), capturing that the controller maintains consistent rotational direction.
2. `-14.952 * mu * Cl_tot`: Viscous-scaled lift feedback. As viscosity decreases (higher Re), the lift feedback weakens proportionally, naturally adapting to different flow regimes.

The rear cylinders rotate at constant speed, suggesting they provide a steady boat-tailing effect rather than active feedback.

### 3.2 CFD Validation

| Re | PPO Baseline | Joint Formula | % of PPO |
|:--:|:-----------:|:------------:|:--------:|
| 50 | 0.961 | 0.847 | 88.1% |
| 100 | 0.954 | 0.888 | 93.1% |
| 200 | 0.884 | 0.845 | 95.6% |
| 400 | 0.795 | 0.806 | 101.4% |

At Re=400, the symbolic formula actually outperforms the PPO policy at the default sampling interval. Testing revealed that Re=400 benefits from a shorter control interval (SI=400 instead of 800), improving formula performance to 0.819.

### 3.3 Per-Re Individual Formulas

Individual PySR fits at each Reynolds number achieve higher similarity (0.888-0.916) but produce structurally different formulas across Re, reflecting the flow's bifurcation cascade through the Re=50-400 range. The joint formula trades some per-Re performance for a unified expression valid across all conditions.

## 4. Illusion Results

### 4.1 Joint Formula (0.75L + 1.0L)

Training PySR on the combined data from two target cylinder diameters (0.75L and 1.0L) yields:

**Front** (no bias):
```
alpha_F = Cd_tot - Cd_err - 5.428 + 0.0098 * (du_a_dt + u_a)
```

**Top** (with bias):
```
alpha_T = (Cd_err - (Cd_rear - Cl_err)) * 0.535 + 2.782
```

**Physical interpretation** of the front formula:
1. `Cd_tot - Cd_err = target_Cd`: The controller tracks the desired target drag coefficient.
2. `-5.428`: Constant offset accounting for unit/calibration differences.
3. `0.0098 * (du_a_dt + u_a)`: Small phase-lead correction from cross-stream velocity asymmetry, fine-tuning the shedding phase.

The top cylinder uses error-state feedback: the difference between drag error and rear lift distribution.

### 4.2 Cross-Diameter Generalization

The joint formula, trained only on 0.75L and 1.0L, is tested on unseen target diameters:

| Diameter | Joint Formula | PPO Baseline | Status |
|:--------:|:------------:|:-----------:|--------|
| 0.5L | 0.854 | — | Generalization (unseen) |
| 0.6L | 0.939 | — | Generalization (unseen) |
| 0.75L | 0.978 | 0.980 | Trained |
| 0.8L | 0.908 | — | Generalization (unseen) |
| 1.0L | 0.970 | 0.975 | Trained |
| 1.2L | 0.849 | — | Generalization (unseen) |
| 1.5L | N/A | 0.945 | Non-SR regime |
| 2.0L | 0.676 | — | Degraded (unseen) |

The formula maintains near-PPO performance (similarity > 0.9) for diameters within +/-20% of the training range (0.6L-1.2L). Performance degrades sharply at 2.0L, where the required wake is fundamentally different from what the formula was designed to produce.

### 4.3 The 1.5L Special Case

The 1.5L illusion presents a distinct control regime:

- The PPO policy achieves high similarity (0.945) but uses **high-frequency periodic modulation** at f=0.24 in control space, which is 5.6x the target vortex shedding frequency.
- Action autocorrelation at lag-2 = -0.9, indicating the cylinders switch direction every two control steps.
- All linear correlations between features and actions are below 0.33, meaning no low-dimensional linear structure exists.
- PySR returns trivial solutions (`alpha_F_lag1 * 0.01`), confirming the current feature set cannot capture this mechanism.

This is documented as a **fundamentally non-fittable regime** under the current methodology, not a failure of the approach.

## 5. Structural Comparison: Karman vs. Illusion

The discovered formulas reveal fundamentally different control mechanisms:

| Aspect | Karman Cloak | Illusion |
|--------|------------|----------|
| **Objective** | Preserve incoming vortex street | Sculpt a new vortex street |
| **Dominant term** | Force feedback (Cl_tot) | Error tracking (Cd_err) |
| **Front mechanism** | Action momentum + viscous-scaled lift | Target drag tracking + phase correction |
| **Rear mechanism** | Constant rotation | Error-state feedback |
| **Re dependence** | Explicit via mu parameter | None (Re=100 only) |

This structural difference is expected: cloaking requires the controller to make the pinball "transparent" to passing vortices (force-neutral), while illusion requires the controller to actively generate a specific wake (force-matching).

## 6. Cross-Scene Generalization: Vortex Cloak

The Karman joint formula, trained exclusively on periodic vortex street data, is applied without modification to transient vortex cloaking tasks:

| Vortex | PPO (vortex-trained) | Karman Formula |
|:------:|:-------------------:|:--------------:|
| Lamb dipole | 0.942 | **0.949** |
| Taylor monopole | 0.916 | 0.905 |

The formula matches or exceeds the PPO baseline for the Lamb dipole, demonstrating that the discovered feedback structure captures a universal cloaking mechanism rather than a scene-specific strategy.

## 7. Discussion

### 7.1 The Force-Signature Separation

The structural difference between Karman and Illusion formulas mirrors the OID analysis finding that force-relevant and signature-relevant correction structures are systematically different. In Karman cloak, suppressing force variation IS the way to preserve the signature. In illusion, the agent must actively generate a force pattern that differs from its natural one.

### 7.2 Regime Boundaries

The cross-diameter generalization curve defines a clear regime boundary: the joint illusion formula works for target cylinders within approximately +/-20% of the training diameters. Beyond this, either the formula structure itself is insufficient (2.0L) or the PPO policy has entered a fundamentally different control regime (1.5L with high-frequency modulation).

### 7.3 Limitations

1. **Karman rear formula is constant** (alpha_T = 3.414): The joint formula did not extract meaningful feedback for the rear cylinders, despite PPO showing structured rear actions. This suggests the rear contribution is either encoded in higher-order interactions or is secondary to the front cylinder's dominant role.

2. **daB_dt artifact**: The PySR front formula includes a `daB_dt` term, but this reflects training distribution correlations (front and rear actions are correlated in PPO trajectories), not a causal relationship. At deployment, rear is constant, making this term zero.

3. **Illusion limited to Re=100**: The current illusion formulas are trained only at Re=100 (Re_D=50). Cross-Re generalization for illusion, analogous to the Karman joint formula with its mu-scaling term, is left for future work.

## 8. Conclusion

Symbolic regression successfully extracts compact, physically interpretable control laws from trained DRL policies for the fluidic pinball. The discovered formulas:

- Achieve CFD closed-loop performance within 5-15% of the PPO baseline for in-distribution scenes
- Generalize to unseen Reynolds numbers (Karman) and target diameters (Illusion) within defined regime boundaries
- Reveal fundamentally different feedback mechanisms for cloaking (force-feedback) vs illusion (error-tracking)
- Demonstrate cross-scene transfer: Karman formula generalizes to transient vortex cloaking tasks

The approach bridges the gap between black-box DRL performance and white-box interpretability, providing a path toward verifiable, transferable flow control strategies.
