Does/should ga call fitnessfcn with values that violate A*x <= b?

1 view (last 30 days)
I am using MATLAB R2012b with version 3.2.2 of the Global Optimization Toolbox. I observe that, during mixed-integer optimization, ga calls my fitness function with values that violate A*x <= b. This is a problem for me because values that violate A*x <= b cause my fitness function to crash.
Am I doing something wrong or is this expected behaviour? Are there any tips for handling input values that violate the problem's contstraints?
See below for more MATLAB input/output. With the listed input, I expect ans in the listed output to always be >= 0, but it is often negative???
code snippet...
function g = tuneController(obj)
A = Tuner.createA()
b = zeros(36, 1);
LB = zeros(1, 64);
LB(1:15) = -250;
LB(16:30) = -50;
LB(31:39) = -2;
LB(40:64) = 0;
UB = zeros(1, 64);
UB(1:15) = 1250;
UB(16:30) = 250;
UB(31:39) = 2;
UB(40:64) = 3;
g = ga(@(g)obj.calculateFitness(g, A, b), 64, A, b, [], [], LB, UB, [], [40:64]);
end
function fitness = calculateFitness(obj, g, A, b)
b - A * g'
end
output snippet...
ans =
1.0e+03 *
-1.2410
0.1948
0.7131
0.3577
-0.3159
-0.1104
0.4880
-0.3269
0.1240
0.1050
-0.4290
0.3231
0.7041
0.1274
0.1610
0.0407
-0.0990
-0.0148
0.0133
-0.0491
-0.1007
0.0686
0.0487
0.0917
0.0241
0.0468
0.1181
-0.1777

Answers (1)

Matt J
Matt J on 21 Jun 2014
Edited: Matt J on 21 Jun 2014
Seems inefficient for ga to call the fitness function on infeasible population members, but if it does, it does.
It should be possible to prevent your fitness function from "crashing", though. Test whether A*x<=b inside your fitness function before proceeding. If the constraints are violated, return Inf.

Products

Community Treasure Hunt

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

Start Hunting!