Compare commits
2 Commits
831c3f9db9
...
3cf857f275
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3cf857f275 | ||
|
|
d955aff239 |
@ -34,7 +34,7 @@ class Simulation extends React.Component{
|
|||||||
this.state = {rules: rules, states: states, initial_distribution: initial_distribution, graphData: graphData, horizon: 20.0, selectedNetwork: this.networkObject, selectedModel: this.modelObject, simulationData: undefined,};
|
this.state = {rules: rules, states: states, initial_distribution: initial_distribution, graphData: graphData, horizon: 20.0, selectedNetwork: this.networkObject, selectedModel: this.modelObject, simulationData: undefined,};
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillMount() {
|
UNSAFE_componentWillMount() {
|
||||||
this.recalculate();
|
this.recalculate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,6 +81,9 @@ class Simulation extends React.Component{
|
|||||||
var newSimulationData = simulate(rules, states, initial_distribution, this.state.selectedNetwork.getGraph(), this.state.horizon);
|
var newSimulationData = simulate(rules, states, initial_distribution, this.state.selectedNetwork.getGraph(), this.state.horizon);
|
||||||
|
|
||||||
this.setState({graphData: graphData, rules: rules, states: states, initial_distribution: initial_distribution, simulationData: newSimulationData});
|
this.setState({graphData: graphData, rules: rules, states: states, initial_distribution: initial_distribution, simulationData: newSimulationData});
|
||||||
|
|
||||||
|
//return a promise to be sure the data is saved
|
||||||
|
return Promise.resolve("Done");
|
||||||
}
|
}
|
||||||
|
|
||||||
render(){
|
render(){
|
||||||
|
|||||||
@ -71,7 +71,6 @@ class Custom extends Model {
|
|||||||
//}
|
//}
|
||||||
|
|
||||||
//convert states to states with distribution and color
|
//convert states to states with distribution and color
|
||||||
console.log(newStates);
|
|
||||||
//newStates = newStates.map((x) => [x, 1/newStates.length, "#ffffff"]);
|
//newStates = newStates.map((x) => [x, 1/newStates.length, "#ffffff"]);
|
||||||
let i = -1;
|
let i = -1;
|
||||||
newStates = newStates.map((x) => {
|
newStates = newStates.map((x) => {
|
||||||
@ -81,7 +80,6 @@ class Custom extends Model {
|
|||||||
}
|
}
|
||||||
return [x, 1/newStates.length, "#ffffff"];
|
return [x, 1/newStates.length, "#ffffff"];
|
||||||
});
|
});
|
||||||
console.log(newStates);
|
|
||||||
|
|
||||||
|
|
||||||
return {rules: newRules, states: newStates};
|
return {rules: newRules, states: newStates};
|
||||||
@ -111,7 +109,6 @@ class Custom extends Model {
|
|||||||
let leftSide = [subString.slice(0, subString.length / 2)];
|
let leftSide = [subString.slice(0, subString.length / 2)];
|
||||||
let rightSide = [subString.slice(subString.length / 2, subString.length)];
|
let rightSide = [subString.slice(subString.length / 2, subString.length)];
|
||||||
let out = [leftSide, rightSide, Number(probability)];
|
let out = [leftSide, rightSide, Number(probability)];
|
||||||
console.log(out)
|
|
||||||
return out;
|
return out;
|
||||||
//let out = [0,0,0];
|
//let out = [0,0,0];
|
||||||
//out[0] = (leftSide);
|
//out[0] = (leftSide);
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import DistributionStatus from "../DistributionStatus";
|
|
||||||
import Slider from "../Slider";
|
import Slider from "../Slider";
|
||||||
import '../../css/Model.css';
|
import '../../css/Model.css';
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,6 @@ import React from "react";
|
|||||||
import NVD3Chart from 'react-nvd3';
|
import NVD3Chart from 'react-nvd3';
|
||||||
import '../../css/Chart.css'
|
import '../../css/Chart.css'
|
||||||
import '../../css/nv3d.css'
|
import '../../css/nv3d.css'
|
||||||
import d3 from 'd3';
|
|
||||||
|
|
||||||
class Chart extends React.Component {
|
class Chart extends React.Component {
|
||||||
calculateChartData = () => {
|
calculateChartData = () => {
|
||||||
@ -14,7 +13,7 @@ class Chart extends React.Component {
|
|||||||
)[1]
|
)[1]
|
||||||
//apply cropping
|
//apply cropping
|
||||||
this.props.stateCounts[i]["values"] =
|
this.props.stateCounts[i]["values"] =
|
||||||
this.props.stateCounts[i]["values"].slice(0, this.props.animationLength);
|
this.props.stateCounts[i]["values"].slice(0, this.props.animationLength + 1);
|
||||||
}
|
}
|
||||||
return this.props.stateCounts;
|
return this.props.stateCounts;
|
||||||
}
|
}
|
||||||
@ -22,7 +21,7 @@ class Chart extends React.Component {
|
|||||||
render() {
|
render() {
|
||||||
return(
|
return(
|
||||||
<div id="chart">
|
<div id="chart">
|
||||||
<NVD3Chart type="stackedAreaChart" xAxis={{ tickFormat: (d) => d + 1}} datum={this.calculateChartData} x={(d) => d[0]} y={(d) => d[1]} />
|
<NVD3Chart type="stackedAreaChart" xAxis={{ tickFormat: (d) => d}} datum={this.calculateChartData} x={(d) => d[0]} y={(d) => d[1]} />
|
||||||
</div>);
|
</div>);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import '../../css/Graph.css';
|
import '../../css/Graph.css';
|
||||||
import '../../css/GIFGenerator.css';
|
import '../../css/GIFGenerator.css';
|
||||||
import Slider from '../Slider';
|
|
||||||
import GIF from '@dhdbstjr98/gif.js';
|
import GIF from '@dhdbstjr98/gif.js';
|
||||||
|
|
||||||
class GIFGenerator extends React.Component {
|
class GIFGenerator extends React.Component {
|
||||||
|
|||||||
@ -121,7 +121,6 @@ class Graph extends React.Component {
|
|||||||
this.neverPlayed = false;
|
this.neverPlayed = false;
|
||||||
//check if we pause the animation
|
//check if we pause the animation
|
||||||
clearInterval(this.animationId);
|
clearInterval(this.animationId);
|
||||||
console.log("new animation started");
|
|
||||||
this.setState({playing: false});
|
this.setState({playing: false});
|
||||||
//first we need to normalize the distribution
|
//first we need to normalize the distribution
|
||||||
this.props.normalize();
|
this.props.normalize();
|
||||||
@ -147,9 +146,7 @@ class Graph extends React.Component {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (this.state.step > this.props.animationLength) {
|
if (this.state.step > this.props.animationLength) {
|
||||||
console.log("finished animation");
|
this.finishAnimation();
|
||||||
clearInterval(this.animationId);
|
|
||||||
this.setState({playing: false});
|
|
||||||
return;
|
return;
|
||||||
//this.setState({step: 0}, () => {
|
//this.setState({step: 0}, () => {
|
||||||
//return;
|
//return;
|
||||||
@ -172,13 +169,22 @@ class Graph extends React.Component {
|
|||||||
this.cy.getElementById(allNodes[i].id()).style('background-color', color); }
|
this.cy.getElementById(allNodes[i].id()).style('background-color', color); }
|
||||||
|
|
||||||
if (increment) {
|
if (increment) {
|
||||||
|
if (this.state.step < this.props.animationLength) {
|
||||||
this.setState({step: this.state.step + 1});
|
this.setState({step: this.state.step + 1});
|
||||||
|
} else {
|
||||||
|
this.finishAnimation();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
//update
|
//update
|
||||||
this.setState({});
|
this.setState({});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
finishAnimation() {
|
||||||
|
clearInterval(this.animationId);
|
||||||
|
this.setState({playing: false, step: this.props.animationLength});
|
||||||
|
}
|
||||||
|
|
||||||
visualizeSpecificStep = (e) => {
|
visualizeSpecificStep = (e) => {
|
||||||
var val = Number(e.target.value);
|
var val = Number(e.target.value);
|
||||||
if (val < 0 || val > this.props.animationLength) {
|
if (val < 0 || val > this.props.animationLength) {
|
||||||
|
|||||||
@ -25,11 +25,13 @@ class Visual extends React.Component {
|
|||||||
//if (this.checkIfStatesAreEqual(data, lastState, i)) {
|
//if (this.checkIfStatesAreEqual(data, lastState, i)) {
|
||||||
//lastState = i;
|
//lastState = i;
|
||||||
//}
|
//}
|
||||||
|
//console.log(data[lastState], data[i])
|
||||||
|
//console.log(data[lastState] === data[i])
|
||||||
if (data[lastState] === data[i]) {
|
if (data[lastState] === data[i]) {
|
||||||
lastState = i;
|
lastState = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.setState({animationLength: lastState + 1})
|
this.setState({animationLength: lastState})
|
||||||
//this.animationLength = lastState + 1;
|
//this.animationLength = lastState + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,11 +40,12 @@ class Visual extends React.Component {
|
|||||||
//normalize
|
//normalize
|
||||||
this.props.normalize();
|
this.props.normalize();
|
||||||
//then recalculate
|
//then recalculate
|
||||||
this.props.recalculateFuntion();
|
this.props.recalculateFuntion().then(() => {
|
||||||
//now crop
|
//now crop
|
||||||
this.cropAnimation();
|
this.cropAnimation();
|
||||||
//update the colors for the chart
|
//update the colors for the chart
|
||||||
this.setState({newColors: this.props.colors});
|
this.setState({newColors: this.props.colors});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
switchView = () => {
|
switchView = () => {
|
||||||
|
|||||||
@ -49,8 +49,6 @@ function get_next_state(current_labels){
|
|||||||
edge = graph_as_edgelist[edge];
|
edge = graph_as_edgelist[edge];
|
||||||
let node1 = edge[0];
|
let node1 = edge[0];
|
||||||
let node2 = edge[1];
|
let node2 = edge[1];
|
||||||
if(node2 === 0) {
|
|
||||||
}
|
|
||||||
let current_state1 = current_labels[node1];
|
let current_state1 = current_labels[node1];
|
||||||
let current_state2 = current_labels[node2];
|
let current_state2 = current_labels[node2];
|
||||||
for(var currentRule in rules){
|
for(var currentRule in rules){
|
||||||
@ -101,7 +99,7 @@ function get_next_state(current_labels){
|
|||||||
function count_states(current_labels){
|
function count_states(current_labels){
|
||||||
var counter = [];
|
var counter = [];
|
||||||
|
|
||||||
for (var _ in states) {
|
for (var j = 0; j < states.length; j++) {
|
||||||
counter.push(0);
|
counter.push(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user