MATLAB: In genetic Algorithms optimization. Optimization terminated: average change in the penalty fitness value less than options.TolFun but constraints are not satisfied.

genetic algorithmslarge-scale optimization

I have 799 decisions {0,1} that need to be optimized to maximize (OVWDL). When a maintenance decision is taken (x=1), a treatment cost is allocated to the total cost. My constraint is to find the best combination of decisions that keep the total costs within my budget. I use the following code:
function OVWDL=dl_max(x)
load('2018Optim-Region-2-Conditio-2017-one_mile')
DL_T=DL_I+x.*DL_inc-(DL_dec-x.*DL_dec);
cost_T=sum(x.*cost);
OVWDL=-sum(DL_T.*Lseg)/sum(Lseg);
end
function [c, ceq] = mybudget(x)
load('2018Optim-Region-2-Conditio-2017-one_mile')
B=4580000; %My budget
cost_T=sum(x.*cost);
c=cost_T-B;
ceq=[];
end
load('2018Optim-Region-2-Conditio-2017-one_mile')
FitnessFunction=@dl_max;
ConstraintFunction=@mybudget;
n = length(Lseg);
LB=zeros(1,n);
UB=ones(1,n);
integers=linspace(1,n,n);
[x,fval]=ga(FitnessFunction,n,[],[],[],[],LB,UB,ConstraintFunction,integers);
When I apply this code on a small data size, it works. But for the 799 cases, it violates the constraint and the total costs exceed the budget limit. Could anyone help me how to enhance the prediction ability of this model?

Best Answer

Both your cost function and constraints are linear. You would probably get more reliable results from intlinprog. At the very least, if you are going to use GA, you should avoid using the nonlinear constraint inputs unless your constraints really are nonlinear.
Related Question