Math operations on NLparameter

I am trying to write a NLexpression

sum(alpha^j/prod(i for i=1:max(0,j)) for j=0:floor(C))

where C is NLparameter. I am getting following

MethodError: no method matching floor(::JuMP.NonlinearParameter)
Closest candidates are:
  floor(!Matched::Type{BigInt}, !Matched::BigFloat) at mpfr.jl:151
  floor(!Matched::Float64) at float.jl:216
  floor(!Matched::Float32) at float.jl:217
  ...
 in macro expansion; at /home/deepak/.julia/v0.5/JuMP/src/parseExpr_staged.jl:489 [inlined]
 in macro expansion; at /home/deepak/.julia/v0.5/JuMP/src/parsenlp.jl:225 [inlined]
 in macro expansion; at /home/deepak/.julia/v0.5/JuMP/src/macros.jl:1187 [inlined]
 in anonymous at ./<missing>:?
 in include_string(::String, ::String) at ./loading.jl:441
 in include_string(::String, ::String, ::Int64) at /home/deepak/.julia/v0.5/CodeTools/src/eval.jl:28
 in include_string(::Module, ::String, ::String, ::Int64, ::Vararg{Int64,N}) at /home/deepak/.julia/v0.5/CodeTools/src/eval.jl:32
 in (::Atom.##55#58{String,Int64,String})() at /home/deepak/.julia/v0.5/Atom/src/eval.jl:40
 in withpath(::Atom.##55#58{String,Int64,String}, ::String) at /home/deepak/.julia/v0.5/CodeTools/src/utils.jl:30
 in withpath(::Function, ::String) at /home/deepak/.julia/v0.5/Atom/src/eval.jl:46
 in macro expansion at /home/deepak/.julia/v0.5/Atom/src/eval.jl:57 [inlined]
 in (::Atom.##54#57{String,Int64,String})() at ./task.jl:60

looks like I cannot do floor operation on NLparameter. I can pass this parameter as a julia parameter. But I am trying to modify this problem with different parameter and run it multiple times. Is there a way I can modify C multiple times and solve my optimization model without creating it from scratch?

No, parameters can only appear in the same place as variables, and variables cannot be used to define index sets.

1 Like

I am not trying to define index sets using variables. C is NLparameter. Can’t I do floor operation on that? Since C is just a parameter I should be able to use floor operations on that right?

The floor operation isn’t the relevant part here. You cannot define index sets using variables or parameters. 0:floor(C) is an index set. A better error message wouldn’t hurt (PRs accepted).

1 Like

Oh ok. Got it. Thank you.