stash
This commit is contained in:
parent
831c3f9db9
commit
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(){
|
||||||
|
|||||||
@ -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,10 +2,10 @@ 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 = () => {
|
||||||
|
console.log(this.props.animationLength)
|
||||||
for (let i = 0; i < this.props.stateCounts.length; i++) {
|
for (let i = 0; i < this.props.stateCounts.length; i++) {
|
||||||
//set color
|
//set color
|
||||||
this.props.stateCounts[i].color =
|
this.props.stateCounts[i].color =
|
||||||
@ -14,7 +14,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 +22,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 {
|
||||||
|
|||||||
@ -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 = () => {
|
||||||
|
|||||||
@ -59,6 +59,7 @@ function get_next_state(current_labels){
|
|||||||
//is spont. rule
|
//is spont. rule
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
console.log("works")
|
||||||
if((current_state1 === currentRule[0][0] && current_state2 === currentRule[0][1]) || (current_state2 === currentRule[0][0] && current_state1 === currentRule[0][1])){
|
if((current_state1 === currentRule[0][0] && current_state2 === currentRule[0][1]) || (current_state2 === currentRule[0][0] && current_state1 === currentRule[0][1])){
|
||||||
let current_fireing_time = randomExponential(currentRule[2]);
|
let current_fireing_time = randomExponential(currentRule[2]);
|
||||||
if(current_fireing_time < fastes_firing_time){
|
if(current_fireing_time < fastes_firing_time){
|
||||||
@ -101,7 +102,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