You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using a NLExpr in the definition of another NLExpr does not seem to work correctly all the time.
I've tried to define an expression $v(x)^TAv(x)$, where $v$ is a nonlinear vector field in $x$ and $A$ is a matrix. In the example below, you can see that the evaluation of the functions f2 and f3 are different, while I expect it to be the same.
using JuMP
n =2
x0 = [2.25, 2.4]
β = [-20.15; 0.23-2.1]
Σ = [0.020.007; 0.0070.014]
x0 = [1.5, 2.0]
m =Model()
@defVar(m, x[i=1:n] >=0, start=x0[i])
@defNLExpr(f1[i=1:n], prod{x[j]^β[j,i], j =1:n})
@defNLExpr(f2, sum{Σ[i,j]*f1[i]*f1[j], i=1:n, j=1:n}) # bug@defNLExpr(f3, sum{Σ[i,j]*prod{x[k]^β[k,i], k =1:n}*prod{x[k]^β[k,j], k =1:n}, i=1:n, j=1:n})
println(getValue(f2))
println(getValue(f3))
Output:
0.00217861198424964660.008103475980157478
The text was updated successfully, but these errors were encountered:
anriseth
changed the title
incorrect parsing of NLExpressions
Incorrect parsing/evaluation of NLExpressions
Sep 14, 2015
Looks like there's a scoping issue. The j in f1 is the same symbol as the j in f2. Definitely a bug, but the easy workaround is to use a different indexing variable in f1.
Using a NLExpr in the definition of another NLExpr does not seem to work correctly all the time.$v(x)^TAv(x)$ , where $v$ is a nonlinear vector field in $x$ and $A$ is a matrix. In the example below, you can see that the evaluation of the functions f2 and f3 are different, while I expect it to be the same.
I've tried to define an expression
Output:
The text was updated successfully, but these errors were encountered: