HILIGTHer_FLIM_DigitalTwin

Optimization Strategy

Inputs Analysed

This strategy is based on three sources already present in the project:

What The Existing Backend Already Does

The current backend already contains one valid detection-gate optimiser:

This should be preserved and exposed as one selectable optimization algorithm, not removed.

What The 2013 Paper Adds

The published paper adds two algorithmic ideas that are not yet represented properly in the current backend:

  1. Partition-theorem iterative optimisation
    • A bottom-up strategy that increases channel count by splitting a gate only when the Fisher-information gain is non-trivial.
    • A top-down strategy that decreases channel count by merging channels while minimising information loss.
  2. Full optimisation after partition-theorem initialisation
    • The paper distinguishes between a fast iterative partitioning strategy and a later direct optimisation/refinement step.
    • In practical terms, the current SLSQP optimiser is a good match for the refinement stage, but not for the partition-theorem stage.

So, for detection gates, the backend should eventually expose:

The current backend already covers the direct-refinement family.

What The FisherCompression Document Adds

The Fisher Compression note is materially different from the current optimizer.

It proposes:

This is not just another SLSQP parameterisation. It is a separate algorithm family:

So this should be implemented as a distinct detection optimizer:

Do not keep growing all optimisation logic inside TwinEngine.

Create a small optimisation layer under the backend, for example:

Suggested responsibilities:

TwinEngine should remain the source of forward physics, Fisher evaluation, and simulation, while the optimization layer becomes the consumer of those primitives.

Controller Model To Support

The controller now needs to represent four separate concerns:

  1. Scope
    • optimize detection gates
    • optimize excitation profile
  2. Execution mode
    • one target only
    • sequential
    • iterative alternating
    • if sequential, choose which one runs first
  3. Objective
    • Fisher Information
    • Fisher Throughput
    • if throughput, define the maximum permitted FI loss
  4. Algorithm family
    • detection algorithm
    • excitation algorithm
    • constraint rules for starts, ends, dose, and peak

These settings belong in PhysicsConfig because they affect reproducible optimization behavior and should be accessible through GUI, API, and MCP.

Detection Optimization Strategy

A. Legacy direct optimizer

Use the current backend implementation as:

This is the best match to:

B. Partition-theorem bottom-up

Implementation idea:

  1. Start from a minimal valid partition.
  2. For every current segment, evaluate all admissible splits.
  3. Score each split by Fisher-information gain or information-loss reduction.
  4. Add the best non-trivial split.
  5. Repeat until the requested number of gates or until marginal gain falls below threshold.

Benefits:

C. Partition-theorem top-down

Implementation idea:

  1. Start from a fine partition or dense reference partition.
  2. Evaluate the information loss from merging adjacent segments.
  3. Repeatedly perform the least harmful merge.
  4. Stop at the requested number of gates or loss threshold.

Benefits:

D. Fisher compression dynamic programming

Implementation idea:

  1. Build a fine reference histogram grid.
  2. Evaluate per-bin probabilities and score vectors on one or more design points.
  3. Precompute segment costs for every contiguous interval.
  4. Solve optimal contiguous K-segment partition by dynamic programming.
  5. Recover boundaries from the backpointer table.

Important extensions from the note:

This is the best match to:

Excitation Optimization Strategy

A. Gaussian width

Variables:

Implementation:

B. Square width

Variables:

Implementation:

C. Free-form excitation

Variables:

Constraints:

Implementation:

This should not start as a fully unconstrained pointwise optimization. A low-dimensional spline or control-point basis is safer and easier to regularize.

Objective Definitions

Fisher Information objective

This should optimize on the parameter already selected as the active X parameter in the Decay Model tab.

Recommended aggregate objectives:

Fisher Throughput objective

This should optimize:

Recommended definition:

where detected photon rate depends on the excitation constraint model:

The FisherCompression note already gives the correct conceptual split:

To implement the requested “without sacrificing too much FI”:

Joint Optimization Modes

Detection only

Run the chosen detection algorithm and leave excitation unchanged.

Excitation only

Run the chosen excitation algorithm and leave detection unchanged.

Sequential

Run both, once, in the chosen order.

Recommended defaults:

Iterative alternating

Run:

  1. detection optimization,
  2. excitation optimization,
  3. repeat until:
    • objective change is below tolerance,
    • boundaries and excitation parameters stabilize,
    • or iteration count limit is hit.

Recommended stop criteria:

Boundary and Anchor Rules

All detection algorithms should share the same anchor abstraction:

This should be translated into absolute time bounds before each algorithm runs, so the algorithms themselves only handle contiguous segments inside a bounded interval.

Phase 1

Phase 2

Phase 3

Phase 4

Phase 5

Recommendation

The right strategy is not to replace the current optimizer. It should become one algorithm in a broader optimization framework.

Concretely: