0001 function [prob]=alselftest(testID)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 prob = [];
0014
0015
0016
0017 tests = [
0018 {'pennlp','../../problems/ampl-nl/cosine.nl', 'datafiles/pennlp_cosine.dcf', 'big & unconstrained'}
0019 {'pennlp', '../../problems/ampl-nl/chain100.nl', 'datafiles/pennlp_chain100_a.dcf', '100 LIN eq + 1 NLN eq, no box (==> no penalties)'}
0020 {'pennlp', '../../problems/ampl-nl/israel.nl', 'datafiles/pennlp_israel_a.dcf', 'box + LIN ineq only (no equal)'}
0021 {'pennlp', '../../problems/ampl-nl/seba.nl', 'datafiles/pennlp_seba.dcf', 'box + LIN ineq & eq'}
0022 {'pennlp', '../../problems/ampl-nl/camshape100.nl', 'datafiles/pennlp_camshape100_a.dcf', 'NLN ineq + LIN eq + BOX'}
0023
0024 {'pensdp', 'datafiles/truss1.dat-s', 'datafiles/pensdpa_truss1.dcf', 'very small matrices, no inequalities'}
0025 {'pensdp', 'datafiles/theta1.dat-s', 'datafiles/pensdpa_theta1.dcf', 'one bigger matrix, no inequalitites'}
0026 {'pensdp', 'datafiles/control1.dat-s', 'datafiles/pensdpa_control1.dcf', 'two bigger matrices'}
0027 {'pensdp', 'datafiles/arch0.dat-s', 'datafiles/pensdpa_arch0.dcf', 'one matrix & set of inequalitites'}
0028 {'pensdp', 'datafiles/truss1b.dat-s', 'datafiles/pensdpa_truss1b.dcf', 'very small matrices, one inequality'}
0029 ];
0030
0031 testno=size(tests,1);
0032
0033 if (nargin==0)
0034 testID=[1:testno];
0035 else
0036 testID=intersect(testID,[1:testno]);
0037 end
0038
0039 for i=testID
0040 prob = runtest(i,tests{i,:});
0041 end
0042 end
0043
0044
0045 function [prob] = runtest(ID, type, input1, input2, comment)
0046
0047 [fdir,fname,fext] = fileparts(input1);
0048 disp(sprintf('* Test %2i - %s: %s, %s',ID,type,fname,comment));
0049
0050 if (strcmpi(type,'pennlp') || strcmpi(type,'nlp'))
0051
0052 penm=nlp_define(input1);
0053 prob=penlab(penm);
0054 [alx,aldx,alddx] = setuptestpoint(prob,input2,type);
0055
0056 elseif (strcmpi(type,'pensdp') || strcmpi(type,'sdp'))
0057
0058 sdpdata=readsdpa(input1);
0059 penm=sdp_define(sdpdata);
0060 prob=penlab(penm);
0061 [alx,aldx,alddx] = setuptestpoint(prob,input2,type);
0062
0063 else
0064 disp('Unknown type of the test.');
0065 prob = [];
0066 end
0067
0068 if (~isempty(prob))
0069
0070 prob.eval_alx();
0071 prob.eval_aldx();
0072 prob.eval_alddx();
0073
0074 prndiff('ALx', prob.ALx, alx);
0075 prndiff('ALdx', prob.ALdx, aldx);
0076 if (prob.Neq>0)
0077 prndiff('ALddx', prob.ALddx, alddx(1:prob.Nx,1:prob.Nx));
0078 prndiff('eqdx', prob.eqdx, alddx(1:prob.Nx,prob.Nx+1:end));
0079 else
0080 prndiff('ALddx', prob.ALddx, alddx);
0081 end
0082
0083 end
0084
0085 end
0086
0087
0088 function prndiff(text,my,ref)
0089 diff=norm(my-ref,inf);
0090 nrm=norm(ref,inf);
0091 if (nrm==0)
0092 nrm=1;
0093 end
0094
0095 if (diff/nrm>1e-10)
0096 wrn=' WARNING !!!';
0097 else
0098 wrn='';
0099 end
0100 disp(sprintf(' %-20s: %e %e (abs|rel) %s',text,diff,diff/nrm,wrn));
0101
0102
0103
0104
0105 end
0106