How do I debug this error message: INTLINPROG stopped because some objective or constraint matrix coefficients are too large in magnitude.

INTLINPROG stopped because some objective or constraint matrix coefficients are too large in magnitude.
Error in [x,fval,exitflag,output] = intlinprog(f,intcon,Aineq, bineq, Aeq, beq,lb,ub);

5 Comments

% Build AAmatrix
% mixed integer program for P and Q with each power having increasing loadability
Nbranches=size(BranchData,1);
C=sparse([[1:Nbranches]';[1:Nbranches]'],[BranchData(:,1);BranchData(:,2)], [ones(Nbranches,1);-ones(Nbranches,1)]);
C=Cbar;
Gens=size(GenData,1);
Nodes=size(C,1);
Cg=sparse(zeros(Nodes,Gens));
Cg(GenData(:,1),[1:Gens]')=speye(Gens,Gens);
B=sparse(diag(1./BranchData(:,4)));
U0=0.9;
U1=(U0)^2;
B1=U0*B;
B2=U1*B;
G=sparse(diag(1./BranchData(:,3)));
G1=-U0*G;
G2=U1*G;
Vars=1+2*Gens+Nnodes+4*Nbranches+1;
SpMatZBrNode=sparse(zeros(Nbranches,Nnodes));
SpMatZNodeBr=sparse(zeros(Nnodes,Nbranches));
SpMatZBrBr=sparse(zeros(Nbranches,Nbranches));
% SpMatZBrBr=sparse(zeros(Nnodes,Nnodes));
SpMatZNodeNode=sparse(zeros(Nnodes,Nnodes));
Pd=zeros(Nnodes,1);
%Pd(LoadData(:,1))=LoadData(:,2);
qd=zeros(Nnodes,1);
%qd(LoadData(:,1))=LoadData(:,3);
A11=[-Pd, Cg, -C, sparse(zeros(Nnodes,Gens)),SpMatZNodeBr,SpMatZNodeNode,SpMatZNodeBr,SpMatZNodeBr,zeros(Nnodes,1)];
A12=[-qd, sparse(zeros(Nnodes,Gens)),SpMatZNodeBr, Cg, -C, SpMatZNodeNode,SpMatZNodeBr,SpMatZNodeBr,zeros(Nnodes,1)];
Aeq=[A11;A12];
beq=zeros(2*Nodes,1);
A23=[zeros(Nbranches,1), zeros(Nbranches,Gens),-speye(Nbranches, Nbranches),zeros(Nbranches,Gens),SpMatZBrBr,SpMatZBrNode, SpMatZBrBr,-sparse(diag(pmax)), zeros(Nbranches,1)];
A24=[zeros(Nbranches,1), zeros(Nbranches,Gens), speye(Nbranches, Nbranches),zeros(Nbranches,Gens),SpMatZBrBr,SpMatZBrNode, SpMatZBrBr,-sparse(diag(pmax)), zeros(Nbranches,1)];
A25=[zeros(Nbranches,1), zeros(Nbranches,Gens), speye(Nbranches, Nbranches),zeros(Nbranches,Gens),SpMatZBrBr,G1*Cbar',-B2,sparse(diag(M)),zeros(Nbranches,1)];
A26=[zeros(Nbranches,1), zeros(Nbranches,Gens), -speye(Nbranches, Nbranches),zeros(Nbranches,Gens),SpMatZBrBr,-G1*Cbar',B2,sparse(diag(M)),zeros(Nbranches,1)];
A27=[zeros(Nbranches,1), zeros(Nbranches,Gens), SpMatZBrBr,zeros(Nbranches,Gens),-speye(Nbranches,Nbranches),SpMatZBrNode,SpMatZBrBr,-sparse(diag(pmax)), zeros(Nbranches,1)];
A28=[zeros(Nbranches,1), zeros(Nbranches,Gens), SpMatZBrBr,zeros(Nbranches,Gens),speye(Nbranches, Nbranches),SpMatZBrNode,SpMatZBrBr,-sparse(diag(pmax)), zeros(Nbranches,1)];
A29=[zeros(Nbranches,1), zeros(Nbranches,Gens), SpMatZBrBr,zeros(Nbranches,Gens),speye(Nbranches,Nbranches),-B1*Cbar',-G2,sparse(diag(M)),zeros(Nbranches,1)];
A30=[zeros(Nbranches,1), zeros(Nbranches,Gens), SpMatZBrBr,zeros(Nbranches,Gens),-speye(Nbranches,Nbranches),B1*Cbar',G2,sparse(diag(M)),zeros(Nbranches,1)];
A31=[zeros(Nbranches,1), zeros(Nbranches,Gens), speye(Nbranches, Nbranches),zeros(Nbranches,Gens),SpMatZBrBr,SpMatZBrNode,SpMatZBrBr, SpMatZBrBr,-pmax];
Aineq=[A23;A24;A25;A26;A27;A28;A29;A30;A31];
bineq=[zeros(2*Nbranches,1);M;M;zeros(2*Nbranches,1);M;M;zeros(Nbranches,1)];
% b=[Pbar;zeros(3*Nbranches,1);M;M;zeros(Nbranches,1)];
f = zeros(size(Aeq,2),1)';
f(:,1)=-1;
intcon=[1+Gens+Nbranches+Gens+Nbranches+Nnodes+Nbranches+1;4*Nbranches+Nnodes+2*Gens+1];
lb = [1 (GenData(:,2)'/NomP) -pmax' (GenData(:,4)'/NomP) -qmax' 0.9*ones(1,Nnodes) (-pi/6)*ones(1,Nbranches) zeros(1,Nbranches) 0]';
ub = [1 (GenData(:,3)'/NomP) pmax' (GenData(:,5)'/NomP) qmax' 1.1*ones(1,Nnodes) (pi/6)*ones(1,Nbranches) ones(1,Nbranches) 0]';
[x,fval,exitflag,output] = intlinprog(f,intcon,Aineq, bineq, Aeq, beq,lb,ub);
delta = x(1:Nbranches);
p = x(Nbranches+1:2*Nbranches);
theta=x(2*Nbranches+1:2*Nbranches+Nnodes);
xint=x(2*Nbranches+Nnodes+1:3*Nbranches+Nnodes);
y=x(3*Nbranches+Nnodes+1);
Please attach enough code and data that we can reproduce the error. At the very least we need BranchData
DATA
Column 1 Sending end node
% Column 2 Receiving end node
% Column 3 pu Resistance
% Column 4 pu Reactance
% Column 5 pu half line susceptance
% Nominal Power
NomP=100;
BranchData=[ ...
1 2 0.01938 0.05917 0.0264 157.38 17.48 180 314;
1 5 0.05403 0.22304 0.0246 75.51 7.98 125 314;
2 3 0.04699 0.19797 0.0219 73.40 5.94 96 314;
2 4 0.05811 0.17632 0.0170 55.94 2.94 125 314;
2 5 0.05695 0.17388 0.0173 41.73 4.74 110 314;
3 4 0.06701 0.17103 0.0064 23.14 7.75 125 314;
4 5 0.01335 0.04211 0.0 59.59 11.57 105 314;
4 7 0.0 0.20912 0.0 27.07 15.40 115 314;
4 9 0.0 0.55618 0.0 15.46 2.64 92 314;
5 6 0.0 0.25202 0.0 45.89 20.84 105 314;
6 11 0.09498 0.19890 0.0 8.29 8.90 78 314;
6 12 0.12291 0.25581 0.0 8.06 3.18 92 314;
6 13 0.06615 0.13027 0.0 18.34 9.98 92 314;
7 8 0.0 0.17615 0.0 0.00 20.30 92 314;
7 9 0.0 0.11001 0.0 27.07 14.80 92 314;
9 10 0.03181 0.08450 0.0 4.39 0.90 92 314;
9 14 0.12711 0.27038 0.0 8.64 0.32 92 314;
10 11 0.08205 0.19207 0.0 4.61 6.72 72 314;
12 13 0.22092 0.19988 0.0 1.88 1.41 72 314;
13 14 0.17093 0.34802 0.0 6.46 5.08 72 314];
Nbranches=size(BranchData,1);
BusData =[...
1 1 1.00 0 232 0 0 0 0 0;
2 2 1.045 0 40 42.4 21.7 12.7 -40 50;
3 2 1.010 0 0 23.4 94.2 19.0 0 40;
4 3 1.01 0 0 0 47.8 -3.9 0 0;
5 3 1.0 0 0 0 7.6 1.6 0 0;
6 2 1.070 0 0 12.2 11.2 7.5 -6 24;
7 3 1.0 0 0 0 0.0 0.0 0 0;
8 2 1.090 0 0 17.4 0.0 0.0 -6 24;
9 3 1.01 0 0 0 29.5 16.6 0 0;
10 3 1.0 0 0 0 9.0 5.8 0 0;
11 3 1.0 0 0 0 3.5 1.8 0 0;
12 3 1.0 0 0 0 6.1 1.6 0 0;
13 3 1.0 0 0 0 13.5 5.8 0 0;
14 3 1.0 0 0 0 14.9 5.0 0 0];
Nnodes = size(BusData,1);
%%%% Load parameters
% First column = Load bus number
% Second column = Load active power
% third colum = Load reactive power
LoadData = [ ...
9 29.5 16.6;
7 0 0.0;
6 12.2 11.2;
10 9.0 5.8;
4 47.8 -3.9;
8 17.4 0.0;
5 7.6 1.6];
%%% Generator parameters
% First column = generator bus number
% Second column = Minimum generator active power
% Third column = Maximum generator active power
% Fourth column = Min. generator reactive power
% Fifth column = Max. generator reactive power
GenData =[ ...
1 0 232 0 0;
2 40 42.4 -40 50;
3 23.4 94.2 0 40;
6 11.2 12.2 -6 24;
8 6 17.2 -6 24];
B = 1./BranchData(:,4);
Pg=BusData(:,5)/NomP;
Pl=BusData(:,7)/NomP;
P=Pg-Pl;
pmax=BranchData(:,8)/NomP;
% BuildCmat
send=BranchData(:,1);
rec=BranchData(:,2);
res=BranchData(:,3);
reac=BranchData(:,4);
% B = 1./BranchData(:,5);
% p = BranchData(:,6);
% q =BranchData(:,7);
pmax=BranchData(:,8);
% qmax=BranchData(:,9);
M =BranchData(:,10)/NomP;
% P =BusData(:,4);
Nnodes=max(max(rec),max(send));
Nbranches=size(send,1);
Cmat=sparse(zeros(Nbranches,Nnodes));
for br=1:Nbranches
Cmat(br,send(br))=1;
Cmat(br,rec(br))=-1;
end
Cmat=Cmat';
Cbar=Cmat(2:Nnodes,:);
Pbar=P(2:Nnodes,:);
Nnodes=Nnodes-1;
full(Cmat);
%incorporating program for P and Q with each power having increasing loadability lamda
Nbranches=size(BranchData,1);
C=sparse([[1:Nbranches]';[1:Nbranches]'],[BranchData(:,1);BranchData(:,2)], [ones(Nbranches,1);-ones(Nbranches,1)]);
C=Cbar;
Gens=size(GenData,1);
Nnodes=size(C,1);
Cg=sparse(zeros(Nnodes,Gens));
Cg(GenData(:,1),[1:Gens]')=speye(Gens,Gens);
Your BranchData matrix has 9 columns, but this line refers to a 10th,
Index in position 2 exceeds array bounds (must not exceed 9).
Error in test (line 80)
M =BranchData(:,10)/NomP;

Sign in to comment.

 Accepted Answer

The error message has told you that the input coefficient data f, Aineq, bineq, etc... to intlinprog have values that are too large. Have you checked what those values are?
>>max(abs(f(:))), max(abs(Aineq(:))), etc...
I'm guessing they may be Infs.
In any case, you almost certainly have a bug in the creation of f, Aineq, etc..., and you almost certainly have to be the one to fix it, because only you can know what the real input should be for this application.

8 Comments

Thanks Matt J.
Obviously, the problem is in; [x,fval,exitflag,output] = intlinprog(f,intcon,Aineq, bineq, Aeq, beq,lb,ub) but I don't really know how to fix it.
I am not too good in MATLAB, is there anyway I may further be helped?
Regards,
Yes, you could fix the line
M =BranchData(:,10)/NomP;
and tell us what the repair was, so that we can execute the code to see what is happening.
Great ...,
M =BranchData(:,10)/NomP is M =BranchData(:,9)/NomP.
I ran it in the sequence below ;
>> DATA
>> BuildCmat
>> BuildMatAA
... but still have same error as
Error using intlinprog (line 142)
INTLINPROG stopped because some objective or constraint matrix coefficients are too large in magnitude.
Error in BuildMatAA (line 107)
[x,fval,exitflag,output] = intlinprog(f,intcon,Aineq, bineq, Aeq, beq,lb,ub);
Regards,
Your posted first script (I guess that must be BuildMatAA) refers to qmax, which is not defined in the other code you have posted.
You had a commented out line,
% qmax=BranchData(:,9);
which is right before the problem line
M =BranchData(:,10)/NomP;
which you now say should be
M =BranchData(:,9)/NomP;
but that makes it unlikely that we should just uncomment the qmax line, as it is not obvious that the two should just be scaled values of each other.
Have you considered attaching your current code as files... after, that is, clearing your workspace and running the code to verify that you are indeed reaching the intlinprog line.
Hi Walter,
Thanks for the continuous assistance.
I carried out your suggestions to the extent of my MATLAB capabilities and used qmax=BusData(:,10)/NomP;
>> DATA
>> BuildCmat
>> BuildMatAA
below is the error messages I got...
Warning: Length of lower bounds is < length(x); filling in missing lower bounds with -Inf.
> In checkbounds (line 33)
In optim.algorithm.checkBoundConstraints
In optim.algorithm.IntlinprogBranchAndCut/checkProblem
In optim.algorithm.GeneralizedLinear/checkRun
In intlinprog (line 131)
In BuildMatAA (line 107)
Warning: Length of upper bounds is < length(x); filling in missing upper bounds with +Inf.
> In checkbounds (line 47)
In optim.algorithm.checkBoundConstraints
In optim.algorithm.IntlinprogBranchAndCut/checkProblem
In optim.algorithm.GeneralizedLinear/checkRun
In intlinprog (line 131)
In BuildMatAA (line 107)
Error using intlinprog (line 142)
INTLINPROG stopped because some objective or constraint matrix coefficients are too large in magnitude.
Error in BuildMatAA (line 107)
[x,fval,exitflag,output] = intlinprog(f,intcon,Aineq, bineq, Aeq, beq,lb,ub);
You have
G=sparse(diag(1./BranchData(:,3)));
Some of thos BranchData(:,3) entries are 0, so you are getting inf entries in G. That is leading to +inf and -inf in Aineq and then when you multiply those by x you get +inf.
Thanks so much,
I adjusted (in bold) the 0 entries in BranchData for the G=sparse(diag(1./BranchData(:,3))) to ...
|From | To | R | X | B/2 | p | q | S | M |
|Bus | Bus | pu | pu | pu | MW | Mvar| MVA | |
BranchData=[ ...
1 2 0.01938 0.05917 0.0264 157.38 17.48 180 314;
1 5 0.05403 0.22304 0.0246 75.51 7.98 125 314;
2 3 0.04699 0.19797 0.0219 73.40 5.94 96 314;
2 4 0.05811 0.17632 0.0170 55.94 2.94 125 314;
2 5 0.05695 0.17388 0.0173 41.73 4.74 110 314;
3 4 0.06701 0.17103 0.0064 23.14 7.75 125 314;
4 5 0.01335 0.04211 0.0 59.59 11.57 105 314;
4 7 0.01 0.20912 0.0 27.07 15.40 115 314;
4 9 0.011 0.55618 0.0 15.46 2.64 92 314;
5 6 0.001 0.25202 0.0 45.89 20.84 105 314;
6 11 0.09498 0.19890 0.0 8.29 8.90 78 314;
6 12 0.12291 0.25581 0.0 8.06 3.18 92 314;
6 13 0.06615 0.13027 0.0 18.34 9.98 92 314;
7 8 0.0101 0.17615 0.0 0.00 20.30 92 314;
7 9 0.0011 0.11001 0.0 27.07 14.80 92 314;
9 10 0.03181 0.08450 0.0 4.39 0.90 92 314;
9 14 0.12711 0.27038 0.0 8.64 0.32 92 314;
10 11 0.08205 0.19207 0.0 4.61 6.72 72 314;
12 13 0.22092 0.19988 0.0 1.88 1.41 72 314;
13 14 0.17093 0.34802 0.0 6.46 5.08 72 314];
And I got this error message after running:
>> DATA
>> BuildCmat
>> BuildMatAA
Warning: Length of lower bounds is < length(x); filling in missing lower bounds with -Inf.
> In checkbounds (line 33)
In optim.algorithm.checkBoundConstraints
In optim.algorithm.IntlinprogBranchAndCut/checkProblem
In optim.algorithm.GeneralizedLinear/checkRun
In intlinprog (line 131)
In BuildMatAA (line 107)
Warning: Length of upper bounds is < length(x); filling in missing upper bounds with +Inf.
> In checkbounds (line 47)
In optim.algorithm.checkBoundConstraints
In optim.algorithm.IntlinprogBranchAndCut/checkProblem
In optim.algorithm.GeneralizedLinear/checkRun
In intlinprog (line 131)
In BuildMatAA (line 107)
No feasible solution found.
Intlinprog stopped because no point satisfies the constraints.
Index exceeds array bounds.
Error in BuildMatAA (line 109)
delta = x(1:Nbranches);
Now I am more confused... Please help!!!
Is it correct that your task is to maximize x(1) subject to a whole series of constraints ?
The Index exceeds array bounds is because intlinprog returns empty when there is no solution, but your code assumes that a non-empty result will be returned.
You should fix the lb and ub, especially considering that your second integer constraint at variable #104 is in the section you have not defined a lower bound and upper bound for.

Sign in to comment.

More Answers (0)

Categories

Community Treasure Hunt

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

Start Hunting!