org.jamesii.samo.local.DifferentialImportance Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of samo Show documentation
Show all versions of samo Show documentation
Sensitivity Analysis of Model Output
package org.jamesii.samo.local;
import java.util.Map;
import org.jamesii.samo.IModel;
public class DifferentialImportance implements ILocalSensitivityAnalysis {
private IModel model;
private Map firstOrderDerivatives;
private Map baseCase;
private Map sensitivityCase;
/**
* The class DifferentialImportance implements local sensitivity analysis by using the first order
* derivatives of the model as basis for a sensitivity measure.
*
*
* See:
*
* - Borgonovo, Emanuele and Plischke, Elmar: "Sensitivity analysis: A review of recent
* advances" (2016)
*
*
* @param model model for sensitivity analysis
* @param firstOrderDerivatives values of the first order derivatives of the model at the base
* case
* @param baseCase point in parameter space
* @param sensitivityCase point in parameter space
*/
public DifferentialImportance(IModel model, Map firstOrderDerivatives,
Map baseCase, Map sensitivityCase) {
this.model = model;
this.firstOrderDerivatives = firstOrderDerivatives;
this.baseCase = baseCase;
this.sensitivityCase = sensitivityCase;
}
/**
* Calculates the elasticity of the specified parameter. The elasticity of a parameter denotes the
* ratio of relative model change to relative input change.
*
* @param parameter name of the model parameter
* @return elasticity of the specified parameter
*/
public double elasticity(String parameter) {
double elasticity =
firstOrderDerivatives.get(parameter) * (baseCase.get(parameter) / model.value(baseCase));
return elasticity;
}
/**
* Calculates the differential importance measure of the specified parameter. The differential
* importance measure denotes ratio of differential change caused by the specified parameter to
* the total differential change.
*
* @param parameter name of the model parameter
* @return differential importance measure of the specified parameter
*/
public double differentialImportanceMeasure(String parameter) {
double d = 0;
double numerator = firstOrderDerivatives.get(parameter)
* (sensitivityCase.get(parameter) - baseCase.get(parameter));
double denominator = 0;
for (String parameter2 : model.getParameters()) {
denominator += firstOrderDerivatives.get(parameter2)
* (sensitivityCase.get(parameter2) - baseCase.get(parameter2));
}
try {
d = numerator / denominator;
} catch (Exception e) {
e.printStackTrace();
}
return d;
}
}