\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{shapes.geometric, arrows.meta, positioning, calc, backgrounds}

\begin{document}

\begin{tikzpicture}[
    node distance=1.5cm and 2cm,
    % 设置节点样式
    base/.style={rectangle, rounded corners, draw=black, minimum width=2.5cm, minimum height=1cm, text centered, font=\small, fill=white},
    variable/.style={base, fill=blue!10, draw=blue!50!black},
    process/.style={base, fill=orange!10, draw=orange!50!black},
    decision/.style={diamond, aspect=2, draw=red!50!black, fill=red!5!white, font=\scriptsize, inner sep=0pt},
    formula/.style={font=\scriptsize, text=black!80},
    % 设置区域样式
    container/.style={draw, dashed, inner sep=15pt, rounded corners}
]

    % --- 1. Fairness Allocation Part ---
    \node[variable] (ntotal) {$N_{total} = 730$};
    \node[variable, below=of ntotal] (kbase) {$k_{base} \in [5, 10]$};
    
    \node[process, right=of $(ntotal.south)!0.5!(kbase.north)$] (nfree) {
        $N_{free} = N_{total} - 70 \cdot k_{base}$
    };

    \node[variable, right=of nfree] (kie) {
        $k_{i_e} = k_{base} + \text{round}\left(N_{free} \cdot \frac{D_i}{\sum D_i}\right)$
    };

    % --- 2. Effectiveness Scoring Part ---
    \node[process, below=2cm of kie] (eff) {
        $annual\_eff_i = k_{i_e} \cdot \min(d_i, d_0)$
    };

    \node[process, below=1cm of eff] (score) {
        $score_i = \frac{eff_i}{D_i} - \alpha \cdot unmet_i - \beta \cdot waste_i$
    };

    % --- 3. Validation Part ---
    \node[variable, left=of score] (gini) {
        $G = \frac{\sum \sum |score_i - score_j|}{2n^2 \overline{score}}$
    };

    \node[decision, left=of gini] (judge) {$G < 0.2$?};

    % --- 连线 ---
    \draw[-Stealth, thick] (ntotal) -- (nfree);
    \draw[-Stealth, thick] (kbase) -- (nfree);
    \draw[-Stealth, thick] (nfree) -- node[above, formula] {Demand Ratio Weight} (kie);
    \draw[-Stealth, thick] (kie) -- node[right, formula] {Supply-Demand Alignment} (eff);
    \draw[-Stealth, thick] (eff) -- (score);
    \draw[-Stealth, thick] (score) -- (gini);
    \draw[-Stealth, thick] (gini) -- (judge);
    
    % 回馈线
    \draw[-Stealth, thick] (judge.north) -- ++(0, 1.5) -| node[pos=0.2, above, formula] {Iterative Optimization (maximize total score)} (kbase.west);
    \draw[-Stealth, thick] (judge.south) -- ++(0, -0.5) -- ++(8, 0) |- node[pos=0.2, below, formula] {Final $k_{i_e}$ Allocation} (kie.east);

    % --- 绘制背景框 (模仿原图的 River/Ocean 分区) ---
    \begin{scope}[on background layer]
        % 公平分配区
        \node[container, draw=green!60!black, label={[green!60!black]above:\textbf{Tier 1: Dual-Fairness Allocation}}] 
        (fairbox) [fit=(ntotal) (kbase) (kie)] {};
        
        % 效能与验证区
        \node[container, draw=blue!60!black, label={[blue!60!black]below:\textbf{Tier 2: Effectiveness \& Equity Validation}}] 
        (effbox) [fit=(eff) (score) (gini) (judge)] {};
    \end{scope}

\end{tikzpicture}

\end{document}