fixed bugs TODO: fix color change bug
This commit is contained in:
parent
94f125d339
commit
6fee7d3b9a
@ -18,7 +18,7 @@ class ModelSelector extends React.Component{
|
||||
this.custom = new Custom();
|
||||
|
||||
this.state = {predefinedModels: [this.SIModel, this.SEIRSModel, this.CoronaModel, this.custom]
|
||||
, currentValue: "SI Model"};
|
||||
, currentValue: "SI-Model"};
|
||||
this.dropdownChanged = this.dropdownChanged.bind(this);
|
||||
this.updateSelectedModel = this.updateSelectedModel.bind(this);
|
||||
}
|
||||
@ -35,11 +35,11 @@ class ModelSelector extends React.Component{
|
||||
|
||||
renderCustomHtml(){
|
||||
switch(this.state.currentValue){
|
||||
case "SI Model":
|
||||
case "SI-Model":
|
||||
return <SIModel updateSelectedModel={this.updateSelectedModel}/>
|
||||
case "SEIRSModel":
|
||||
case "SEIRS-Model":
|
||||
return <SEIRSModel updateSelectedModel={this.updateSelectedModel}/>
|
||||
case "CoronaModel":
|
||||
case "Corona-Model":
|
||||
return <CoronaModel updateSelectedModel={this.updateSelectedModel}/>
|
||||
case "Custom":
|
||||
return <Custom updateSelectedModel={this.updateSelectedModel}/>
|
||||
|
||||
@ -3,7 +3,7 @@ import Model from "./Model";
|
||||
class CoronaModel extends Model {
|
||||
constructor() {
|
||||
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"]],
|
||||
[["S", 0.830, "#1F85DE"], ["E", 0.1, "#010061"], ["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],
|
||||
[["I3", "S"], ["I3", "E"], 0.05],
|
||||
|
||||
@ -20,6 +20,7 @@ class Custom extends Model {
|
||||
}
|
||||
this.rules = parsedInput.rules;
|
||||
this.states = parsedInput.states;
|
||||
console.log(this.rules, this.states);
|
||||
}
|
||||
|
||||
parseInput(input) {
|
||||
@ -106,8 +107,8 @@ class Custom extends Model {
|
||||
return [...subString, Number(probability)];
|
||||
}
|
||||
//complex (edge) rule
|
||||
let leftSide = [subString.slice(0, subString.length / 2)];
|
||||
let rightSide = [subString.slice(subString.length / 2, subString.length)];
|
||||
let leftSide = subString.slice(0, subString.length / 2);
|
||||
let rightSide = subString.slice(subString.length / 2, subString.length);
|
||||
let out = [leftSide, rightSide, Number(probability)];
|
||||
return out;
|
||||
//let out = [0,0,0];
|
||||
|
||||
@ -170,7 +170,9 @@ class Graph extends React.Component {
|
||||
for (var i = 0; i < allNodes.length; i++) {
|
||||
//the current state of the current node
|
||||
let state = data[this.state.step][i];
|
||||
var color = this.props.colors.find(element => element[0] === state)[1];
|
||||
let color = this.props.colors.find((element) => {
|
||||
return element[0] === state;
|
||||
})[1];
|
||||
|
||||
this.cy.getElementById(allNodes[i].id()).style('background-color', color); }
|
||||
|
||||
|
||||
@ -57,6 +57,7 @@ function get_next_state(current_labels){
|
||||
//is spont. rule
|
||||
continue
|
||||
}
|
||||
//console.log(current_state1, currentRule[0][0])
|
||||
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]);
|
||||
if(current_fireing_time < fastes_firing_time){
|
||||
@ -120,7 +121,6 @@ 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){
|
||||
@ -231,7 +231,6 @@ function simulate(newRules, newStates, newDistr, newGraph, newHorizon){
|
||||
}
|
||||
current_labels = new_labels;
|
||||
}
|
||||
console.log(time_steps)
|
||||
return {data: simulation, stateCounts: state_counts, timeSteps: time_steps};
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user