Dimension error with genetic algorithm optimization variable
Show older comments
Hello, I am trying to solve a nonlinear constrained integer problem from a paper from Daniels & Carillo (1997) on beta-robust scheduling. I failed to use a BNB method as I couldn't get it to work for a matrix input.

C = jobmeans(:,1); % 10x1 vector
v = jobvars(:,1); % 10x1 vector
Aeq = [ones(length(C),length(C))]; %10x10 matrix
beq = [ones(1,length(C))]; %1x10 vector
lb = zeros(length(C),length(C)); %10x10 matrix
ub = ones(length(C),length(C)); %10x10 matrix
T = 220;
fun = @(x)(-(T-C'*((n(1)+1-[1:n(1)])*x')')/sqrt(v'*((n(1)+1-[1:n(1)]).^2*x')'));
intcon = 100;
x = ga(fun,100,[],[],Aeq,beq,lb,ub,[],intcon);
I want to optimize for a n(1) x n(1) = 10x10 integer matrix. If I define the amount of optimization variables (nvars) to be 100, Matlab states that the number of columns in Aeq (10) is not the same as the length of x0. If I set nvars = 10 without intcon = 10 I only get 1x10 non-integer vector x, and with intcon = 10 I do not get a solution. The output of the 'fun' function for a test matrix of x = rand(10,10) is a scalar result so I'm not sure what the issue could be here.
How can I get the solver to solve for a 10x10 integer matrix?
The Matlab error is
Error using preProcessLinearConstr (line 71)
The number of columns in Aeq must be the same as the length of X0.
Error in gacommon (line 97)
[Iterate.x,Aineq,bineq,Aeq,beq,lb,ub,msg,exitFlag] = preProcessLinearConstr( ...
Error in ga (line 363)
NonconFcn,options,Iterate,type] = gacommon(nvars,fun,Aineq,bineq,Aeq,beq,lb,ub, ...
Error in BRSP (line 78)
x = ga(fun,100,[],[],Aeq,beq,lb,ub,[],100);
Accepted Answer
More Answers (1)
Quinten Rademakers
on 2 Mar 2021
0 votes
Categories
Find more on Genetic Algorithm in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!