Handle fixing and conditioning together
Los mantenedores suelen responder en 2 días
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 38/100
Línea de trabajo
Comienza con las líneas 448-461 de src/compiler.jl y sigue la lógica de getconditioned/getfixed para las operaciones de condition y fix anidadas. Revisa la prueba de regresión prevista en test/submodel.jl y la representación existente de CondFixContext. Se considera terminado cuando la operación de conditioning o fixing más externa tiene precedencia de forma consistente para los cuatro pares de operaciones y hay pruebas que cubren este comportamiento.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Consider:
using DynamicPPL, Distributions
for op1 in [condition, fix]
for op2 in [condition, fix]
@model g() = x ~ Normal()
g_op = op1(g(), (; x = 1.0))
@model f() = a ~ to_submodel(g_op)
f_op = op2(f(), (@varname(a.x) => 2.0))
println("$op1 $op2 => $(f_op())")
end
end
The result (last tested on DynamicPPL 0.41):
condition condition => 2.0
condition fix => 2.0
fix condition => 1.0
fix fix => 2.0
For fixfix and concon, there's no issue because the values are merged in a way that respects the outer. (it's somewhere in getconditioned / getfixed I think)
For confix and fixcon, unfortunately, the logic in the codebase says that fixing always takes precedence over conditioning, because fix is in the first branch and condition is in the last branch
I discovered while writing tests for nested condition/fix. This was the test I had intended to add to test/submodel.jl.
@testset "precedence for conditioning/fixing the same variable twice" begin
# Check that the outermost conditioning takes precedence. I'm not sure
# if there is a strong a priori reason for this, but it is currently
# the case and thus this test just ensures that the behaviour doesn't
# suddenly change without it being a conscious decision to do so.
@testset "$op1,$op2" for op1 in [condition, fix], op2 in [condition, fix]
@model function f()
x ~ Normal()
end
fcond = op1(f(), (; x=1.0)) # this is ignored
@model function g()
return a ~ to_submodel(fcond)
end
gcond = op2(g(), (@varname(a.x) => 2.0)) # this takes precedence
@test gcond() == 2.0
end
end
How to solve?
Right now, conditioning and fixing go via what's now called CondFixContext. However, the conditioned values and fixed values are still stored in separate 'layers' of this.
The way to prevent this would be to 'flatten' the layers such that conditioned variables and fixed variables are part of the same VarNamedTuple. They would be held inside a VNT together with a flag that indicates whether it's conditioned or fixed. Thus instead of having a data structure that holds two VNTs, one conditioned and one fixed, we would only have one VNT that holds both.
We could then use templated_setindex_no_overwrite!! or something similar to issue an error when attempting to fix a variable that is already conditioned.
- Lenguaje dominante
- Julia
- Estrellas
- 291
- Forks
- 43
- Merge medio
- 1 d 23 h
- PR fusionados (30 d)
- 15
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de TuringLang/DynamicPPL.jl
-
Dificultad 4/5 3-5 días Aptitud para principiantes 64/100
TuringLang/DynamicPPL.jl#1499 ·
Los mantenedores suelen responder en 2 días
-
enhancement
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
TuringLang/DynamicPPL.jl#1480 ·
Los mantenedores suelen responder en 2 días
-
Separate model-evaluation inputs from outputsQuizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. Abiertodata-structures enhancement
Dificultad 5/5 Más de una semana Aptitud para principiantes 30/100
TuringLang/DynamicPPL.jl#1469 ·
Los mantenedores suelen responder en 2 días
-
enhancement
Dificultad 3/5 1-2 días Aptitud para principiantes 64/100
TuringLang/DynamicPPL.jl#1466 · 1 comentario ·
Los mantenedores suelen responder en 2 días
-
documentation
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
TuringLang/DynamicPPL.jl#1390 · 2 comentarios ·
Los mantenedores suelen responder en 2 días
Todos los issues de TuringLang/DynamicPPL.jl
Issues similares
-
Release CorleoneInverse as 0.1.1Posiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 78/100
SciML/Corleone.jl#200 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
JuliaAI/MLJTransforms.jl#120 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
exercism/julia#1205 · 3 comentarios · 1 reacción ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100
SciML/OrdinaryDiffEq.jl#5175 ·
Los mantenedores suelen responder en 1 día