Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

results are not apparently deterministic? #15

Closed
shabbychef opened this issue Dec 23, 2014 · 9 comments
Closed

results are not apparently deterministic? #15

shabbychef opened this issue Dec 23, 2014 · 9 comments

Comments

@shabbychef
Copy link

I am hunting down a bug that we have traced back to sedumi not being deterministic. I have a MWE:

sed_A = sparse([1e-06 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0.000374569348444187 0 -0.000143510377232224 0 -0.000107308290246781 0 -0.00023475302385101 0 -0.000222588804655496 0 -0.00039621568504792 0 -0.000175372571085547 0 0 0 0 0 0 0 0;0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0;0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0;0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0;0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0;-2 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;-2 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;-2 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;-2 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0;-2 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0;-2 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0;-2 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0;-2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 0 0 0 0 0 0 0 0;0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.00182361766281337 0 0.000300035708922513 0 5.25148072155411e-05 0 0.000172937546376846 0 0.000368772505991557 0 0.000258802261860665 0 9.13124417751099e-05 0 -1 0 0 0 0 0 0;0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.00166011586827782 0 5.08618097827969e-05 0 0.000550274603301129 0 -1.24577387791141e-05 0 2.80912803114481e-05 0 0.000787997869564677 0 0 -1 0 0 0 0 0;0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.00131496023553193 0 -2.85427725918689e-05 0 -6.40917512673142e-05 0 -6.48347565119609e-05 0 -9.88411732133345e-05 0 0 0 -1 0 0 0 0;0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.00116855302122233 0 -1.40653733430151e-05 0 1.38084332511408e-05 0 0.00052463330628182 0 0 0 0 -1 0 0 0;0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.00177126319840008 0 0.000136498835240328 0 -0.000139615027512656 0 0 0 0 0 -1 0 0;0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.00218208935736517 0 -0.000117739846758266 0 0 0 0 0 0 -1 0;0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.00170708755797057 0 0 0 0 0 0 0 -1;-1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0]);
sed_b = [-5e-08;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0];
sed_c = [0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;1;0;0;0;0;0;0;0];
sed_K = struct(sprintf('f'), {0}, sprintf('l'), {17}, sprintf('q'), {[2 2 2 2 2 2 2 8]}, sprintf('r'), {0});
pars = struct(sprintf('fid'), {0}, sprintf('maxiter'), {100});

% run sedumi 200 times, and hash the output:
for i=1:200
    [x,y,info]  = sedumi(sed_A,sed_b,sed_c,sed_K,pars);
    % get the md5 hash of x:
    myhash = java.security.MessageDigest.getInstance('MD5');
    myhash.update(typecast(x,'uint8'));
    hstr = lower(sprintf('%02X',typecast(myhash.digest,'uint8')));
    disp(hstr);
end

In any one Matlab instance, I tend to get the same results. In different Matlab instances, I can get different output. I have gotten all the following output hashes:

1347dafee66c8ff3680ff91ec51cc8bc
01b524f80080f1de14e910d6878ea380
1a8829b52cdf4e970f48ce4c2c0d5003
79f20e7f39ea5e1fba8c06f45d401960

and a few more. I have confirmed that the different hashes correspond to different output. Typically the variation is on the order of 1e-7, indicating some kind of single to double conversion might be at fault.

This is in Matlab r2007b on a linux machine. I have confirmed the results on a few diffferent linux machines all running r2007b. I have code which sets the random seed used by Matlab, and it does not appear to fix the issue. I have also tried setting maxNumCompThreads(1) to see if multithreading causes the problem. It does not appear to.

edit: I am using SeDuMi 1.21

@mcg1969
Copy link
Contributor

mcg1969 commented Dec 23, 2014

Interesting! I'm not entirely sure where randomness my be introduced.

@mcg1969 mcg1969 closed this as completed Dec 23, 2014
@mcg1969 mcg1969 reopened this Dec 23, 2014
@mcg1969
Copy link
Contributor

mcg1969 commented Dec 23, 2014

(Sorry, didn't mean to close it. Re-opened.)

@robertgj
Copy link
Contributor

deczky3_socp_test.gdb.session.txt
I have been trying to track down a
similar problem. I don't have MATLAB but I have made minor edits to SeDuMi_1_3 to build it under octave. I built octave-4.0.0 with address-sanitizer added in the environment (CFLAGS="-g -fsanitize=address -fno-omit-frame-pointer", etc) and ran a script that eventually calls SeDuMi. address sanitizer is triggered at blkchol2.c:79. This appears to be an off-by-one error. "x[idamax_(&n,x,&one)]" is trying to read past the end of x. I have attached a debugging session. I will spend some time trying to work out what is happening in the dense cholesky factorisation in cholonBlk().

@robertgj
Copy link
Contributor

This hack seems to fix my problem:

--- SeDuMi_1_3.orig/blkchol2.c  2009-10-19 22:09:54.000000000 +1100
+++ SeDuMi_1_3/blkchol2.c   2015-11-19 11:20:07.062226915 +1100
@@ -124,7 +124,7 @@ void cholonBlk(double *x, double *d, mwI
    ------------------------------------------------------- */
     xkk = x[inz];
     if(xkk > lb[k]){ /* now xkk > 0 */
-      if(xkk < ub){
+      if((m>1) && (xkk < ub)){
         ubk = maxabs(x+inz+1,m-1) / maxu;
         if(xkk < ubk){
 /* ------------------------------------------------------------

@mcg1969
Copy link
Contributor

mcg1969 commented Nov 19, 2015

Thanks for finding this!

@shabbychef
Copy link
Author

I left my former job and no longer have access to Matlab, so I cannot test this issue. I have notified a former colleague (@cerebellum-github ?) regarding this fix, hoping he can confirm the issue is resolved.

@robertgj
Copy link
Contributor

The following, copied from the original post, works for me in Octave (built on my machine under Fedora 23 from the octave-4.0.0.tar.xz source without native graphics using "./configure --without-fltk --disable-gui --disable-java"):

more off
addpath('SeDuMi_1_3');
sed_A = sparse([1e-06 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0.000374569348444187 0 -0.000143510377232224 0 -0.000107308290246781 0 -0.00023475302385101 0 -0.000222588804655496 0 -0.00039621568504792 0 -0.000175372571085547 0 0 0 0 0 0 0 0;0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0;0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0;0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0;0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0;-2 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;-2 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;-2 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;-2 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0;-2 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0;-2 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0;-2 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0;-2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 0 0 0 0 0 0 0 0;0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.00182361766281337 0 0.000300035708922513 0 5.25148072155411e-05 0 0.000172937546376846 0 0.000368772505991557 0 0.000258802261860665 0 9.13124417751099e-05 0 -1 0 0 0 0 0 0;0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.00166011586827782 0 5.08618097827969e-05 0 0.000550274603301129 0 -1.24577387791141e-05 0 2.80912803114481e-05 0 0.000787997869564677 0 0 -1 0 0 0 0 0;0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.00131496023553193 0 -2.85427725918689e-05 0 -6.40917512673142e-05 0 -6.48347565119609e-05 0 -9.88411732133345e-05 0 0 0 -1 0 0 0 0;0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.00116855302122233 0 -1.40653733430151e-05 0 1.38084332511408e-05 0 0.00052463330628182 0 0 0 0 -1 0 0 0;0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.00177126319840008 0 0.000136498835240328 0 -0.000139615027512656 0 0 0 0 0 -1 0 0;0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.00218208935736517 0 -0.000117739846758266 0 0 0 0 0 0 -1 0;0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.00170708755797057 0 0 0 0 0 0 0 -1;-1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0]);
sed_b = [-5e-08;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0];
sed_c = [0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;1;0;0;0;0;0;0;0];
sed_K = struct(sprintf('f'), {0}, sprintf('l'), {17}, sprintf('q'), {[2 2 2 2 2 2 2 8]}, sprintf('r'), {0});
pars = struct(sprintf('fid'), {0}, sprintf('maxiter'), {100});

% run sedumi 200 times, and hash the output:
for i=1:200
  [x,y,info]  = sedumi(sed_A,sed_b,sed_c,sed_K,pars);
  myhash=md5sum(x,true);
  disp(myhash);
  if strcmp(myhash,'93b885adfe0da089cdf634904fd59f71')==false
    error('Expected myhash to be 93b885adfe0da089cdf634904fd59f71');
  endif
end

@robertgj
Copy link
Contributor

Sorry, I didn't read the documentation of md5sum carefully enough. Try again. This works for me:

more off
format long e
addpath('SeDuMi_1_3');
sed_A = sparse([1e-06 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0.000374569348444187 0 -0.000143510377232224 0 -0.000107308290246781 0 -0.00023475302385101 0 -0.000222588804655496 0 -0.00039621568504792 0 -0.000175372571085547 0 0 0 0 0 0 0 0;0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0;0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0;0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0;0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0;-2 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;-2 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;-2 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;-2 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0;-2 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0;-2 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0;-2 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0;-2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 0 0 0 0 0 0 0 0;0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.00182361766281337 0 0.000300035708922513 0 5.25148072155411e-05 0 0.000172937546376846 0 0.000368772505991557 0 0.000258802261860665 0 9.13124417751099e-05 0 -1 0 0 0 0 0 0;0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.00166011586827782 0 5.08618097827969e-05 0 0.000550274603301129 0 -1.24577387791141e-05 0 2.80912803114481e-05 0 0.000787997869564677 0 0 -1 0 0 0 0 0;0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.00131496023553193 0 -2.85427725918689e-05 0 -6.40917512673142e-05 0 -6.48347565119609e-05 0 -9.88411732133345e-05 0 0 0 -1 0 0 0 0;0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.00116855302122233 0 -1.40653733430151e-05 0 1.38084332511408e-05 0 0.00052463330628182 0 0 0 0 -1 0 0 0;0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.00177126319840008 0 0.000136498835240328 0 -0.000139615027512656 0 0 0 0 0 -1 0 0;0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.00218208935736517 0 -0.000117739846758266 0 0 0 0 0 0 -1 0;0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.00170708755797057 0 0 0 0 0 0 0 -1;-1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0]);
sed_b = [-5e-08;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0];
sed_c = [0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;1;0;0;0;0;0;0;0];
sed_K = struct(sprintf('f'), {0}, sprintf('l'), {17}, sprintf('q'), {[2 2 2 2 2 2 2 8]}, sprintf('r'), {0});
pars = struct(sprintf('fid'), {0}, sprintf('maxiter'), {100});

% run sedumi 200 times, and hash the output:
for i=1:200
  [x,y,info]  = sedumi(sed_A,sed_b,sed_c,sed_K,pars);
  xstr=sprintf('%16.10g ',x)
  myhash=md5sum(xstr,true);
  disp(myhash);
  if strcmp(myhash,'d50f2fb51d0c438fe218383a145f2534')==false
    error('Expected myhash to be d50f2fb51d0c438fe218383a145f2534');
  endif
end

siko1056 added a commit that referenced this issue Aug 25, 2020
Fix compiler warnings about uninitialised variables and issue #15
@siko1056
Copy link
Member

siko1056 commented Aug 25, 2020

Finally closed by #58 thanks to @robertgj 😊 👍

This program runs in Octave 5.2.0 and Matlab R2020b (with the old and new mexa64 binaries 😕 maybe only an Octave issue).

install_sedumi
format long e
sed_A = sparse([1e-06 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0.000374569348444187 0 -0.000143510377232224 0 -0.000107308290246781 0 -0.00023475302385101 0 -0.000222588804655496 0 -0.00039621568504792 0 -0.000175372571085547 0 0 0 0 0 0 0 0;0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0;0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0;0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0;0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0;-2 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;-2 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;-2 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;-2 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0;-2 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0;-2 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0;-2 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0;-2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 0 0 0 0 0 0 0 0;0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.00182361766281337 0 0.000300035708922513 0 5.25148072155411e-05 0 0.000172937546376846 0 0.000368772505991557 0 0.000258802261860665 0 9.13124417751099e-05 0 -1 0 0 0 0 0 0;0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.00166011586827782 0 5.08618097827969e-05 0 0.000550274603301129 0 -1.24577387791141e-05 0 2.80912803114481e-05 0 0.000787997869564677 0 0 -1 0 0 0 0 0;0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.00131496023553193 0 -2.85427725918689e-05 0 -6.40917512673142e-05 0 -6.48347565119609e-05 0 -9.88411732133345e-05 0 0 0 -1 0 0 0 0;0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.00116855302122233 0 -1.40653733430151e-05 0 1.38084332511408e-05 0 0.00052463330628182 0 0 0 0 -1 0 0 0;0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.00177126319840008 0 0.000136498835240328 0 -0.000139615027512656 0 0 0 0 0 -1 0 0;0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.00218208935736517 0 -0.000117739846758266 0 0 0 0 0 0 -1 0;0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.00170708755797057 0 0 0 0 0 0 0 -1;-1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0]);
sed_b = [-5e-08;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0];
sed_c = [0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;1;0;0;0;0;0;0;0];
sed_K = struct(sprintf('f'), {0}, sprintf('l'), {17}, sprintf('q'), {[2 2 2 2 2 2 2 8]}, sprintf('r'), {0});
pars = struct(sprintf('fid'), {0}, sprintf('maxiter'), {100});

if (exist ("OCTAVE_VERSION", "builtin") == 5)
  expected = '287ab8afc72fef3240296fe3d62c81be'; % Octave 5.2.0
else
  expected = '71ed00585640dbc3f14990e38a2db1aa'; % Matlab R2020b
end

% run sedumi 200 times, and hash the output:
for i=1:200
  [x,y,info]  = sedumi(sed_A,sed_b,sed_c,sed_K,pars);
  xstr=sprintf('%16.10g ',x);
  if (exist ("OCTAVE_VERSION", "builtin") == 5)
    myhash = hash("md5", xstr);
  else
    mhash = java.security.MessageDigest.getInstance('MD5');
    mhash.update(typecast(x,'uint8'));
    myhash = lower(sprintf('%02X',typecast(mhash.digest,'uint8')));
  end
  if (~strcmp (myhash, expected))
    error('Expected myhash to be %s, but got %s', expected, myhash);
  end
end

disp ('done')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants