Is there any way in multi variable optimization toolbox/app, to prespecify that first k variables should be chosen in an ascending order (x(1)<=x(2)<=...<=x(k); and the rest x(k+1),...,x(n) should be random)?
For example, could I somehow set the current x(1) as x(2)'s lower bound?
I know I could add it to constraints later, but then I would waste too much CPU time, and if I start sorting the variables in the objective function (create a new variable x_sorted = sort(x) and use that variable instead) it would mess up the searching path of the optimization algorithm.
Every bit of help is appreciated. Thanks.

1 comentario

Damn I was so blind. It can be sorted with Linear Inequities.
If anyone needs it, here's a example:
n = 20; % Total number of variables
k1 = 5; % Starting point of variables u want to sort
k2 = 10; % End point of variables u want to sort
A = zeros(n,n);
b = zeros(n,1);
for j=k1:(k2-1)
A(j,j)=1;
A(j,j+1)=-1;
end
[x,fval] = ga(fitnessfcn,nvars,A,b);

Iniciar sesión para comentar.

 Respuesta aceptada

John D'Errico
John D'Errico el 10 de Jun. de 2016
Editada: John D'Errico el 10 de Jun. de 2016
Linear equality constraints suffice of course. Be careful, that the tolerance constraint will allow SLIGHT constraint violations. So you might want to set that difference to be some tiny positive minimum.
You can also ensure they are sorted if you transform the problem in your objective as
y(1) = cumsum(x);
where the vector x has lower bounds set at 0 (or some tiny positive number) for all but the first element. Then just use y as your variable.

1 comentario

Wow. That's a great way to code this in objective function, while retaining some info about the variable order (so it doesn't mess with the search path).
Thanks mate.
P.S. A way to keep it under upper bounds (assuming they are the same):
y = checksum(x)/sum(upper_bounds);

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Preguntada:

el 10 de Jun. de 2016

Comentada:

el 11 de Jun. de 2016

Community Treasure Hunt

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

Start Hunting!

Translated by