fminsearch + objective function with variable input arguments
Mostra commenti meno recenti
Hello,
I am relatively new to MATLAB and this is actually my first question, so I thank everyone in advance who takes the time to answer.
I am developing an optimization algorithm which can solve a specific problem using a variable amount of optimization parameters. The idea is to run an objective function multiple times with an increasing number of parameters so that in the end I can evaluate the optimization results vs the complexity (number of parameters).
I would like to know if is there a way of generating a handle to the objective function with a variable amount of parameters. Right now I am using a very inelegant approach like:
switch numberParameters
case 1
hObjectiveFunction = @(paramOpt) objectiveFunction(paramOpt(1));
case 2
hObjectiveFunction = @(paramOpt) objectiveFunction(paramOpt(1),...
paramOpt(2));
case i
hObjectiveFunction = @(paramOpt) objectiveFunction(paramOpt(1),...
paramOpt(2),...
...
paramOpt(i));
end
fminsearchbnd(hObjectiveFunction, x0)
As you can see this is very bothersome as I would need to explicitly write the number of optimization parameters that I would like to have.
Does anyone have any idea how to do it in a more elegant way, without having to code all the options?
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Function Creation in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!