Atmosphere89/PromptAligner
0
1# ===========================2# core/evaluator.py — Harmony Index computation3# ===========================4 5def compute_harmony_index(v_c: float, v_a: float, v_s: float, weights=(1, 1, 1)) -> float:6 """7 Compute the Harmony Index (H) using a weighted geometric mean.8 9 Parameters10 ----------11 v_c : float12 Content Consistency (semantic similarity)13 v_a : float14 Aesthetic Alignment (visual style score)15 v_s : float16 Structural Similarity (composition matching)17 weights : tuple18 (alpha, beta, gamma) weight coefficients19 20 Returns21 -------22 float23 The harmony score (H) between 0 and 1.24 """25 alpha, beta, gamma = weights26 product = (v_c ** alpha) * (v_a ** beta) * (v_s ** gamma)27 exponent = 1 / (alpha + beta + gamma)28 return product ** exponent