Is it possible to use mixed integer ga optimization on octave?

My MATLAB code is below. You can use for H = [11 12 13 14] and for des = 200.

At octave, I’m unable to set the intcon ( Integer variables, specified as a vector of positive integers taking values from 1 to nvars . Each value in IntCon represents an x component that is integer-valued.)

function [x,fval]=Pmaq(H,des)

fun=@(x)otFobjetiveME(x,H);%objective function handle
%lb=[25,25,25,25,0,0,0,0]; %lower bound
if H(3)==0
    lb=[25,25,25,25,0,0,0,0];
    ub=[75,75,75,75,1,1,0,0];%upper bound
else
    lb=[25,25,25,25,0,0,0,0];
    ub=[75,75,75,75,1,1,1,1];
end

intcon=[5 6 7 8]; %index of integer variable
nvar=length(lb);%problem dimension
nonlcon=@(x)nonlconInt(x,des); %nonlinear constraint function
%% Start with the default options
options = optimoptions('ga');
PopulationSize_Data=5*10^4;
CrossoverFraction_Data=0.6;
FunctionTolerance_Data=1e-15;
ConstraintTolerance_Data=1e-15;
InitialPenalty_Data=10;
PenaltyFactor_Data=1000;


%% Modify options setting
options = optimoptions(options,'PopulationSize', PopulationSize_Data);
options = optimoptions(options,'CrossoverFraction', CrossoverFraction_Data);
options = optimoptions(options,'StallTest', 'geometricweighted');
options = optimoptions(options,'FunctionTolerance', FunctionTolerance_Data);
options = optimoptions(options,'ConstraintTolerance', ConstraintTolerance_Data);
options = optimoptions(options,'InitialPenalty', InitialPenalty_Data);
options = optimoptions(options,'PenaltyFactor', PenaltyFactor_Data);
options = optimoptions(options,'CreationFcn', @gacreationuniform);
options = optimoptions(options,'CrossoverFcn', @crossoverscattered);
options = optimoptions(options,'MutationFcn', {  @mutationuniform 0.5 });
options = optimoptions(options,'Display', 'off');
%solver
[x,fval]=ga(fun,nvar,[],[],[],[],lb,ub,nonlcon,intcon,options);

Did you take a look at the ga-package?

How do otFobjetiveME and nonlconInt look like?

In case of a linear program, you can use of the glpk-function to mark a variable as “continuous” or “integer”.

otFobjetiveME.m (585 Bytes)
nonlconInt.m (229 Bytes)

Thank you for showing the function. To my knowledge there is no “feature complete” replacement for the Matlab Genetic Algorithm toolbox available for Octave :thinking:

As your objective and constraint functions are non-linear, you must adapt your code to existing non-linear solvers in Octave and match to integer solutions yourself…