From ad7b165c914acd0d71fd0b6498642772aca0b45a Mon Sep 17 00:00:00 2001 From: Bagaev Dmitry Date: Mon, 18 Sep 2023 15:16:37 +0200 Subject: [PATCH] fix warning for predicted datavars --- src/constraints/specifications/constraints.jl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/constraints/specifications/constraints.jl b/src/constraints/specifications/constraints.jl index 1f5517b4f..b83ec6c5c 100644 --- a/src/constraints/specifications/constraints.jl +++ b/src/constraints/specifications/constraints.jl @@ -104,7 +104,10 @@ function activate!(constraints::ConstraintsSpecification, nodes::FactorNodesColl foreach(constraints.factorisation) do spec specnames = getnames(spec) foreach(specnames) do specname - if warn && (hasdatavar(variables, specname) || hasconstvar(variables, specname)) + if hasdatavar(variables, specname) && allows_missings(variables[specname]) + # skip, because it is fine to have a datavar in the factorization constraint, which allows missings + nothing + elseif warn && (hasdatavar(variables, specname) || hasconstvar(variables, specname)) @warn "Constraints specification has factorisation constraint for `q($(join(specnames, ", ")))`, but `$(specname)` is not a random variable. Data variables and constants in the model are forced to be factorized by default such that `q($(join(specnames, ", "))) = q($(specname))q(...)` . Use `warn = false` option during constraints specification to suppress this warning." elseif warn && !hasrandomvar(variables, specname) @warn "Constraints specification has factorisation constraint for `q($(join(specnames, ", ")))`, but variables collection has no random variable named `$(specname)`. Use `warn = false` option during constraints specification to suppress this warning."