From 3cd8567a9b8e6fa02fe95c7393c17beeb1ae5445 Mon Sep 17 00:00:00 2001 From: Tim Date: Sat, 1 Nov 2025 06:39:54 +0100 Subject: [PATCH 1/2] #541 Define AverageEnergy for Mixture node, throwing a warning. --- src/nodes/predefined/mixture.jl | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/nodes/predefined/mixture.jl b/src/nodes/predefined/mixture.jl index c32109186..ffd30dc34 100644 --- a/src/nodes/predefined/mixture.jl +++ b/src/nodes/predefined/mixture.jl @@ -194,3 +194,18 @@ function collect_latest_marginals(::RequireMarginalFunctionalDependencies, facto return marginal_names, marginals_observable end + +# FreeEnergy related functions +@average_energy Mixture (q_out::Any, q_switch::Any, q_inputs::ManyOf{N, Any}) where {N} = begin + @warn """ + AverageEnergy not defined for Mixture node. + + The Mixture node performs model comparison using log-scale factors, + hence its contribution to the Bethe Free Energy (BFE) is not well-defined. + + Returning 0.0 as a placeholder. If you need a proper energy term, + consider expanding the mixture explicitly or using Gate-style nodes. + """ + return 0.0 +end + From 1127f6288450b7f77b32e9ea72ccf14b9f8b57bf Mon Sep 17 00:00:00 2001 From: Tim Date: Sat, 1 Nov 2025 06:40:24 +0100 Subject: [PATCH 2/2] make format --- src/nodes/predefined/mixture.jl | 1 - 1 file changed, 1 deletion(-) diff --git a/src/nodes/predefined/mixture.jl b/src/nodes/predefined/mixture.jl index ffd30dc34..bf7c805ec 100644 --- a/src/nodes/predefined/mixture.jl +++ b/src/nodes/predefined/mixture.jl @@ -208,4 +208,3 @@ end """ return 0.0 end -