Here is a simple example of a much larger program. I want to use an index "m", which ranges from say 0 to 5, and for each value of m do a minimization.
The program works fine if I insert a specific value of m, but won't work if I allow m to range.
> I guess I was supposed to put the m range at the end rather than the beginning.
...and add "m" as second argument of function y. Keep in mind that in this case because of the way minimize works the order of the arguments matters.
Its always a good idea to write the solve block for a single scalar, then turn it into a function of that value and later call it with a range, or, even better and more reliable, with a vector as argument (you may need vectorization),