Enable Remigijus's Barnes-Hut

This commit is contained in:
Pitchaya Boonsarngsuk
2018-02-02 12:19:17 +00:00
parent f6ac1f7e37
commit 474bd677ae
2 changed files with 13 additions and 12 deletions

View File

@@ -15,7 +15,7 @@ function starttSNE() {
// The distance function that will be used to calculate distances // The distance function that will be used to calculate distances
// between nodes. // between nodes.
.distance(function (s, t) { .distance(function (s, t) {
return distanceFunction(s, t, props, norm) * MULTIPLIER; return distanceFunction(s, t, props, norm);
})); }));
// Restart the simulation. // Restart the simulation.
console.log(simulation.force(forceName).perplexity(), simulation.force(forceName).learningRate()); console.log(simulation.force(forceName).perplexity(), simulation.force(forceName).learningRate());
@@ -26,18 +26,19 @@ function starttSNE() {
* Initialize the Barnes-Hut algorithm and start simulation. * Initialize the Barnes-Hut algorithm and start simulation.
*/ */
function startBarnesHutSimulation() { function startBarnesHutSimulation() {
console.log("startBarnesHutSimulation")
alreadyRanIterations = 0;
manualStop = false;
springForce = false; springForce = false;
simulation.stop();
p1 = performance.now(); p1 = performance.now();
simulation simulation.alphaDecay(1 - Math.pow(0.001, 1 / ITERATIONS))
.alphaDecay(1 - Math.pow(0.001, 1 / ITERATIONS)) .on("tick", ticked)
.on("end", ended)
.force(forceName, d3.forceBarnesHut() .force(forceName, d3.forceBarnesHut()
// The distance function that will be used to calculate distances // The distance function that will be used to calculate distances
// between nodes. // between nodes.
.distance(function (s, t) { .distance(function(s, t) { return distanceFunction(s, t, props, norm); }));
return distanceFunction(s, t, props, norm) * MULTIPLIER;
}));
// Restart the simulation. // Restart the simulation.
simulation.alpha(1).restart(); simulation.alpha(1).restart();
} }

View File

@@ -1,9 +1,9 @@
export {default as forceNeighbourSampling} export {default as forceNeighbourSampling}
from "./src/neighbourSampling"; from "./src/neighbourSampling";
/*
export { default as forceBarnesHut} export { default as forceBarnesHut}
from "./src/barnesHut"; from "./src/barnesHut";
/*
export { default as tSNE} export { default as tSNE}
from "./src/t-sne"; from "./src/t-sne";
*/ */