Error Nonlinear expressions may contain only scalar expressions

 countBM=6
 model= Model()
 @variable(model,x[ i in 1:30])
 BendMom=Array{Any}(undef,countBM)
 zz=@NLexpression(model,[ i in 1:30],x[i]+i)
 BendMom[1]=@NLexpression(model,zz+1)
julia>  BendMom[1]=@NLexpression(model,zz+1)
ERROR: Unexpected array NonlinearExpression["Reference to nonlinear expression #1", "Reference to nonlinear expression #2", "Reference to nonlinear expression #3", "Reference to nonlinear expression #4", "Reference to nonlinear expression #5", "Reference to nonlinear expression #6", "Reference to nonlinear expression #7", "Reference to nonlinear expression #8", "Reference to nonlinear expression #9", "Reference to nonlinear expression #10", "Reference to nonlinear expression #11", "Reference to nonlinear expression #12", "Reference to nonlinear expression #13", "Reference to nonlinear expression #14", "Reference to nonlinear expression #15", "Reference to nonlinear expression #16", "Reference to nonlinear expression #17", "Reference to nonlinear expression #18", "Reference to nonlinear expression #19", "Reference to nonlinear expression #20", "Reference to nonlinear expression #21", "Reference to nonlinear expression #22", "Reference to nonlinear expression #23", "Reference to nonlinear expression #24", "Reference to nonlinear expression #25", "Reference to nonlinear expression #26", "Reference to nonlinear expression #27", "Reference to nonlinear expression #28", "Reference to nonlinear expression #29", "Reference to nonlinear expression #30"] in nonlinear expression. Nonlinear expressions may contain only scalar expressions.

Your zz is a vector so you have to consider the elements one by one:

BendMom[1]=@NLexpression(model,[ i in 1:30], zz[i]+1)

Explanation: Nonlinear Modeling · JuMP

1 Like