Dot product in GUSEK/GLPK - ampl

I've been trying to do a dot product in GUSEK. I used the explicit expression to compute it :
sum{i in 1..n} v[i]*x[i]
Is there a lighter notation I could use?

GUSEK uses GNU MathProg language which is based on a subset of AMPL and AFAIK it doesn't have any special notation for vectors. So I don't think you can further simplify this expression.

Related

normal cdf and pdf functions in Pyomo

I am working on a mathematical model in pyomo. There are parameters that are based on a normal distribution. The input for these distributions is not a simple numerical number, but it's another parameter that is defined in pyomo.
I imported the Statistics package to use normal distribution but I get this error:
Cannot convert non-constant Pyomo expression (0 < s) to bool.
This error is usually caused by using a Var, unit, or mutable Param in a
Boolean context such as an "if" statement, or when checking container
membership or equality.
I found the answer. I share it here for others if they had the same question.
I think the easiest approach is working with python (Numpy ), generating whatever you want, then assigning it to pyomo objects. I tried this and it worked very well.

How can I represent probabilistic grammars in BNF?

I've found a grammar online which I want to rewrite to BNF so I can use it in a grammatical evolution experiment. From what I've read online BNF is given by this form:
<symbol> := <expression> | <term>
...but I don't see where probabilities factor into it.
In a probabilistic context-free grammar (PCFG), every production also is assigned a probability. How you choose to write this probability is up to you; I don't know of a standard notation.
Generally, the probabilities are learned rather than assigned, so the representation issue doesn't come up; the system is given a normal CFG as well as a large corpus with corresponding parse trees, and it derives probabilities by analysing the parse trees.
Note that PCFGs are usually ambiguous. Probabilities are not used to decide whether a sentence is in the language but rather which parse is correct, so with an unambiguous grammar, the probabilities would be of little use.

Is the Pearson correlation coefficient a suitable objective function for quadratic programming solvers?

Is the Pearson correlation coefficient -- with one vector, x, exogenous and another vector, y, as a choice variable -- a suitable quadratic objective function for quadratic programming solvers like Gurobi?
A quick Google search for "Gurobi objective function" shows that Gurobi has an API to set an objective function that accepts a linear or quadratic expression. That is quite expected because quadratic programming is, by definition, an optimization of a quadratic function, with the math behind the methods specifically designed for this class (like, working directly with the Q coefficient matrix and the c vector rather than the raw function).
I didn't look into details too much, but I can see that Pearson product-moment correlation coefficient appears to be not a quadratic but a rational function. So, if your specific case can't be simplified to that, no.
I cannot say anything about other solvers because each one is an independent product and has to be considered separately.
Since your function appears to be piecewise continuous and infinitely differentiable, you're probably interested in general-purpose gradient methods instead.

Custom linear operators in ViennaCL

Is is possible to pass custom linear operators (like CUSP's http://cusplibrary.github.io/classcusp_1_1linear__operator.html) to ViennaCL's solvers?
Thanks.
Yes, it is possible for iterative solvers. An example can be found in
examples/tutorial/matrix-free.cpp or here:
http://viennacl.sourceforge.net/doc/matrix-free_8cpp-example.html

Write in SWRL a mathematical expression to calculate probability distributions

I am new on Semantic Web Rules Language and I am writing some rules in order to calculate the probability of - discrete and continuous - distributions.
I know that with SWRL I can do subtractions, addition, multiplication and divisions.
But what about exponentiation, summation, calculation of mathematical functions? Is there a way to do this in SWRL?
Just an example to place my question :
You know, for example, for Triangular distribution, we need basic mathematical calculus (subtractions and divisions), but for Beta Distribution we need exponentiation and calculus of the beta function..
Is there a way to do this in SWRL?
Thanks
The standard describes what math functions should be available, and these include exponentiation:
8.2. Math Built-Ins
…
swrlb:pow
Satisfied iff the first argument is equal to the result of the second argument raised to the third argument power.
There's no built in for the Beta function, though. You'd need to look into the reasoner that you're using and see whether you can implement additional mathematical builtins.
summation, calculation of mathematical functions
For summations, you may find the aggregate functions in SPARQL useful, but only if the terms you need to sum are available individually. You won't easily be able to express arbitrary sums like &Sum;i=1…n i2. You might find support for extension functions in SPARQL implementations, too.