MATLAB genetic algorithm integer optimization toolbox returns values higher than boundaries and doesn't satisfy inequality constraints. Why?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
I'm using MATLAB R2016a genetic algorithm optimization toolbox to optimize 80 integer values. I have these constraints:
x(80) > x(79) > x(78) > x(77) > x(76) ... x(5) > x(4) > x(3) > x(2) > x(1)
The range for all integer variables is between 1 and 500. I used this code in MATLAB:
f = @(x)Cost_function(x, my_data);
num_of_var = 80;
for mx = 1:num_of_var-1
A(mx,:) = [zeros(1,mx-1),1,-1, zeros(1,num_of_var-mx-1)];
end
b = repmat(-3, [num_of_var-1,1]);
lb = ones([num_of_var-1,1]);
up = repmat(500,[num_of_var-1,1]);
options = optimoptions('ga');
options.Display = 'iter';
options.PopulationSize = 200;
options.UseParallel = 0;
IntCon = 1:1:num_of_var;
[x, fval, exitflag] = ga(f, num_of_var, A, b, [], [], lb, up,[] ,IntCon, options);
Is this code correct? In some cases this code returns integer higher than boundaries. For example this is first return of this code for cost function:
11 89 129 136 168 191 208 232 267 299 306 312 312 270 270 293 297 296 283 192 188 239 241 239 226 212 212 301 275 231 221 210 179 182 200 224 227 258 270 264 225 204 183 199 202 236 305 310 313 276 272 259 256 336 329 310 303 303 296 289 275 235 233 232 194 196 203 268 294 313 340 336 333 263 260 257 265 275 409 174964160
Otherwise this output structure doesn't satisfy my mentioned constraints. why?
2 Kommentare
Antworten (1)
Alan Weiss
am 22 Mai 2016
I would give a feasible point for starting. Something like
x0 = 2:2:160;
options.InitialPopulationMatrix = x0;
It is possible that you don't have any feasible points, and the solver gets stuck in the infeasible region.
Alan Weiss
MATLAB mathematical toolbox documentation
2 Kommentare
Alan Weiss
am 23 Mai 2016
I am not sure that I understand you. ga is population-based, and unless you have a population of just one member, the vector you gave is not a complete population.
Your population should consist of entirely feasible members when using the @gacreationlinearfeasible creation function. Is that your creation function? If it is, then if you have an infeasible population then your linear constraints are not set up properly. Please check what you get when you take your A matrix and multiply it by a solution to see whether it satisfies A*x <= b.
Sorry, I don't have any other ideas right now.
Alan Weiss
MATLAB mathematical toolbox documentation
Siehe auch
Kategorien
Mehr zu Genetic Algorithm finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!