Appendix A. Matlab Code to Reproduce the Used Instances
function [c,A,b,equations]=ExampSag(n)
switch n
case 1 % Example 1, no feasible solution
c=[-1 -3 1]’; b=[-4 4 3 zeros(1,3)]’;
A=[-1 -1 -2; -1 0 1; 0 0 1; eye(3)]’;
case 2 % Example 2, unbounded solution
c=[1 4 0 -1]’; b=[-2 4 -4 2 0 0 0]’;
A=[1 -2 1 -1; 2 1 2 -2; -2 -1 -2 2; 1 0 -3 1; 1 0 0 0; 0 1 0 0; 0 0 0 1]’;
case 3 % Example 3, bounded solution
c=[-4 -2 -6]’; b=[-3 -2 -1 0 0]’;
A=[-1 0 -1; -1 -1 -1; -1 1 -2; 1 0 0; 0 -1 0]’;
case 4 % [Gill, Murray and Wright, 91, p. 381]
c=[1, 10]’; b=[3, 1, -2]’;
A=[1 5; 5 -1; -1 -1]’;
case 5 %simplicial case [Gill, Murray and Wright, 91, p. 345]
c=[1, 10]’; b=[2.5, -1, 1, -4.7, -10.2]’;
A=[4 1; 1 -1; -1 3; -1 -2; -5 -1]’;
case 6 % Cycle example with textbook rule [Gill, Murray and Wright, 91, p. 351]
c=[-2, -3, 1, 12]’; b=zeros(6,1);
A=[eye(4); 2 9 -1 -9; -1/3 -1 1/3 2]’;
case 7 % Myopic example [Gill, Murray and Wright, 91, p. 397]
c=[-1.2, -1]’; b=[-2.5, -1.4, 0, 0]’;
A=[-1.5 -1; -1 0; 1 0; 0 1]’;
case 8 % One restriction parallel and the other perpendicular to objective gradient
c=[1, 2]’; b=[4, 8]’;
A=[-2 1; 1 2]’;
case 9 % Problem KM02
c=[-1.2 -1.0]’; b=[-2.20 -3.25 -2.50 -1.40 0.00 0.00]’;
A=[2.2 -1.0; -1.5 -1.2; -1.5 -1.0; -1.0 0.0; 1.0 0.0; 0.0 1.0];
v=[A([5 6],:)\b([5 6]) A([4 6],:)\b([4 6]) …
A([3 4],:)\b([3 4]) A([1 3],:)\b([1 3]) A([1 5],:)\b([1 5])]’;
case 10 % Problem KM03
c=[-1.2 -1.0]’; b=[-2.50 -2.20 -3.25 -2.50 -1.40 0.00 0.00 -2.40]’;
A=[1.25 -1.00; 2.20 -1.00; -1.50 -1.20; -1.50 -1.00; …
-1.00 0.00; 1.00 0.00; 0.00 1.00; -1.20 -1.00];
v=[A([6 7],:)\b([6 7]) A([5 7],:)\b([5 7]) A([4 5],:)\b([4 5]) …
A([4 8],:)\b([4 8]) A([2 8],:)\b([2 8]) A([2 6],:)\b([2 6])]’;
case 11 % Problem LP4
c=[7 20 21 5]’; b=[-5 1 7 2 -2 14 2 -3]’;
A=[-5 -3 1 8; -1 4 2 0; 5 3 5 1; -1 4 6 1; …
5 0 6 1; 4 6 4 2; 0 1 0 0; 0 0 0 1]’;
case 12 % [Vanderbei, 97] page 234, exercise 14.2
c=-[7 -3 9 2]’; b=sparse([-1 -1 1 1 zeros(1,4)]’);
A=sparse([-1 -1 0 0; 0 0 -1 -1; 1 0 1 0; 0 1 0 1; eye(4)])’;
case 13 %Exponential example [Osborne, 85, p. 61], dual Klee-Minty [Nash and Sofer, 96, p. 270]
c=sparse([1 100 10000]’); b=sparse([zeros(1,3) 100 10 1]’);
A=sparse([speye(3); 1 20 200; 0 1 20; 0 0 1])’;
case 14 % Example degeneracy [Osborne, 85, p. 76]
A=sparse([1 0 0 1 1 1 1; 0 1 0 1/2 -1/2 -5/2 9; 0 0 1 1/2 -3/2 -1/2 1]);
b=sparse([0 0 0 -1 7 1 2])’; c=sparse([1 0 0])’;
case 15 % Example degeneracy [Chvatal, 83, p. 31];
A=sparse([1 0 0 1/2 -11/2 -5/2 9; 0 1 0 1/2 -3/2 -1/2 1; 0 0 1 1 0 0 0]);
b=sparse([0 0 0 10 -57 -9 -24])’; c=sparse([0 0 1])’;
case 16 % Example degeneracy [Nash and Sofer, 96, p. 136];
c=sparse([0 0 1]’); b=sparse([zeros(1,3) 3/4 -150 1/50 -6]’);
A=sparse([eye(3); 1/4 1/2 0; -60 -90 0; -1/25 -1/50 1; 9 3 0])’;
case 17 % [Vanderbei, 97] page 231, exercise 2.11
Aorig=sparse([ 1 1 1 0 0 0 -1 0; …
-1 0 0 1 1 0 0 0; …
0 -1 0 -1 0 1 0 0; …
0 0 1 0 1 1 0 1]);
borig=sparse([-1 -8 -9 -2 -7 -3 0 0]’);
corig=sparse([1 0 0 1]’);
p=colmmd(Aorig’); % p = 1 3 2 4
for k=1:size(Aorig,2), normas(k)=norm(Aorig(p,k)); end; normas
for k=1:size(Aorig,2)
priyults(:,k)=[min(find(Aorig(p,k)));max(find(Aorig(p,k)))];
end;
[foo,q]=sort(priyults(1,:));
A=Aorig(p,q); b=borig(q); c=corig(p); spy(A);
case 18 % criss-cross example [Zionts, 69, p. 430]
c=[-2 -4 1 3]’; b=[3 -4 zeros(1,4)]’;
A=[-1 -3 1 1; -2 -1 -1 1; eye(4)]’;
case 19 % Example 2/6-cycle, for EXPAND [Hall and McKinnon, 04, S2]
% for Dantzig rule unbounded
c=[0 0]’; b=[2.3 2.15 -13.55 -0.4 0 0]’;
A=[[0.4 0.2 -1.4 -0.2; -7.8 -1.4 7.8 0.4] eye(2)];
case 20 % Example 2/6-cycle, for EXPAND [Hall and McKinnon, 04, S2]
% for Dantzig rule bounded
c=[0 0 1 1]’; b=[2.3 2.15 -13.55 -0.4 0 0 0 0]’;
A=[[0.4 0.2 -1.4 -0.2; -7.8 -1.4 7.8 0.4; 1 0 0 0; 0 1 0 0] eye(4)];
case 21 % Example 2/6-cycle, for EXPAND: [Hall and McKinnon, 04, S4], infeasible
c=[0 0 1]’; b=[2.3 2.15 -13.55 -0.4 0 0 0]’;
A=[[0.4 0.2 -1.4 -0.2; -7.8 -1.4 7.8 0.4; 0 -20 156 8] eye(3)];
case 22 % Example 2/6-cycle, for EXPAND: [Hall y McKinnon, 04, S4], bounded
c=[0 0 1 1 1]’; b=[2.3 2.15 -13.55 -0.4 0 0 0 0 0]’;
A=[[0.4 0.2 -1.4 -0.2; -7.8 -1.4 7.8 0.4; 0 -20 156 8; …
1 0 0 0; 0 1 0 0] eye(5)];
case 23 % Example interior point challenge [Meszaros, 98, p. 8]
c=[1 2 3+1e-8]’; b=[0 0 0 -1]’;
A=[1 0 0 0; 0 1 1 0; 1 1 1+1e-8 1];
case 24 % Example interior point challenge [Meszaros, 98, p. 9]
c=[1e5 1e-5 2e-5]’; b=[0 0 -1]’;
A=[1 0 0; 1 -1 1; 1 -1 2];
case 25 % Example interior point challenge [Stojkovic and Stanimirovic, 01, p. 436]
c=[-9791 9789 -9790 -9790 9791 -9789 9789 -9872 -8790]’;
b=sparse([1 2 6 10 11 14 15 17 18 19 20],ones(1,11),…
[-8919 -5981 -9892 -3 -9800 -9989 -993 9978 -9687 -9993 9800],22,1);
A=[8919 -4788 -2 -9733 -3993 0 -1 -1 -9002 -9789 …
1 -3 -9971 1 -1 -1 -9978 9687 9993 -1 0 0; …
-8919 -4790 2 -9733 -3993 -2 1 1 -9002 9789 …
1 -3 -9971 4902 -1 1 9978 -9687 -9993 -1 0 0; …
8919 -1 -2 0 0 -2 -1 -1 0 9789 …
-1 0 0 4901 0 -1 -9978 9687 9993 1 0 0; …
0 -4788 -2 0 0 0 -1 -1 0 -9789 …
0 0 0 1 -1 -1 0 0 0 0 0 0; …
8919 -4789 2 9733 3993 0 1 1 9002 0 …
0 3 9971 1 -1 1 -9978 9687 9993 0 0 0; …
-8919 4789 -2 9733 3993 2 -1 -1 9002 0 …
1 3 9971 -4902 1 -1 9978 -9687 -9993 -1 0 0; …
0 4788 2 -9733 -3993 -2 1 1 -9002 9789 …
1 -3 -9971 4900 1 1 0 0 0 -1 0 0];
A=[sparse(A); sparse([1 1 2 2],[1 21 16 22],[-1 1 -1 1])];
case 26 % Example interior point challenge [Stojkovic and Stanimirovic, 01, p. 437]
c=[-9791 9789 -9790 -9790 9791 -9789 9782 -9872 -8790]’;
b=sparse([1 2 6 10 11 14 15 17 18 19 20],ones(1,11),…
[-8919 -5981 -9892 -3 -9800 -9989 -993 9978 -9687 -9993 9800],23,1);
A=[8919 -4788 -2 -9733 -3993 0 -1 -1 -9002 -9789 …
1 -3 -9971 1 -1 -1 -9978 9687 9993 -1 1 0 0; …
-8919 -4790 2 -9733 -3993 -2 1 1 -9002 9789 …
1 -3 -9971 4902 -1 1 9978 -9687 -9993 -1 0 0 0; …
8919 -1 -2 0 0 -2 -1 -1 0 9789 …
-1 0 0 4901 0 -1 -9978 9687 9993 1 0 0 0; …
0 -4788 -2 0 0 0 -1 -1 0 -9789 …
0 0 0 1 -1 -1 0 0 0 0 0 0 0; …
8919 -4789 2 9733 3993 0 1 1 9002 0 …
0 3 9971 1 -1 1 -9978 9687 9993 0 0 0 0; …
-8919 4789 -2 9733 3993 2 -1 -1 9002 0 …
1 3 9971 -4902 1 -1 9978 -9687 -9993 -1 0 0 0; …
0 4788 2 -9733 -3993 -2 1 1 -9002 9789 …
1 -3 -9971 4900 1 1 0 0 0 -1 0 0 0];
A=[sparse(A); sparse([1 1 2 2],[1 22 16 23],[-1 1 -1 1])];
case 27 %Instance with equations [Best and Ritter, 85, p. 231]
K = ones(20,1); F0=sparse(8,1); W=1;
F=sparse([1,3,4,6],1,[W,W,2*W,2*W],8,1); C=sparse(10,8,28);
C(:,1)=sparse([1,3,5,6,7],1,[-1/sqrt(65),7/sqrt(113),1,1/sqrt(65),…
5/sqrt(89)],10,1);
C(:,2)=sparse([1,3,6,7],1,[8/sqrt(65),8/sqrt(113),-8/sqrt(65),…
-8/sqrt(89)],10,1);
C(:,3)=sparse([6,8,10],1,[-1/sqrt(65),5/sqrt(89),1],10,1);
C(:,4)=sparse([6,8],1,[8/sqrt(65),8/sqrt(89)],10,1);
C(:,5)=sparse([7,9,10],1,[-5/sqrt(89),1/sqrt(65),-1],10,1);
C(:,6)=sparse([7,9],1,[8/sqrt(89),8/sqrt(65)],10,1);
C(:,7)=sparse([2,4,5,8,9],1,[-7/sqrt(113),1/sqrt(65),-1,-5/sqrt(89),…
-1/sqrt(65)],10,1);
C(:,8)=sparse([2,4,8,9],1,[8/sqrt(113),8/sqrt(65),-8/sqrt(89),…
-8/sqrt(65)],10,1);
N = sparse(0,0);
for k = 1:10
[p1,m1] = size(N); N = sparse([N zeros(p1,2); zeros(1,m1) [1 -1]]);
end;
c = sparse(11,1,1); A = [-C -N; F’ zeros(1,20)]; b = [F0;-K];
equations = logical(sparse(1:8,1,1,28,1)’);
case 28 %Experimental case for testing NNLS
A =[ 1 -2 3 1 0; 0 2 0 0 1; -1 6 5 -3 3; -1 -3 -5 2 -2; …
-2 -4 -4 2 -5; -3 -1 -2 1 2; 1 0 0 0 0; 0 0 1 0 0; …
0 0 0 1 0]’;
b =[ 2 1 -1 -4 -5 -1 0 0 0]’; c=[ -1 6 6 -3 2]’;
case 29 %Experimental case for testing NNLS
A =[ 1 -2 3 1 0; 0 2 0 0 1; -1 6 5 -3 3; -1 -3 -5 2 -2; …
-2 -4 -4 2 -5; -3 -1 -2 1 2; 1 0 0 0 0; 0 0 1 0 0; …
-3 -2 -7 1 -5]’;
b =[ 2 1 -1 -4 -5 -1 0 0 -7]’; c=[ -1 6 6 -3 2]’;
case 30 % Example for IMAJNA
A=[-1 0 0 0 0 -1; 0 1 0 -1 0 0; 1 0 -1 0 0 0 ; 0 1 0 -1 0 1; …
0 0 0 0 1 1 ; 1 0 0 0 0 2 ; 0 0 -1 -1 0 0; 0 1 0 3 0 0 ]’;
b=[-7 -1 3 -1 -1 6 7 -6]’; c=[5 0 -2 1 0 4]’;
case 31 % Example for IMAJNA
A=[ 1 0 0 0.5 0 1; 0 1 0 -1 0 0; 1 0 -1 0 0 0 ; 0 1 0 -1 0 1; …
0 0 0 0 1 1 ; 1 0 0 0 0 2 ; 0 0 -1 -1 0 0; 0 1 0 3 0 0 ]’;
b=[-7 -1 3 -1 -1 6 7 -16]’; c=[5 0 -2 1 0 4]’;
case 32 % [Chvatal, 1983, pp. 180--181]
b = sparse([139 88 133 137 165 zeros(1,6) zeros(1,15)]’);
c = sparse([420 415 355 345 160 95 380 395 270 230 310 420 5200 5200 …
3600 0]’);
filas = [1*ones(1,5) 2*ones(1,5) 3*ones(1,5) …
4*ones(1,6) 5*ones(1,6) 6*ones(1,6) 7*ones(1,6) 8*ones(1,6) …
9*ones(1,4) 10*ones(1,5) 11*ones(1,5) 12*ones(1,5) …
13*ones(1,5) 14*ones(1,5) 15*ones(1,5) 16*ones(1,10)];
columnas = [1:5 1:5 1:5 [1:5 6] [1:5 7] [1:5 8] [1:5 9] [1:5 10] …
[1:3 11] 1:5 1:5 1:5 [1 4 5 6 7] [1 4 5 8 9] [1 4 5 10 11] 2:11];
valores = [1.4 1.8 1.5 1.4 1.4 9.8 2.4 1.4 1.4 1.4 4.0 0.4 1.4 1.4 1.4 …
2.8 0.6 1.3 1.4 1.5 5.5 2.2 0.4 1.3 1.5 1.2 5.5 2.2 0.4 1.3 1.3 1.2 5.5 …
2.2 0.6 1.3 1.3 1.2 5.5 2.6 5.8 1.5 1.5 1.2 5.5 0.6 4.0 1.3 5.5 …
0.6 1.2 1.3 1.3 2.6 0.6 1.8 1.2 1.2 1.2 0.6 1.8 1.5 1.4 1.4 …
16 12 35 50 50 20 36 50 50 50 16 12 35 50 50 …
0.1 0.9 0.8 2.3 -ones(1,6)];
A = sparse(filas,columnas,valores,16,26);
A(1:15,12:26)=speye(15);
case 33 %testing NNLS
c = [0.1 0 0.1 0 -1]’; b=zeros(8,1);
A = [1 -2 1 0 -1 -2 1 0; 0 1 -2 1 0 -1 -2 1; 0 0 1 -2 0 0 -1 -2; …
0 0 0 1 0 0 0 -1; 0 -1 0 -3 0 -24 -4 -128];
otherwise
disp(’unknown instance’); c=[]; A=[]; b=[];
end;
function [c,A,b]=AndSchSp(n)
% Returns sparse diet problem of size n [Andrus and Schaferkotter, 1996]
%
c = -(2:3:3*n-1)’; b = [ones(n,1); -2*ones(n,1)];
A = sparse([],[],[],n,n); A(n,n)=2;
for i=1:n-1, A(i,i)=2; A(i,i+1)=1; end; A = [A’ -A’];
% Testing recipe for TomLab v3.0
clear all; global L ACT NAC A b c;
% [c,A,b]=AndSchSp(1000); TomLab cannot solve it!!
[c,A,b]=AndSchSp(25); A=sparse(A); b=sparse(b); c=sparse(c);
Prob = lpAssign(-b,A,c,c,sparse(size(A,2),1)); Prob.SolveAlg = 2;
rkeyk=zeros(size(A,2),1); tic; Result = lpSolve(Prob);
ACT=find(Result.x_k)’; NAC=setdiff(1:size(A,2),ACT); R=qr(A(:,ACT),0);
dkoxk=A(:,ACT)*(R\(R’\b(ACT)));
dkoxk=dkoxk + A(:,ACT)*(R\(R’\(b(ACT)-A(:,ACT)’*dkoxk)));
rkeyk(ACT)=Result.x_k(ACT); rkeyk(NAC)=A(:,NAC)’*dkoxk-b(NAC);
k=Result.Iter; toc, k, full(c’*dkoxk), min(rkeyk(ACT)), min(rkeyk(NAC))
function [c,A,b]=ChPaSaSp(m,n,dens)
%Generates sparse random problems [Chen, Pardalos and Saunders, 94, S6]
%
A = sprandn(n,m,dens,1);
for k = 1:size(A,1)
denom = norm(A(k,:),2);
if denom > eps
A(k,:) = A(k,:)/denom;
else
error(’Row of A too small in size’);
end;
end;
b = sparse(randi(m),1,1,m,1); c = sparse(n,1); c(:) = 1;
function [c,A,b]=ClauseSp(n,mode)
% To generate sparse problems as those of [Clausen, 1979]
%
if nargin < 2, mode = 0; end;
alfa = 4/5; beta = 5/4; gama = 5; A = speye(n);
for k=1:n-1, A = A + diag(2*beta^k*ones(n-k,1),-k); end;
if rem(mode,2)
b = sparse([alfa .^ (1:n)’;zeros(n,1)]);
% Errata in [Murty, 1983, p. 437]: chaning sign b of interest
if mode > 1, b = -b; end;
c = sparse([gama .^ (0:n-1)’]); A = [A speye(n)];
else
c = -sparse(alfa .^ (1:n)’);
% Errata in [Murty, 1983, p. 437]: changing sign c not interesting
if mode > 1, c = -c; end;
b = -sparse([gama .^ (0:n-1)’;zeros(n,1)]);
A = [-A; speye(n)]’;
end;
function [c,A,b,s]=GoldfaSp(n,beta,delta,a)
%Generates extreme case of Golfarb with n variables, sparse
%
if nargin < 1
n = 3; beta = 3; delta = 7; a = 0;
elseif nargin < 2
beta = 3; delta = 7; a = 0;
elseif nargin < 3
delta = floor(2*beta+1); a = 0;
elseif nargin < 4
a = 0;
end;
if (n <= 2) | (beta < 2) | (delta <= 2*beta) | (a-floor(a)~=0) | (a < 0) | (a > 2^n-1)
return;
end;
% As an example, for beta = 3 and delta = 7 we get:
% c=-[0 21 8]; b=[0; 0; 0; -1; -7; -49];
% A=[1 0 0; -3 1 0; 1 -3 1; -1 0 0; -3 -1 0; 1 -3 -1];
c = sparse([],[],[],n,1); A = [speye(n); -speye(n)];
b = sparse([],[],[],2*n,1); b(n+1,1)=-1;
for i=2:n
A(i,i-1)=-beta; A(i+n,i-1)=-beta; b(n+i,1)=b(n+i-1,1)*delta;
if i > 2, A(i,i-2)=1; A(i+n,i-2)=1; end;
end;
a2=zeros(1,n); for i=n:-1:1, a2(i)=rem(a,2); a=floor(a/2); end;
alfa(1)=1; alfa(2)=beta; a2=a2-(~a2);
for i=3:n+1
alfa(i)=beta*alfa(i-1)+a2(i-2)*alfa(i-2);
end;
c(n-1,1)=-alfa(n+1); c(n,1)=a2(n)*alfa(n);
if nargout > 3
for j=0:2^n-1
k=j; k2=zeros(1,n); for i=n:-1:1, k2(i)=rem(k,2); k=floor(k/2); end;
for i=1:n
if rem(sum(k2(i:n)),2)==0, d2(i)=0; else, d2(i)=1; end;
end;
d2=fliplr(d2); s(j+1)=polyval(d2,2);
end;
end;
A=A’;
function [c,A,b]=KleMinSp(n,base,mode)
%Generates sparse variants of Klee-Minty, cf. [Floudas and Pardalos, 2001, pp. 193--199]
%
A=speye(n);
if abs(mode)<3
c=sparse(ones(n,1));
else
c=sparse(base.^(2*((1:n)’-1)));
end;
for i=1:n
A(i,1:i-1)=A(i,1:i-1)+2*base.^(i-(1:i-1));
end;
if mode > 0,
b=sparse([base.^(n-(1:n)) zeros(1,n)]’); A=[A speye(n)];
else
b=sparse([zeros(1,n) base.^(n-(1:n))]’); A=[speye(n) A];
end;
if rem(abs(mode),2)==0
p=[1:2:(2*n-1) 2:2:2*n]; A(:,p)=A; b(p)=b;
end;
function [c,A,b]=KuhQuaSp(n,dens)
%Generates Kuhn-Quandt sparse problem [Chvatal, 83, p. 46]
%
if nargin < 2, dens = 1e-5; end;
N = round(1000*sprand(n,n,dens,1/20));
while sprank(N)~=n, N = round(1000*sprand(n,n,dens,1/20)); end;
A = [N speye(n)]; c = sparse(n,1); c(:) = 1e4; b = sparse(2*n,1); b(1:n) = 1;
function [c,A,b]=Powell(m)
%Returns a dense 2D problem with m constraints, challenge for interior point
%
c = [0 1]’; b = -ones(m,1); A = [cos((1:m)*2*pi/m); sin((1:m)*2*pi/m)];