I need to optimize a problem with variable number of arguments. The problem is something like that: I have a function $F$, now the function F takes input of position $(x_0,y_0)$, generates three output: two position coordinate $x_1, y_1$ and a cost function $C_1$.
That is, in MATLAB, I can make a function $[C_1, x_1, y_1] = F(x_0,y_0)$;
now the output coordinate goes to the same function again to generate second cost, $C_2$ and I need to keep adding $C_1 + C_2$ and so on until I get a desired cost $C_{opt} = C_1 + C_2 + .....$ . So my variables for this optimization problem is also variable, I don't know how many times I need to calculate the function $F$ before the optimization starts and the total number of variables is also not known.
How can I solve this problem. Any insight to address this problem will be welcomed. I just need some clue to start this. I would like to use Particle Swarm Optimization problem with MATLAB.
Thanks in advance. Khalid