Closed lileicc closed 10 years ago
@lileicc @cberzan
Fully support Case Expression. I remove Clause. Instead, I add distribSpec and caseSpec. Now every expression becomes an ArgSpec. IfExpr and CaseExpr will be translated to caseSpec.
Also, for caseSpec, I force that all the possible branches of case expression to return a distribSpec.
I have tested on Hurricane, Burglary and tugwar
Also, I tested the following example:
fixed Integer f(Integer x) = if x>1 then 1 else 2; random Integer X ~ UniformInt(1,3); random Integer Y ~ UniformInt(5,6); random Integer Z ~ UniformInt(X,Y);
query f(X); query Z;
LGTM! :+1: Very good. Perhaps the best one can do within the time limit.
will merge after the new-distrib-interface merged.
@jxwuyi
example/general-fixed-fun.blog
doesnot work!
Please fix!
@jxwuyi There is a major bug! The way you are using cpd setParams is incorrect!
random Real x ~ UniformReal(1, 2);
random Real y ~Gaussian(0, 1);
random Real z ~ Gaussian(x, 1);
random Real a ~ Gaussian(1, x);
random Real b ~ Gaussian(y, x);
All these should work. Please see doc in CondProbDistrib.
for example, in Gaussian,
setParam(Object[] params)
should take Object[2].
always two parameters. at construction time, the fixed value will be passed, the rest will be null. At sampling time, random values will be passed, the rest will be null.
Line 231 - 286 in DistribSpec is implemented incorrectly!
@jxwuyi Pointed out that the error was due to FuncCallExpr. I tested example/hurricane-new.blog It works under the new case-expression.
I will merge this one. then create a new issue for FuncCallExpr.
Support the semantic translation of case expression (the syntax for case is already supported)
195