Originally posted by: emmyl
I know someone has a similar post before. I checked, but it didn't seem to apply to my case.
I am trying to a mixed integer quadratic programming problem with linear objective function and quadratic constraints. Here is how I construct the cplex class. I do not post the part on creating each individual matrix.
cplex = Cplex('saa_mip_2d');
cplex.Model.sense = 'maximize';
A=[Aineq;Aeq];
cplex.Model.A=A;
lhs=[repmat(-inf,size(Aineq,1),1);beq];
cplex.Model.lhs=lhs;
rhs=[bineq;beq];
cplex.Model.rhs=rhs;
cplex.Model.obj=f';
ctype=blanks(ncol);
ctype(1:2)='C';
ctype(3:ncol)='B';
cplex.Model.ctype=ctype;
%adding quadratic constraints
Q=blkdiag(n*pvec(1)*pvec(2)*ones(2,2),zeros(ncol-2));
pprod=2*sqrt(n*pvec(1)*pvec(2))*sqrt(pvec);
amat=repmat(pprod,m,1).*epsilon;
for j=1:m
a=zeros(1,ncol);
a(4+m+j)=M3;
a(1:2)=amat(j,:);
cplex.Model.qc(j).a=a';
cplex.Model.qc(j).Q=Q;
end
cplex.solve
I have checked the size of each matrix. I have 304 variables.
size of A is 508 by 304
size of rhs and lhs is 508 by 1
size of f' is 304 by 1
ctype is a string of length 304
size of a' is 304 by 1
size of Q is 304 by 304.
When I run cplex.solve, I keep getting the same message "CPLEX encountered arrays with inconsistent lengths."
Anybody has a hint of what goes wrong here?
#CPLEXOptimizers#DecisionOptimization