سؤال

i have my objective function as

function val = fitness( X )
val = 10*X(7)+20*X(8)+50*X(9)+10*X(10)+20*X(11)+50*X(12);
end

and i am trying to call ga as

ga(@fitness,12,A,b,[],[],lb,[],[],IntCon)
A = 9X9 matrix
b = 9X1 matrix
lb = 9X1 Zero matrix  
IntCon = [1:12]

i am getting the following error message

Error using preProcessLinearConstr (line 48)
The number of columns in A must be the same as the length of X0.

Error in gacommon (line 100)
[Iterate.x,Aineq,bineq,Aeq,beq,lb,ub,msg,exitFlag] = ...

Error in ga (line 319)
[x,fval,exitFlag,output,population,scores,FitnessFcn,nvars,Aineq,bineq,Aeq,beq,lb,ub,

please provide an example using ga function solving mixed integer problem.

هل كانت مفيدة؟

المحلول

The issue is that Ab is of size 9x1, while fitness() expects the size to be at least 12x1.

E.g. the following has no error:

A = ones(12,12);
b = ones(12,1);
lb = zeros(12,1); 
IntCon = [1:12];
ga(@fitness,12,A,b,[],[],lb,[],[],IntCon)

For more information, see Mixed Integer Optimization.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top