This is a static copy of a profile report

Home

Function details for qap_admm_blkdiagThis is a static copy of a profile report

Home

qap_admm_blkdiag (Calls: 1, Time: 5418.606 s)
Generated 20-Jul-2018 02:24:58 using performance time.
function in file C:\Users\yz\Dropbox\Workspace\Researches\PhD Research\My Papers\2018_symmtry_reduction\18groupsymmetrySDPSlaterHaoRenata.d\codesgroupsymmetrySDPSlaterHaoRenata.d\qap\qap_admm_blkdiag.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
LiveEditorEvaluationHelperESectionEvalscript1
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
81
output = run_admm(output,C_til...
15279.277 s97.4%
66
[B_mat, B_mat_mean, Bhat_blk, ...
1108.414 s2.0%
56
if norm(double(B{i}(logical(A1...
375729.510 s0.5%
96
end
10.492 s0.0%
33
A1 = kron(eye(n),ones(n)-eye(n...
10.170 s0.0%
All other lines  0.743 s0.0%
Totals  5418.606 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
run_admmfunction15279.259 s97.4%
get_admm_matrixfunction1108.380 s2.0%
kronfunction50.224 s0.0%
get_blkdiagfunction20.189 s0.0%
qap_admm_blkdiag>load_settingsubfunction10.073 s0.0%
blkdiagfunction20.027 s0.0%
qap_admm_blkdiag>@(x)size(x,2)anonymous function1980.012 s0.0%
Self time (built-ins, overhead, etc.)  30.442 s0.6%
Totals  5418.606 s100% 
Code Analyzer results
Line numberMessage
Coverage results
Show coverage for parent directory
Total lines in function96
Non-code lines (comments, blank lines)49
Code lines (lines that can run)47
Code lines that did run45
Code lines that did not run2
Coverage (did run/can run)95.74 %
Function listing
time 
Calls 
 line
   1 
function [Y, fval, output] = qap_admm_blkdiag(qap_A,qap_B,G,opts)
   2 

   3 
% load the group information
  0.002 
      1 
   4
Q = G.Q; 
  0.001 
      1 
   5
B = G.B; 
  0.003 
      1 
   6
Bhat = G.Bhat; 
  0.002 
      1 
   7
blk_nz = G.blk_nz; 
  0.006 
      1 
   8
blk_sizes = G.blk_sizes; 
   9 

  10 
% the objective kron(B,A)
  0.049 
      1 
  11
BXA = kron(qap_B,qap_A); 
  12 

  13 
%% load the setting
  0.082 
      1 
  14
[opts,output] = load_setting(opts,BXA); 
< 0.001 
      1 
  15
b_tol = 1e-10; % the tolerance for the block-diagonalization 
  16 

  17 
%% load the instance parameter
      1 
  18
n = length(qap_A); 
  19 
% m = n^2;
  20 

  21 
% print information
  0.024 
      1 
  22
    fprintf('--------------------------------------------\n') 
  0.005 
      1 
  23
    fprintf('Instance information: number of facilitys/locations %d \n', n) 
  24 

  25 
%% obtain the data and datamatrices for the sdp below
  26 
% min{ <A0,Y> | <Ai,Y>==0 for i = 1,2 }
  0.010 
      1 
  27
scalar = opts.scalar; 
  28 

  29 
% cost matrix Q in the objective
  0.032 
      1 
  30
A0 = blkdiag(0,BXA)*scalar;    
  31 

  32 
% A1 is the gangster constraint <A1,Y> = 0
  0.170 
      1 
  33
A1 = kron(eye(n),ones(n)-eye(n)) + kron(ones(n)-eye(n),eye(n)); 
  0.006 
      1 
  34
A1 = blkdiag(0,A1); 
  35 

  36 
% T_hat is in the null-space of Y,i.e., T_hatY = 0
  37 
% Thus T_hat'T_hat is an exposing vector
  0.047 
      1 
  38
T = [kron(eye(n),ones(1,n)); kron(ones(1,n),eye(n))]; 
  0.007 
      1 
  39
T_hat = [-ones(2*n,1) T]; 
  40 

  41 
% ev = [2*n -2*ones(1,n^2); -2*ones(n^2,1) kron(eye(n),ones(n))+kron(ones(n),eye(n))];
  42 
% if norm(ev - T_hat'*T_hat) > 0
  43 
%     keyboard
  44 
% end
  45 
%% group symmetry - preprocessing
  46 

  47 
% get the exposing vector of the symmetry reduced problem
  0.122 
      1 
  48
Wbar = get_blkdiag(T_hat'*T_hat,Q,blk_nz,b_tol); 
  0.080 
      1 
  49
C_tilde = get_blkdiag(A0,Q,blk_nz,b_tol); 
  50 

  0.002 
      1 
  51
output.Wbar = Wbar; 
  52 

  53 
% remove the base B_{i} if the associated entry is 0 
  0.003 
      1 
  54
idx = false(length(B),1); 
  0.001 
      1 
  55
for i = 1:length(B) 
 29.510 
   3757 
  56
   if norm(double(B{i}(logical(A1)))) == 0 
  0.003 
   3282 
  57
       idx(i) = true; 
< 0.001 
   3282 
  58
   end     
  0.037 
   3757 
  59
end 
  0.014 
      1 
  60
B = B(idx);         % only keep base B_{i} for non-zeros 
  0.008 
      1 
  61
Bhat = Bhat(idx); % only keep base Bhat_{i} for non-zeros 
  0.065 
      1 
  62
output.B_hat = Bhat; 
  63 

  64 
%% ADMM
  65 
% preprocess the data-matrices for admm
 108.414 
      1 
  66
[B_mat, B_mat_mean, Bhat_blk, V] = get_admm_matrix(B, Bhat, Wbar, blk_sizes); 
  67 

  68 
% check if the dimension of the problem is correct
  0.070 
      1 
  69
r = sum(cellfun(@(x) size(x,2), V));        % the dim. of facially reduced program 
< 0.001 
      1 
  70
if r ~= (n-1)^2+1                               % the strictly feasible problem has rank m-n+2 
  71 
    error('the dimension is NOT correct.')
  72 
end
  73 

  74 
% save the data-matrices for admm
  0.005 
      1 
  75
output.blk_sizes = blk_sizes; 
< 0.001 
      1 
  76
output.blk_nz = blk_nz; 
  0.002 
      1 
  77
output.B_mat_mean = B_mat_mean; 
  0.014 
      1 
  78
output.B_mat = B_mat; 
  79 

  80 
% run admm to solve the problem
 5279.277 
      1 
  81
output = run_admm(output,C_tilde,Bhat_blk,Q,V,opts); 
  82 

  83 
% obtain the optimal solution&value
  0.001 
      1 
  84
Y = output.Y; 
  0.004 
      1 
  85
fval = output.fval; 
  86 

  87 
% compute the upper&lower bound
  88 
% output.lb = getlb(C_tilde,blkdiag(output.Z{:}),blkdiag(V{:}),U)/scalar;
< 0.001 
      1 
  89
output.lb = -1; 
  90 
% [output.ub, output.ub_x] = getub(I,Q,s,t,Y(m+3:m+2:end));
  0.001 
      1 
  91
output.ub =-1; 
  0.003 
      1 
  92
output.ub_x  =-1; 
  0.004 
      1 
  93
fprintf('lower bound      : %.3f (*)\n', output.lb) 
  0.007 
      1 
  94
fprintf('upper bound      : %.3f (*)\n', output.ub) 
  95 

  0.492 
      1 
  96
end 

Other subfunctions in this file are not included in this listing.