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 Kommentar

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);

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

John D'Errico
John D'Errico am 10 Jun. 2016
Bearbeitet: John D'Errico am 10 Jun. 2016

0 Stimmen

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 Kommentar

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);

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Community Treasure Hunt

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

Start Hunting!

Translated by