How to set a fixed step for lower and upper bounds (lb,ub) in particle swarm optimization?

21 visualizzazioni (ultimi 30 giorni)
Dear All:
I am trying to particle swarm to optimize a function. I would ask you how to set a fixed step for lower and upper bounds (lb, ub), let's say: 0:0.5.5 (i.e., a step of 0.5 from lb to up). My script is a follows:
nvars=3;
lb=[0,0,0]; ub=[5,5,5];
options=optimoptions('particleswarm','SwarmSize',100,'HybridFcn',@fmincon);
[x,fval,exitflag,output]=particleswarm(objfun,nvars,lb,ub,options);
Thank you very much for your help.
Best regards,

Risposta accettata

Alan Weiss
Alan Weiss il 22 Lug 2020
I am not sure that I understand you. I think that you mean that you have discrete variables, you would like your solution to be from a discrete set, where each component of the solution is an integer multiple of 1/2. If this is true, then both particleswarm and fmincon are inappropriate solvers, as they cannot deal with discrete variables.
It also seems to me as if you have just three variables, and you have about 10 distinct values possible for each variable (0, 0.5, 1, 1.5,..,4.5, 5). In that case I think that you would do best by simply performing a complete search over the 10^3 possible solutions; that is not very many at all.
If I misunderstand, feel free to clarify.
Alan Weiss
MATLAB mathematical toolbox documentation
  1 Commento
Son
Son il 22 Lug 2020
Thank you very much for your prompt reponse. Yes, because I used particleswarm and fmincon for searching (with contious values). But, it is very time-consuming, when I have more three variables. That's why I would use decrete (integer) values with a fixed step to search from lower to upper bounds. However, I cann't input such a fixed step in the particleswarm. I am very much appreciated if you drop me a solution for that.
Best,

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by