ubc-stat-ml / blangdsl Goto Github PK
View Code? Open in Web Editor NEWBlang core (parsing, generation, eclipse plug-in)
Home Page: https://www.stat.ubc.ca/~bouchard/blang/
License: BSD 2-Clause "Simplified" License
Blang core (parsing, generation, eclipse plug-in)
Home Page: https://www.stat.ubc.ca/~bouchard/blang/
License: BSD 2-Clause "Simplified" License
Some configs on access rule seem to be in the gitignore but should be committed
This could become confusing as e.g. someList.size
is allowed in most of the language, while it would create an error in the for loop bounds.
It looks like there is currently both .pom files and .gradle files. We should stick to one to make things easier to maintain.
Consider code of the form
model {
param T1 p
laws {
x | T2 y = f(p) ~ Dist(y)
}
def static T2 f(T1 input) { .. }
}
Here the issue is that p is actually compiled to type Supplier<T1>
so the expression f(p)
cannot be translated directly.
Note: this should probably be resolved jointly with Issue #1
The following is not allowed by the grammar but should be:
model {
random Real y
laws {
y ~ Normal(0, 1)
}
}
Similarly for
model {
random Real y
param Real test
param Real test2
laws {
y | Real t1 = test, Real t2 = test2 ~ Normal(t1, t2)
}
}
The empty model:
model {
}
produces
import blang.core.Model;
@SuppressWarnings("all")
public class MyFile implements Model {
}
which does not compile because it does not override abstract method components().
Will take forever to debug otherwise
Hook up and improve/simplify blang2/bayonet's system.
Maybe something like:
random Real mu
and
random Real mu = RealScalar(3)
Should have options to configure model as well as mcmc samplers.
Does not work because of type erasure. Instead, pass in Parameter object
for (type var : iterator)
rather than for(type var = value; test; increment)
Basic instructions in a README.md would be great. Topics to include initially:
?:
syntaxCall and cache the value of component()
?
The following runs fine in unit test execution but not in child eclipse:
model {
random Object test
laws {
logf(test) = { 1.0 + 1.0 }
}
}
but weirdly, the following works in both:
model {
random Object test
laws {
logf(test) = { 1.0 }
}
}
Conjecture: It seems that +,-,*,..
do not work somehow in child eclipse.
Test for example:
Realistically, this should be a two-step process:
The processing architecture should support this evolution.
Note that point 2 involves a lot of parts:
Should be easy to hook up blang2/bayonet infratructure.
Example in MarkovChain, but it can be also a log or support factor:
laws {
for (int t = 0; t < states.size(); t++) {
states.get(t + 1) | Int prev = states.get(t), calculator, t
~ Categorical(calculator.transitionsProbabilities(t).get(prev))
}
}
Having to include [..]
and .doubleValue
is distracting
Use the following recursive structure both for Default
and InitVia
(and generally, to work around limitations around type permitted in annotations):
static annotation WithArg {
String key = ""
String value
WithArg [] children = #[]
}
static annotation Instantiator {
Class<?> type
WithArg [] arguments = #[]
}
static annotation InitViaInstantiator {
Instantiator value
}
@InitViaInstantiator(
@Instantiator(
type = OneArgConstructor,
arguments = #[
@WithArg(key = "type", value = "java.lang.String"),
@WithArg(key = "parser", value = "inits.strategies.parsers.StringParser")
]
)
)
static class MyClass {
new(String test) {}
}
Currently, the right-hand side of the support factor spec is an XBlockExpression
, which has to be surrounded by curly braces. It would be nice if a single expression, like variance > 0
could be given like that instead of { variance > 0 }
.
Some files in ca.ubc.stat.blang.tests
, eg BlangDslParsingTest
are marked as generated. I am wrong to think this warning should be removed?
E.g. in the tests of simpleNormalModel:
y | Real mean = mu ~ Normal(mean, [mean.doubleValue ** 2])
This is needed for variable accessions, e.g.
y.get(i) ~ Normal ..
For example, some of the recursive behavior can be pulled out of the loop, no comments, etc.
The current value generated is inSupport
but should be isInSupport
Instead of code templates, we could create or modify the AST programmatically, i.e. use something like that:
https://www.eclipse.org/forums/index.php/t/502128/
The gist is to use: XbaseFactory
Can reuse some of the stuff in blang2/bayonet but improvements are required in terms of automation, handling false positive rate adaptively, etc.
In the grammar, params for Distribution/LogScaleFactor/SupportFactor are of the form
'(' (param += Param) ( ',' param += Param)* ')'
which I think imply at least one param is needed. As some of them may have zero arguments, I suppose the alternative would be something like
'(' (
')' |
( param += Param) ( ',' param += Param)* ')' )
)
In BlangDslJvmModelInferrer
when large to medium models are parsed, expression of the form model.vars.findFirst[name == p]
are likely to become a computational bottleneck. This could be addressed by first going over the variables to create a hashtable lookup, and then using that hashtable.
Would be easy I think. Just base it on the for loop construct.
Instead of maintaining one repo for SDK development, and one for blang project template (currently, blangProjectTemplate), use a script that strips the former to create the latter. Will make it easier to maintain.
I can't seem to use typeRef
at this point in the code to get a nice management of referenced classes (using imports, etc.). Until this is done, I have to generate adding the components with typeRef(...).identifier
, which works fine, but inserts the fully-qualified name even when that same class also exists in the imports list.
for (val ..
vs for (..
could get confusing for the user
Both for eclipse and in the command line (to be split into two issues if needed)
Currently disabled as it was not working if not in the default package.
It would be nice for users to be able to just add Blang from the Eclipse marketplace, instead of having to clone the blangDSL project and run it in child Eclipse.
It could be done with an Eclipse update site, docs
E.g., with
param Real m,v
param List<Real> means
laws{
for (int i : 0..<2) {
means.get(i) | m, v ~ Normal(m, v)
}
}
the generated methods for handling m
are:
private static Object $generated__2(final Real m, final Real v) {
return m;
}
private static Supplier<Object> $generated__2_lazy(final Supplier<Real> $generated__m, final Supplier<Real> $generated__v) {
return () -> $generated__2($generated__m.get(), $generated__v.get());
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.