When the genetic algorithm has integer constraint issues, how to customize the variogram to eliminate the ignored warning

Use the genetic algorithm to solve the single target minimum and the optimal solution of three variables, where two variables are real numbers and one variable is an integer, in order to improve the genetic algorithm, the taboo search algorithm is used to make the custom variogram of the mutation operator, but the runtime appears, warning: Problem has integer constraints. The following options will be ignored by GA:MutationFcn.Therefore, many different functions still cannot solve this warning.
How to solve this mixed integer problem? If I don't define integer intcon in options, do I need to redefine selection, crossing, variogram? Or do you only need to constrain the variable integer in the variogram

 Accepted Answer

I am not sure what you mean by "variogram." But I think that I know the reason for your difficulty. As the Release Notes state, until R2021b the genetic algorithm did not allow custom mutation or crossover functions in integer-constrained problems. If you want to use custom mutation or crossover functions, upgrade to R2021b or later.
Alan Weiss
MATLAB mathematical toolbox documentation

8 Comments

In custom mutants, I use tabu search algorithm to mutate, but option structure ga cannot run custom mutants, because there is intcon constraint in the structure, so there is a warning: problem has integers, the mutants myfun will be ignored. However, after deleting intcon and using round constraint on the variable, the calculation result is not ideal, perhaps because of the problem of custom variation function. Ask the experts how to solve it. Will an upgrade to 2022b fix it?
I cannot say whether your tabu search will be effective or not, but the ga solver in R2022b allows any custom mutation function.
Since you have just one integer variable, would it be possible for you to simply scan a range of integer values and use a different, faster solver such as fmincon for the other two variables? You might also need to start from a variety of initial points for fmincon to achieve a global solution, but it still might be faster and more reliable than using ga. And if your objective is nonsmooth, you could use patternsearch instead of ga for the 2-variable minimization. That should still be faster and more reliable than ga.
Alan Weiss
MATLAB mathematical toolbox documentation
lb=[0.0002 0.0002 5] ub[0.001 0.002 19] Could you please tell me how to use two solvers to solve real variables and integer variables respectively? Could you please give me a code example? Thank you very much for your answer
OK, suppose that your variable has intcon = 3, meaning the third component must be integer-valued. Suppose that your bounds are
lb = [-3,-4,1];
ub = [4,5,10];
My objective function of three variables is at the end of this script.
Run the fmincon solver from four random initial points in 2-D for each value of the integer variable going from 1 to 10;
val = nan(4,10);
sol = nan(40,2);
opts = optimoptions('fmincon','Display','none');
for j = 1:10
invar = j;
for i = 1:4
x0 = lb(1:2) + rand(1,2).*( ub(1:2) - lb(1:2)); % random point in 2-D
[xx,val(i,j)] = fmincon(@(x)myfun(x,invar),x0,[],[],[],[],lb(1:2),ub(1:2),[],opts);
sol(4*(j-1)+i,:) = xx;
end
end
themin = min(min(val))
themin = -1.0316
Look at the val matrix to see the other values fmincon found for the various start points. Look in the corresponding sol for the solution point.
function f = myfun(x,invar)
t = [x,invar]; % Change to your original 3-variable objective
f = (4*t(1)^2 - 2.1*t(1)^4 + t(1)^6/3 + t(1)*t(2) - 4*t(2)^2 + 4*t(2)^4)/t(3); % arbitrary example function
end
Alan Weiss
MATLAB mathematical toolbox documentation
My pleasure. If you believe I helped, please Accept my answer.
Alan Weiss
MATLAB mathematical toolbox documentation
I have a difficulty too for the same problem. My optimization problem has 'integer design variable' and 'linear/nonlinear inequality constraint'. I have to modify the crossover and mutation function referring to the default two operation functions, i.e., crossoverlaplace and mutationpower.
Then, can I open the function files 'crossoverlaplace' and 'mutationpower' exist after R2021b?
As the Release Notes for R2021b state, you can (but do not have to) give alternate crossover and mutation functions for the genetic algorithm. Because you have integer variables, I suggest that you use the mutationgaussian mutation function.
Alan Weiss
MATLAB mathematical toolbox documentation

Sign in to comment.

More Answers (0)

Products

Release

R2019b

Community Treasure Hunt

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

Start Hunting!