Skip to content

Commit

Permalink
unify storage of BT, instead of transformation
Browse files Browse the repository at this point in the history
  • Loading branch information
origamimagiro committed Oct 3, 2024
1 parent f86fca2 commit 3c01173
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 29 deletions.
21 changes: 10 additions & 11 deletions src/batch.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,14 @@ export const BATCH = {
const [CF, FC] = X.EF_FV_SP_SE_CP_SC_2_CF_FC(EF, FV, SP, SE, CP, SC);
const BF = X.EF_SP_SE_CP_CF_2_BF(EF, SP, SE, CP, CF);
const BI = new Map();
const num = {};
for (const [i, F] of BF.entries()) { BI.set(F, i); }
const [BT0, BT1, BT2] = X.BF_BI_EF_SE_CF_SC_2_BT0_BT1_BT2(
BF, BI, EF, SE, CF, SC);
num.BT0 = NOTE.count_subarrays(BT0)/6;
num.BT1 = NOTE.count_subarrays(BT1)/2;
num.BT2 = NOTE.count_subarrays(BT2)/2;
const CC = X.FC_BF_BI_BT1_2_CC(FC, BF, BI, BT1);
const BT = BF.map((F,i) => [BT0[i], BT1[i], BT2[i]]);
const BT = X.BF_BI_EF_SE_CF_SC_2_BT(BF, BI, EF, SE, CF, SC);
const BTn = [0, 0, 0];
for (const bT of BT) {
for (let i = 0; i < 3; ++i) { BTn[i] += bT[i].length; }
}
for (const [i, d] of [[0, 6], [1, 2], [2, 2]]) { BTn[i] /= d; }
const CC = X.FC_BF_BI_BT_2_CC(FC, BF, BI, BT);
const BA0 = SOLVER.EF_EA_Ff_BF_BI_2_BA0(EF, EA, Ff, BF, BI);
const trans_count = {all: 0, reduced: 0};
const out = SOLVER.initial_assignment(BA0, BF, BT, BI, FC, CF, CC, trans_count);
Expand Down Expand Up @@ -132,9 +131,9 @@ export const BATCH = {
faces: FV.length,
eps: eps,
variables: BF.length,
"taco-taco": num.BT0,
"taco-tortilla": num.BT1,
"tortilla-tortilla": num.BT2,
"taco-taco": BTn[0],
"taco-tortilla": BTn[1],
"tortilla-tortilla": BTn[2],
transitivity: trans_count.all/3,
"reduced-trans": trans_count.reduced/3,
components: GB.length,
Expand Down
18 changes: 10 additions & 8 deletions src/compute.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,17 @@ const actions = {
const {EF} = G.FOLD;
const {SP, SE, CP, SC, CF, FC} = G.CELL;
NOTE.time("Computing non-transitivity constraints");
const [BT0, BT1, BT2] = X.BF_BI_EF_SE_CF_SC_2_BT0_BT1_BT2(
G.BF, G.BI, EF, SE, CF, SC);
NOTE.count(BT0, "taco-taco", 6);
NOTE.count(BT1, "taco-tortilla", 2);
NOTE.count(BT2, "tortilla-tortilla", 2);
G.BT = X.BF_BI_EF_SE_CF_SC_2_BT(G.BF, G.BI, EF, SE, CF, SC);
const BTn = [0, 0, 0];
for (const bT of G.BT) {
for (let i = 0; i < 3; ++i) { BTn[i] += bT[i].length; }
}
for (const [i, d] of [[0, 6], [1, 2], [2, 2]]) { BTn[i] /= d; }
NOTE.log(` - Found ${BTn[0]} taco-taco`);
NOTE.log(` - Found ${BTn[1]} taco-tortilla`);
NOTE.log(` - Found ${BTn[2]} tortilla-tortilla`);
NOTE.lap();
G.BT = G.BF.map((F,i) => [BT0[i], BT1[i], BT2[i]]);
G.CC = X.FC_BF_BI_BT1_2_CC(FC, G.BF, G.BI, BT1);
BT0.length = 0; BT1.length = 0; BT2.length = 0;
G.CC = X.FC_BF_BI_BT_2_CC(FC, G.BF, G.BI, G.BT);
postMessage({type: "end", arg: []});
},
presolve: () => {
Expand Down
21 changes: 11 additions & 10 deletions src/conversion.js
Original file line number Diff line number Diff line change
Expand Up @@ -573,14 +573,15 @@ export const X = { // CONVERSION
for (const p of pairs) {
const i = BI.get(M.encode_order_pair(p));
if (i == undefined) { debugger; }
BT[type][i].push(M.encode(F));
BT[i][type].push(M.encode(F));
}
},
BF_BI_EF_SE_CF_SC_2_BT0_BT1_BT2: (BF, BI, EF, SE, CF, SC) => {
const BT0 = BF.map(() => []); // taco-taco
const BT1 = BF.map(() => []); // taco-tortilla
const BT2 = BF.map(() => []); // tortilla-tortilla
const BT = [BT0, BT1, BT2];
BF_BI_EF_SE_CF_SC_2_BT: (BF, BI, EF, SE, CF, SC) => {
const BT = BF.map(() => [
[], // taco-taco
[], // taco-tortilla
[], // tortilla-tortilla
]);
NOTE.time("Computing from edge-edge intersections");
const ExE = EF.map(() => new Set());
for (const edges of SE) {
Expand Down Expand Up @@ -671,12 +672,12 @@ export const X = { // CONVERSION
ExF.length = 0;
return BT;
},
FC_BF_BI_BT1_2_CC: (FC, BF, BI, BT1) => {
FC_BF_BI_BT_2_CC: (FC, BF, BI, BT) => {
const FG = FC.map(() => new Map());
NOTE.start_check("taco-tortilla", BT1);
for (const [i, T] of BT1.entries()) { // construct connectivity graphs
NOTE.start_check("taco-tortilla", BT);
for (const [i, T] of BT.entries()) { // construct connectivity graphs
NOTE.check(i);
for (const k of T) {
for (const k of T[1]) {
const [a, b, c] = M.decode(k);
const G = FG[c];
if (!G.has(a)) { G.set(a, new Set()); }
Expand Down

0 comments on commit 3c01173

Please sign in to comment.