blob: c79431d1f4d69e3dd482acace773d5869080acac [file] [log] [blame]
package org.eclipse.stem.diseasemodels.experimental.impl;
/*******************************************************************************
* Copyright (c) 2011 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
import org.eclipse.emf.ecore.EClass;
import org.eclipse.stem.core.graph.LabelValue;
import org.eclipse.stem.core.model.STEMTime;
import org.eclipse.stem.diseasemodels.experimental.ExperimentalFactory;
import org.eclipse.stem.diseasemodels.experimental.ExperimentalPackage;
import org.eclipse.stem.diseasemodels.experimental.TBDiseaseModel;
import org.eclipse.stem.diseasemodels.experimental.TBDiseaseModelLabelValue;
import org.eclipse.stem.diseasemodels.standard.DiseaseModelLabel;
import org.eclipse.stem.diseasemodels.standard.DiseaseModelLabelValue;
import org.eclipse.stem.diseasemodels.standard.Infector;
import org.eclipse.stem.diseasemodels.standard.SIInfector;
import org.eclipse.stem.diseasemodels.standard.StandardDiseaseModelLabel;
import org.eclipse.stem.diseasemodels.standard.StandardDiseaseModelLabelValue;
import org.eclipse.stem.diseasemodels.standard.StandardFactory;
import org.eclipse.stem.diseasemodels.standard.impl.StandardDiseaseModelImpl;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>TB Disease Model</b></em>'.
* <!-- end-user-doc -->
* <p>
* </p>
*
* @generated
*/
public class TBDiseaseModelImpl extends StandardDiseaseModelImpl implements TBDiseaseModel {
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated NOT
*/
public TBDiseaseModelImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return ExperimentalPackage.Literals.TB_DISEASE_MODEL;
}
public void doModelSpecificAdjustments(LabelValue label) {
// TODO Auto-generated method stub
}
@Override
public StandardDiseaseModelLabelValue computeDiseaseDeltas(STEMTime time,
StandardDiseaseModelLabelValue currentState,
StandardDiseaseModelLabel diseaseLabel, long timeDelta,
DiseaseModelLabelValue returnValue) {
// Just hard code the parameters for now
double beta = 0.4; // Transmission rate;
double p = 0.6; // Probability that a new infection becomes active infection. (1-p) is probability that it becomes latent
TBDiseaseModelLabelValue tbdelta = (TBDiseaseModelLabelValue)returnValue;
TBDiseaseModelLabelValue tbcurr = (TBDiseaseModelLabelValue)currentState;
double S = tbcurr.getS();
double iaEff = getNormalizedEffectiveInfectious(diseaseLabel.getNode(), diseaseLabel, tbcurr.getIa(), ExperimentalPackage.Literals.TB_DISEASE_MODEL_LABEL_VALUE__IA);
tbdelta.setIa(beta*S*p*iaEff);
tbdelta.setIl(beta*S*(1-p)*iaEff);
double incidence = beta*S*tbcurr.getIa() / tbcurr.getPopulationCount();
tbdelta.setS(-incidence);
tbdelta.setIncidence(incidence);
return (StandardDiseaseModelLabelValue)returnValue;
}
@Override
public DiseaseModelLabel createDiseaseModelLabel(String populationIdentifier) {
return ExperimentalFactory.eINSTANCE.createTBDiseaseModelLabel();
}
@Override
public DiseaseModelLabelValue createDiseaseModelLabelValue(String populationIdentifier) {
return ExperimentalFactory.eINSTANCE.createTBDiseaseModelLabelValue();
}
@Override
public Infector createInfector() {
SIInfector retValue = StandardFactory.eINSTANCE.createSIInfector();
retValue.setDiseaseName(this.getDiseaseName());
retValue.setPopulationIdentifier(getPopulationIdentifier());
return retValue;
}
} //TBDiseaseModelImpl