updates and final touches... even more to come
This commit is contained in:
parent
8e20c7a480
commit
94f125d339
@ -20,7 +20,7 @@ class Simulation extends React.Component{
|
||||
this.modelChanged = this.modelChanged.bind(this);
|
||||
this.recalculate = this.recalculate.bind(this);
|
||||
|
||||
//HERE WE SET THE DEFAULT VALUES, THIS MUST BE CONSISTEN!!!!!
|
||||
//HERE WE SET THE DEFAULT VALUES, THIS MUST BE CONSISTENT!!!!!
|
||||
this.networkObject = new KarateClass();
|
||||
this.modelObject = new SIModel();
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@ import Model from "./Model";
|
||||
|
||||
class CoronaModel extends Model {
|
||||
constructor() {
|
||||
super("CoronaModel",
|
||||
super("Corona-Model",
|
||||
[["S", 0.965, "#1F85DE"], ["I1", 0.005, "#de1f50"], ["I2", 0.005, "#b91fde"], ["I3", 0.005, "#1fdea7"], ["R", 0.005, "#8fde1f"], ["V", 0.005, "#de801f"], ["D", 0.005, "#3b0b0b"]],
|
||||
[[["I1", "S"], ["I2", "E"], 0.15],
|
||||
[["I2", "S"], ["I2", "E"], 0.05],
|
||||
|
||||
@ -2,7 +2,7 @@ import Model from "./Model";
|
||||
|
||||
class SEIRSModel extends Model {
|
||||
constructor() {
|
||||
super("SEIRSModel",
|
||||
super("SEIRS-Model",
|
||||
[["E", 0.03, "#1F85DE"], ["I", 0.03, "#de1f50"], ["R", 0.03, "#b91fde"], ["S", 0.91, "#1fdea7"]],
|
||||
[[["S", "I"], ["I", "E"], 0.5],
|
||||
["E", "I", 0.5],
|
||||
|
||||
@ -2,7 +2,7 @@ import Model from "./Model";
|
||||
|
||||
class SIModel extends Model {
|
||||
constructor() {
|
||||
super("SI Model",
|
||||
super("SI-Model",
|
||||
[["S", 0.9, "#0FA75F"], ["I", 0.1, "#ff225b"]],
|
||||
[[["S", "I"],["I", "I"], 0.5]],
|
||||
20, 0.05);
|
||||
|
||||
@ -21,7 +21,7 @@ class Chart extends React.Component {
|
||||
render() {
|
||||
return(
|
||||
<div id="chart">
|
||||
<NVD3Chart type="stackedAreaChart" xAxis={{ tickFormat: (d) => d}} datum={this.calculateChartData} x={(d) => d[0]} y={(d) => d[1]} />
|
||||
<NVD3Chart type="stackedAreaChart" xAxis={{ tickFormat: (d) => this.props.timeSteps[d]}} datum={this.calculateChartData} x={(d) => d[0]} y={(d) => d[1]} />
|
||||
</div>);
|
||||
}
|
||||
}
|
||||
|
||||
@ -68,7 +68,7 @@ class Visual extends React.Component {
|
||||
} else {
|
||||
return (
|
||||
<div id="chart">
|
||||
<Chart stateCounts={this.props.simulationData.stateCounts} colors={this.state.newColors} animationLength={this.state.animationLength}/>
|
||||
<Chart stateCounts={this.props.simulationData.stateCounts} timeSteps={this.props.simulationData.timeSteps} colors={this.state.newColors} animationLength={this.state.animationLength}/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@ -97,6 +97,9 @@ function get_next_state(current_labels){
|
||||
|
||||
|
||||
function count_states(current_labels){
|
||||
//add time steps
|
||||
time_steps.push(timepoints_samples[0]);
|
||||
|
||||
var counter = [];
|
||||
|
||||
for (var j = 0; j < states.length; j++) {
|
||||
@ -117,6 +120,7 @@ function count_states(current_labels){
|
||||
for (var i = 0; i < states.length; i++) {
|
||||
state_counts[i]["values"].push( [newX, counter[i]] );
|
||||
}
|
||||
console.log(state_counts)
|
||||
}
|
||||
|
||||
function generateNodes(edgelist){
|
||||
@ -193,6 +197,7 @@ let current_labels;
|
||||
let global_clock;
|
||||
let labels = [];
|
||||
let state_counts = {};
|
||||
let time_steps = [];
|
||||
|
||||
function simulate(newRules, newStates, newDistr, newGraph, newHorizon){
|
||||
simulation = [];
|
||||
@ -226,7 +231,8 @@ function simulate(newRules, newStates, newDistr, newGraph, newHorizon){
|
||||
}
|
||||
current_labels = new_labels;
|
||||
}
|
||||
return {data: simulation, stateCounts: state_counts};
|
||||
console.log(time_steps)
|
||||
return {data: simulation, stateCounts: state_counts, timeSteps: time_steps};
|
||||
}
|
||||
|
||||
export default simulate;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user