Loop for minimizing functions with a varying number of arguments

I get ERROR: MethodError: no method matching -(::Array{Float64,1}, ::Int64) .

Then look for the line (it should be indicated in your stacktrace) where that error come from. There’s probabably a v - 1 that should be v .- 1 for some v::Vector.

Yes… The number of arguments changes at each iteration. The number of arguments is indicated by k .

Does it need to be that way though? I still don’t understand why you can’t just have a function of a single vector and have the length of that vector change in each iteration? This will likely be a lot more efficient than writing a function of 50 variables (in terms of compile time, runtime and writing time).

5 Likes