updates and final touches... even more to come

This commit is contained in:
JuliusHerrmann 2022-01-12 17:40:52 +01:00
parent 8e20c7a480
commit 94f125d339
7 changed files with 13 additions and 7 deletions

View File

@ -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();

View File

@ -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],

View File

@ -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],

View File

@ -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);

View File

@ -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>);
}
}

View File

@ -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>
);
}

View File

@ -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;