diff --git a/advancedUse/experiment/POPrandom/solvePOParrow.m b/advancedUse/experiment/POPrandom/solvePOParrow.m
index 8539764..eed1fc3 100644
--- a/advancedUse/experiment/POPrandom/solvePOParrow.m
+++ b/advancedUse/experiment/POPrandom/solvePOParrow.m
@@ -54,29 +54,14 @@ function solvePOParrow(printFileName,degree,a,b,c,l,isBin,addComplement,solver)
% end
if nargin == 4
- solver = 'BP';
+ solver = 'BP';
end
% [objPoly, I01, Icomp]=genPOParrow2(d,a,b,c,l,isBin,addComplement)
- [objPoly, I01, Icomp] = genPOParrow(degree,a,b,c,l,isBin,addComplement);
-
- params.solver = solver;
- params.newBPswitch = false;
-
- %% to DNN
- eqPolySys = [];
- params.relaxOrder = ceil(degree / 2);
- [Q0vec, H0vec, H1vec, PSDcone, polyCone, UbdIX] ...
- = BBPOPtoCOP(objPoly, eqPolySys, I01, Icomp, params);
+ [objPoly, I01, Icomp] = genPOParrow(degree,a,b,c,l,isBin,addComplement);
+
+ [sol, info, params] = solvePOPpipeline(objPoly, I01, Icomp, degree, solver);
- %% solve
- params.UbdIX = UbdIX;
- params.UbdObjVal = evalPoly(objPoly, zeros(n, 1));
- params.delta1 = 1.0e-4;
- params.delta2 = 0;
- params.delta = 0;
- [sol, info] = solveCOP(Q0vec, H0vec, H1vec, PSDcone, polyCone, params);
-
%% print
filename = printFileName;
fid = fopen(filename, 'a');
diff --git a/advancedUse/experiment/POPrandom/solvePOPchordal.m b/advancedUse/experiment/POPrandom/solvePOPchordal.m
index 170028d..c1f6368 100644
--- a/advancedUse/experiment/POPrandom/solvePOPchordal.m
+++ b/advancedUse/experiment/POPrandom/solvePOPchordal.m
@@ -13,40 +13,14 @@ function solvePOPchordal(printFileName,degree,nDim,radiorange,isBin,addComplemen
% addComplement : 1 for adding random complementarity constraints
% solver : 'BP, 'sdpnalplus', 'sedumi'
-[objPoly, I01, Icomp] = genPOPchordal(degree,nDim,radiorange,isBin,addComplement);
-
-% Icomp = [];
-% if addComplement
-% Icomp = complementarityConstraint(2, 2, clique, randSeed);
-% end
-
if nargin == 4
- solver = 'BP';
+ solver = 'BP';
end
-
- if strcmp(solver, 'newBP')
- params.solver = 'BP';
- params.newBPswitch = true;
- else
- params.solver = solver;
- params.newBPswitch = false;
- end
-
- %% to DNN
- eqPolySys = [];
- params.relaxOrder = ceil(degree / 2);
- [Q0vec, H0vec, H1vec, PSDcone, polyCone, UbdIX] ...
- = BBPOPtoCOP(objPoly, eqPolySys, I01, Icomp, params);
- %% solve
- params.UbdIX = UbdIX;
- params.UbdObjVal = evalPoly(objPoly, zeros(nDim, 1));
- params.delta1 = 1.0e-4;
- params.delta2 = 0;
- params.delta = 0;
- [sol, info] = solveCOP(Q0vec, H0vec, H1vec, PSDcone, polyCone, params);
-
-
+ [objPoly, I01, Icomp] = genPOPchordal(degree,nDim,radiorange,isBin,addComplement);
+
+ [sol, info, params] = solvePOPpipeline(objPoly, I01, Icomp, degree, solver);
+
%% print
fid = fopen(printFileName, 'a');
% fprintf(fid,'degree,n,rRange,isBin,addComp,rOder,solver,LBv,sec,iter(APGR),termcode,iterBP\n');
diff --git a/advancedUse/experiment/POPrandom/solvePOPdense.m b/advancedUse/experiment/POPrandom/solvePOPdense.m
index c3baf35..3234f4a 100644
--- a/advancedUse/experiment/POPrandom/solvePOPdense.m
+++ b/advancedUse/experiment/POPrandom/solvePOPdense.m
@@ -10,35 +10,13 @@ function solvePOPdense(printFileName,degree,nDim,isBin,addComplement,solver)
% solver : 'BP, 'sdpnalplus', 'sedumi'
if nargin == 4
- solver = 'BP';
+ solver = 'BP';
end
-
- [objPoly,I01,Icomp] = genPOPdense(degree,nDim,isBin,addComplement);
- if strcmp(solver, 'newBP')
- params.solver = 'BP';
- params.newBPswitch = true;
- else
- params.solver = solver;
- params.newBPswitch = false;
- end
- %% to DNN
- eqPolySys = [];
- params.relaxOrder = ceil(degree / 2);
- [Q0vec, H0vec, H1vec, PSDcone, polyCone, UbdIX] ...
- = BBPOPtoCOP(objPoly, eqPolySys, I01, Icomp, params);
- %% solve
- params.delta1 = 1.0e-4;
- params.delta2 = 0;
- params.delta = 0;
- params.UbdIX = UbdIX;
- params.UbdObjVal = evalPoly(objPoly, zeros(nDim, 1));
- % params.deltaRelBP = 1.0e-4;
- % params.deltaAbsBP = 0;
- % params.deltaDifRelBP = 0;
- [sol, info] = solveCOP(Q0vec, H0vec, H1vec, PSDcone, polyCone, params);
-
-
+ [objPoly, I01, Icomp] = genPOPdense(degree,nDim,isBin,addComplement);
+
+ [sol, info, params] = solvePOPpipeline(objPoly, I01, Icomp, degree, solver);
+
%% print
fid = fopen(printFileName, 'a');
% fprintf(fid,'degree,n,isBin,addComp,rOrder,solver,LBv,sec,iter,termcode\n');
diff --git a/advancedUse/experiment/POPrandom/solvePOPpipeline.m b/advancedUse/experiment/POPrandom/solvePOPpipeline.m
new file mode 100644
index 0000000..c9e06b1
--- /dev/null
+++ b/advancedUse/experiment/POPrandom/solvePOPpipeline.m
@@ -0,0 +1,21 @@
+function [sol, info, params] = solvePOPpipeline(objPoly, I01, Icomp, degree, solver)
+%SOLVEPOPPIPELINE Shared solver pipeline: BBPOPtoCOP -> solveCOP.
+% Common logic extracted from solvePOParrow, solvePOPchordal, solvePOPdense.
+ if strcmp(solver, 'newBP')
+ params.solver = 'BP';
+ params.newBPswitch = true;
+ else
+ params.solver = solver;
+ params.newBPswitch = false;
+ end
+ eqPolySys = [];
+ params.relaxOrder = ceil(degree / 2);
+ [Q0vec, H0vec, H1vec, PSDcone, polyCone, UbdIX] ...
+ = BBPOPtoCOP(objPoly, eqPolySys, I01, Icomp, params);
+ params.UbdIX = UbdIX;
+ params.UbdObjVal = evalPoly(objPoly, zeros(objPoly.dimVar, 1));
+ params.delta1 = 1.0e-4;
+ params.delta2 = 0;
+ params.delta = 0;
+ [sol, info] = solveCOP(Q0vec, H0vec, H1vec, PSDcone, polyCone, params);
+end
diff --git a/instances/BIQ/biqread.m b/instances/BIQ/biqread.m
index 3da74b8..b63fc48 100644
--- a/instances/BIQ/biqread.m
+++ b/instances/BIQ/biqread.m
@@ -6,14 +6,7 @@
function [Q] = biqread(instance)
- fid = fopen(instance,'r');
- if (fid == -1); error('file cannot be opened'); end
-
- [datavec,count] = fscanf(fid,'%c');
- fclose(fid);
- linefeeds = findstr(datavec,char(10));
- datavec(linefeeds) = blanks(length(linefeeds));
- datavec = sscanf(datavec,'%f');
+ datavec = readInstanceFile(instance);
n = datavec(1); nz = datavec(2);
tmp = datavec(3:end);
diff --git a/instances/POPrandom/findChordalCliques.m b/instances/POPrandom/findChordalCliques.m
new file mode 100644
index 0000000..04248b4
--- /dev/null
+++ b/instances/POPrandom/findChordalCliques.m
@@ -0,0 +1,40 @@
+function [clique, R] = findChordalCliques(adjMat)
+% FINDCHORDALCLIQUES Find maximal cliques via chordal extension (Cholesky).
+% Input:
+% adjMat : symmetric adjacency matrix of a sparse graph
+% Output:
+% clique.Set : logical matrix; each row is a maximal clique (0-1 encoding)
+% clique.NoC : number of maximal cliques
+% clique.maxC : maximum clique size
+% clique.minC : minimum clique size
+% R : upper triangular adjacency of the chordal extension
+
+ nDim = size(adjMat,1);
+ adjMat = spones(adjMat);
+ adjMat = adjMat + adjMat';
+ adjMat = adjMat + 10*nDim*speye(nDim);
+
+ I = symamd(adjMat);
+ [R, p] = chol(adjMat(I,I));
+ if (p > 0)
+ error('Correlative sparsity matrix is not positive definite.');
+ end
+
+ R = spones(R);
+ [~, orig_idx] = sort(I);
+ remainIdx = 1;
+ for i = 2:nDim
+ checkSet = R(i,i:nDim);
+ noOfone = length(find(checkSet));
+ cliqueResult = R(1:i-1,i:nDim)*checkSet';
+ yesno = find(cliqueResult == noOfone);
+ if ~any(yesno)
+ remainIdx = [remainIdx; i];
+ end
+ end
+ clique.Set = logical(R(remainIdx, orig_idx));
+ clique.NoC = size(clique.Set,1);
+ sumClique = sum(clique.Set,2);
+ clique.maxC = max(sumClique);
+ clique.minC = min(sumClique);
+end
diff --git a/instances/POPrandom/genPOPchordal.m b/instances/POPrandom/genPOPchordal.m
index 5026d18..fcfd998 100644
--- a/instances/POPrandom/genPOPchordal.m
+++ b/instances/POPrandom/genPOPchordal.m
@@ -8,9 +8,9 @@
%% radiorange : radiorange which controls the sparsity of the chordal graph generated
%% for example, radiorange = 0.1
%% isBin : 1 for the binary constraint, 0 for the box constraint
-%% addComplement : 1 for adding random complementarity constraints
+%% addComplement : 1 for adding random complementarity constraints
- relaxOrder = ceil(degree/2);
+ relaxOrder = ceil(degree/2);
params.delta1 = 1.0e-4;
params.delta = 0;
@@ -18,32 +18,16 @@
I01 = isBin .* true(1,nDim);
rng('default');
rng(randSeed);
- [adjMat] = generateSparseGraph(radiorange,nDim,randSeed);
- adjMat = spones(adjMat);
- [clique,R] = genCliques(adjMat);
- % clique: information on the maximal cliques, this variable is the
- % structure with the following fields.
- %
- % clique.Set: The maximal clieques, which are represented by 0-1.
- % e.g. The number of variable is 3 and the maximal
- % cliques are C1={1,2} and C2={2,3}.
- %
- % Then, clique.Set(1,:) = [1,1,0];(= C1)
- % clique.Set(2,:) = [0,1,1];(= C2)
- % clique.NoC: The number of cliques
- % clique.maxC: The maximum size in the maximum cliques
- % clique.minC: The minimum size in the maximum cliques
- % R: The upper triangular adjacency matrix of a chordal graph
-
- %%%%%%%%%%
+ [adjMat] = generateSparseGraph(radiorange,nDim,randSeed);
+ adjMat = spones(adjMat);
+ [clique,R] = findChordalCliques(adjMat);
+
Icomp = [];
if addComplement
Icomp = complementarityConstraint(2, 2, clique, randSeed);
end
- %%%%%%%%%
-
+
if 1
- %spy(R);
[m, n] = size(clique.Set);
A = sparse(n, n);
for ii = 1:m
@@ -51,17 +35,10 @@
end
spy(A);
end
-
- mDim = size(clique.Set,1);
-% supportsT = [];
+
+ mDim = size(clique.Set,1);
supports = cell(mDim, 1);
- for i=1:mDim
-% idx=find(clique.Set(i,:));
-% cDim = length(idx);
-% oneSupports = enumMonosUptoDeg(cDim,degree);
-% sDim = size(oneSupports,1);
-% [I,J,V] = find(oneSupports);
-% supportsT = [supportsT,sparse(idx(J),I,V,nDim,sDim,length(V))];
+ for i = 1:mDim
idx = clique.Set(i,:);
cDim = sum(idx);
oneSupports = enumMonosUptoDeg(cDim, degree);
@@ -70,10 +47,8 @@
supports{i}(:, idx) = oneSupports;
end
supports = cell2mat(supports);
-% objPoly.supports = unique(supportsT','rows','first','legacy');
supports = fastUnique(supports);
objPoly.supports = sortrows(supports);
- %objPoly.supports = unique(supports, 'rows', 'first', 'legacy');
objPoly.noTerms = size(objPoly.supports,1);
objPoly.coef = 2*rand(objPoly.noTerms,1) - ones(objPoly.noTerms,1);
objPoly.typeCone = 1;
@@ -81,448 +56,5 @@
objPoly.dimVar = nDim;
objPoly.degree = degree;
x0 = zeros(nDim,1);
- objPoly.UbdObjVal = evalPoly(objPoly,x0); % evalPolynomials(objPoly,x0);
-end
-
-function [clique,R] = genCliques(adjMat)
- %
- % adjMat: symmetric adjacency matrix of a sparse graph
- %