public code v1
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>flintstones.group</groupId>
|
||||
<artifactId>flintstones.bundles</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>flintstones.entity.sensitiveanalysismodel.ahp.mcc</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<packaging>eclipse-plugin</packaging>
|
||||
<name>[bundle] AHP</name>
|
||||
</project>
|
||||
@@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>flintstones.entity.sensitiveanalysismodel.ahp.mcc</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.ManifestBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.SchemaBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||
<nature>org.eclipse.pde.PluginNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
<filteredResources>
|
||||
<filter>
|
||||
<id>1779484362574</id>
|
||||
<name></name>
|
||||
<type>30</type>
|
||||
<matcher>
|
||||
<id>org.eclipse.core.resources.regexFilterMatcher</id>
|
||||
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
|
||||
</matcher>
|
||||
</filter>
|
||||
</filteredResources>
|
||||
</projectDescription>
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding/<project>=UTF-8
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
activeProfiles=
|
||||
eclipse.preferences.version=1
|
||||
resolveWorkspaceProjects=true
|
||||
version=1
|
||||
@@ -0,0 +1,15 @@
|
||||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: AHP
|
||||
Bundle-SymbolicName: flintstones.entity.sensitiveanalysismodel.ahp.mcc;singleton:=true
|
||||
Bundle-Version: 1.0.0.qualifier
|
||||
Automatic-Module-Name: flintstones.method.common.phase.sensitiveanalysis.mcc.ahp
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-11
|
||||
Require-Bundle: flintstones.entity.sensitiveanalysismodel,
|
||||
flintstones.model.problemelement.service,
|
||||
flintstones.valuation.twoTuple,
|
||||
flintstones.valuation.numeric,
|
||||
javax.inject,
|
||||
org.eclipse.e4.core.di.annotations,
|
||||
flintstones.valuation.fuzzy
|
||||
Export-Package: flintstones.entity.sensitiveanalysismodel.ahp.mcc
|
||||
@@ -0,0 +1,5 @@
|
||||
source.. = src/
|
||||
output.. = bin/
|
||||
bin.includes = META-INF/,\
|
||||
.,\
|
||||
plugin.xml
|
||||
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?eclipse version="3.4"?>
|
||||
<plugin>
|
||||
<extension
|
||||
point="flintstones.entity.sensitiveanalysismodel.extension">
|
||||
<model
|
||||
uid="flintstones.entity.sensitiveanalysismodel.mcc.ahp"
|
||||
implementation="flintstones.entity.sensitiveanalysismodel.ahp.mcc.AnalyticHierarchyProcessMCCTwoTuple"
|
||||
name="analytic hierarchy process">
|
||||
</model>
|
||||
<model
|
||||
implementation="flintstones.entity.sensitiveanalysismodel.ahp.mcc.AnalyticHierarchyProcessMCCNumeric"
|
||||
name="analytic hierarchy process"
|
||||
uid="flintstones.entity.sensitiveanalysismodel.mcc.ahp.numeric">
|
||||
</model>
|
||||
<model
|
||||
implementation="flintstones.entity.sensitiveanalysismodel.ahp.mcc.AnalyticHierarchyProcessMCCFuzzy"
|
||||
name="analytic hierarchy process"
|
||||
uid="flintstones.entity.sensitiveanalysismodel.mcc.ahp.fuzzy">
|
||||
</model>
|
||||
</extension>
|
||||
|
||||
</plugin>
|
||||
+314
@@ -0,0 +1,314 @@
|
||||
package flintstones.entity.sensitiveanalysismodel.ahp.mcc;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.eclipse.e4.core.di.annotations.Optional;
|
||||
|
||||
import flintstones.entity.problemelement.entities.Alternative;
|
||||
import flintstones.entity.problemelement.entities.Criterion;
|
||||
import flintstones.entity.problemelement.entities.ProblemElement;
|
||||
import flintstones.entity.sensitiveanalysismodel.SensitiveAnalysisModel;
|
||||
import flintstones.entity.valuation.Valuation;
|
||||
import flintstones.helper.data.HashMatrix;
|
||||
import flintstones.model.problemelement.service.IProblemElementService;
|
||||
|
||||
public abstract class AnalyticHierarchyProcessMCC extends SensitiveAnalysisModel {
|
||||
|
||||
@Inject
|
||||
@Optional
|
||||
IProblemElementService problemService;
|
||||
|
||||
protected Double[] alternativesFinalPreferences;
|
||||
|
||||
protected Double[][][] minimumAbsoluteChangeInCriteriaWeights;
|
||||
protected Double[][][] minimumRelativeChangeInCriteriaWeights;
|
||||
|
||||
protected List<Integer> absoluteTop;
|
||||
protected List<Integer> absoluteAny;
|
||||
protected List<Integer> relativeTop;
|
||||
protected List<Integer> relativeAny;
|
||||
|
||||
protected int numAlternatives;
|
||||
protected int numCriteria;
|
||||
|
||||
public AnalyticHierarchyProcessMCC() {}
|
||||
|
||||
public Map<ProblemElement, Double> getCriteriaWeights() {
|
||||
return criteriaWeights;
|
||||
}
|
||||
|
||||
public void setCriteriaWeights(Map<ProblemElement, Double> criteriaWeights) {
|
||||
this.criteriaWeights = criteriaWeights;
|
||||
}
|
||||
|
||||
public Double[] getAlternativesFinalPreferences() {
|
||||
return alternativesFinalPreferences;
|
||||
}
|
||||
|
||||
public void setAlternativesFinalPreferences(Double[] alternativesFinalPreferences) {
|
||||
this.alternativesFinalPreferences = alternativesFinalPreferences;
|
||||
}
|
||||
|
||||
public Double[][][] getMinimumAbsoluteChangeInCriteriaWeights() {
|
||||
return minimumAbsoluteChangeInCriteriaWeights;
|
||||
}
|
||||
|
||||
public void setMinimumAbsoluteChangeInCriteriaWeights(Double[][][] minimumAbsoluteChangeInCriteriaWeights) {
|
||||
this.minimumAbsoluteChangeInCriteriaWeights = minimumAbsoluteChangeInCriteriaWeights;
|
||||
}
|
||||
|
||||
public Double[][][] getMinimumRelativeChangeInCriteriaWeights() {
|
||||
return minimumRelativeChangeInCriteriaWeights;
|
||||
}
|
||||
|
||||
public void setMinimumRelativeChangeInCriteriaWeights(Double[][][] minimumRelativeChangeInCriteriaWeights) {
|
||||
this.minimumRelativeChangeInCriteriaWeights = minimumRelativeChangeInCriteriaWeights;
|
||||
}
|
||||
|
||||
public List<Integer> getAbsoluteTop() {
|
||||
return absoluteTop;
|
||||
}
|
||||
|
||||
public void setAbsoluteTop(List<Integer> absoluteTop) {
|
||||
this.absoluteTop = absoluteTop;
|
||||
}
|
||||
|
||||
public List<Integer> getAbsoluteAny() {
|
||||
return absoluteAny;
|
||||
}
|
||||
|
||||
public void setAbsoluteAny(List<Integer> absoluteAny) {
|
||||
this.absoluteAny = absoluteAny;
|
||||
}
|
||||
|
||||
public List<Integer> getRelativeTop() {
|
||||
return relativeTop;
|
||||
}
|
||||
|
||||
public void setRelativeTop(List<Integer> relativeTop) {
|
||||
this.relativeTop = relativeTop;
|
||||
}
|
||||
|
||||
public List<Integer> getRelativeAny() {
|
||||
return relativeAny;
|
||||
}
|
||||
|
||||
public void setRelativeAny(List<Integer> relativeAny) {
|
||||
this.relativeAny = relativeAny;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(HashMatrix<ProblemElement, ProblemElement, Valuation> decisionMatrix, Map<ProblemElement, Double> criteriaWeights) {
|
||||
numAlternatives = problemService.getAll(Alternative.Type).length;
|
||||
numCriteria = problemService.getMainElements(Criterion.Type).length;
|
||||
|
||||
this.setCriteriaWeights(criteriaWeights);
|
||||
this.normalizeDecisionMatrix(decisionMatrix);
|
||||
this.computeFinalPreferences();
|
||||
this.computeRanking();
|
||||
this.computeMinimumAbsoluteChangeInCriteriaWeights();
|
||||
this.computeMinimumRelativeChangeInCriteriaWeights();
|
||||
this.computeAbsoluteTopCriticalCriterion();
|
||||
this.computeAbsoluteAnyCriticalCriterion();
|
||||
this.computeRelativeTopCriticalCriterion();
|
||||
this.computeRelativeAnyCriticalCriterion();
|
||||
}
|
||||
|
||||
protected abstract void normalizeDecisionMatrix(HashMatrix<ProblemElement, ProblemElement, Valuation> decisionMatrixAggregation);
|
||||
|
||||
private void computeFinalPreferences() {
|
||||
alternativesFinalPreferences = new Double[numAlternatives];
|
||||
for (int alternative = 0; alternative < numAlternatives; alternative++) {
|
||||
alternativesFinalPreferences[alternative] = 0d;
|
||||
for (int criterion = 0; criterion < numCriteria; criterion++) {
|
||||
alternativesFinalPreferences[alternative] += decisionMatrix[alternative][criterion] *
|
||||
criteriaWeights.get(problemService.getMainElements(Criterion.Type)[criterion]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void computeRanking() {
|
||||
ranking = IntStream.range(0, alternativesFinalPreferences.length)
|
||||
.boxed().sorted((j, i) -> alternativesFinalPreferences[i].compareTo(alternativesFinalPreferences[j]))
|
||||
.mapToInt(ele -> ele).toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Compute the minimum change in absolute terms to apply in criteria weights so that there is an exchange among any pair of alternatives
|
||||
*/
|
||||
private void computeMinimumAbsoluteChangeInCriteriaWeights() {
|
||||
minimumAbsoluteChangeInCriteriaWeights = new Double[numAlternatives][numAlternatives][numCriteria];
|
||||
|
||||
for (int i = 0; i < numAlternatives - 1; i++) {
|
||||
for (int j = i + 1; j < numAlternatives; j++) {
|
||||
for (int k = 0; k < numCriteria; k++) {
|
||||
if ((Double) decisionMatrix[j][k] - (Double) decisionMatrix[i][k] == 0)
|
||||
minimumAbsoluteChangeInCriteriaWeights[i][j][k] = NON_FEASIBLE;
|
||||
else {
|
||||
minimumAbsoluteChangeInCriteriaWeights[i][j][k] = (alternativesFinalPreferences[j] - alternativesFinalPreferences[i])
|
||||
/ ((Double) decisionMatrix[j][k] - (Double) decisionMatrix[i][k]);
|
||||
|
||||
if (minimumAbsoluteChangeInCriteriaWeights[i][j][k] > criteriaWeights.get(problemService.getMainElements(Criterion.Type)[k]))
|
||||
minimumAbsoluteChangeInCriteriaWeights[i][j][k] = NON_FEASIBLE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Compute the minimum change in relative terms to apply in criteria weights so that there is an exchange among any pair of alternatives
|
||||
*/
|
||||
private void computeMinimumRelativeChangeInCriteriaWeights() {
|
||||
minimumRelativeChangeInCriteriaWeights = new Double[numAlternatives][numAlternatives][numCriteria];
|
||||
|
||||
for (int i = 0; i < numAlternatives - 1; i++) {
|
||||
for (int j = i + 1; j < numAlternatives; j++) {
|
||||
for (int k = 0; k < numCriteria; k++) {
|
||||
if (minimumAbsoluteChangeInCriteriaWeights[i][j][k] != NON_FEASIBLE)
|
||||
minimumRelativeChangeInCriteriaWeights[i][j][k] = minimumAbsoluteChangeInCriteriaWeights[i][j][k] * (100d / criteriaWeights.get(
|
||||
problemService.getMainElements(Criterion.Type)[k]));
|
||||
else
|
||||
minimumRelativeChangeInCriteriaWeights[i][j][k] = NON_FEASIBLE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Look for the minimal change in absolute terms among the best alternative/s and the rest of them
|
||||
*/
|
||||
private void computeAbsoluteTopCriticalCriterion() {
|
||||
List<Integer> bestAlternatives = getBestAlternatives();
|
||||
|
||||
absoluteTop = new LinkedList<Integer>();
|
||||
|
||||
Double minimum = Double.MAX_VALUE, change;
|
||||
for (int i = 0; i < bestAlternatives.size(); i++) {
|
||||
for (int j = 0; j < numAlternatives; j++) {
|
||||
for (int k = 0; k < numCriteria; k++) {
|
||||
change = minimumAbsoluteChangeInCriteriaWeights[bestAlternatives.get(i)][j][k];
|
||||
if (change != NON_FEASIBLE) {
|
||||
change = Math.abs(change);
|
||||
if (change < minimum) {
|
||||
minimum = change;
|
||||
absoluteTop.clear();
|
||||
absoluteTop.add(Integer.valueOf(k));
|
||||
} else if (change == minimum)
|
||||
absoluteTop.add(Integer.valueOf(k));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the indexes of the best alternatives
|
||||
* @return indexes of the best alternatives
|
||||
*/
|
||||
private List<Integer> getBestAlternatives() {
|
||||
List<Integer> bestAlternatives = new LinkedList<Integer>();
|
||||
for (int i = 0; i < numAlternatives; i++) {
|
||||
if (ranking[i] == 0)
|
||||
bestAlternatives.add(Integer.valueOf(i));
|
||||
}
|
||||
return bestAlternatives;
|
||||
}
|
||||
|
||||
/**
|
||||
* Look for the minimal change in absolute terms among all the alternatives
|
||||
*/
|
||||
private void computeAbsoluteAnyCriticalCriterion() {
|
||||
|
||||
absoluteAny = new LinkedList<Integer>();
|
||||
|
||||
Double minimum = Double.MAX_VALUE, change;
|
||||
for (int i = 0; i < numAlternatives - 1; i++) {
|
||||
for (int j = i + 1; j < numAlternatives; j++) {
|
||||
for (int k = 0; k < numCriteria; k++) {
|
||||
change = minimumAbsoluteChangeInCriteriaWeights[i][j][k];
|
||||
if (change != NON_FEASIBLE) {
|
||||
change = Math.abs(change);
|
||||
if (change < minimum) {
|
||||
minimum = change;
|
||||
absoluteAny.clear();
|
||||
absoluteAny.add(Integer.valueOf(k));
|
||||
} else if (change == minimum)
|
||||
absoluteAny.add(Integer.valueOf(k));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Look for the minimal change in relative terms among the best alternative/s and the rest of them
|
||||
*/
|
||||
private void computeRelativeTopCriticalCriterion() {
|
||||
List<Integer> bestAlternatives = getBestAlternatives();
|
||||
|
||||
relativeTop = new LinkedList<Integer>();
|
||||
|
||||
Double minimum = Double.MAX_VALUE, change;
|
||||
for (int i = 0; i < bestAlternatives.size(); i++) {
|
||||
for (int j = 0; j < numAlternatives; j++) {
|
||||
for (int k = 0; k < numCriteria; k++) {
|
||||
change = minimumRelativeChangeInCriteriaWeights[bestAlternatives.get(i)][j][k];
|
||||
if (change != NON_FEASIBLE) {
|
||||
change = Math.abs(change);
|
||||
if (change < minimum) {
|
||||
minimum = change;
|
||||
relativeTop.clear();
|
||||
relativeTop.add(Integer.valueOf(k));
|
||||
} else if (change == minimum)
|
||||
relativeTop.add(Integer.valueOf(k));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Look for the minimal change in absolute terms among all the alternatives
|
||||
*/
|
||||
private void computeRelativeAnyCriticalCriterion() {
|
||||
|
||||
relativeAny = new LinkedList<Integer>();
|
||||
|
||||
Double minimum = Double.MAX_VALUE, change;
|
||||
for (int i = 0; i < numAlternatives - 1; i++) {
|
||||
for (int j = i + 1; j < numAlternatives; j++) {
|
||||
for (int k = 0; k < numCriteria; k++) {
|
||||
change = minimumRelativeChangeInCriteriaWeights[i][j][k];
|
||||
if (change != NON_FEASIBLE) {
|
||||
change = Math.abs(change);
|
||||
if (change < minimum) {
|
||||
minimum = change;
|
||||
relativeAny.clear();
|
||||
relativeAny.add(Integer.valueOf(k));
|
||||
} else if (change == minimum)
|
||||
relativeAny.add(Integer.valueOf(k));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double[][][] getChanges(FieldsChanges typeOfChange) {
|
||||
switch(typeOfChange) {
|
||||
case absolute:
|
||||
return minimumAbsoluteChangeInCriteriaWeights;
|
||||
case relative:
|
||||
return minimumRelativeChangeInCriteriaWeights;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
package flintstones.entity.sensitiveanalysismodel.ahp.mcc;
|
||||
|
||||
import flintstones.entity.problemelement.entities.Alternative;
|
||||
import flintstones.entity.problemelement.entities.Criterion;
|
||||
import flintstones.entity.problemelement.entities.ProblemElement;
|
||||
import flintstones.entity.valuation.Valuation;
|
||||
import flintstones.helper.data.HashMatrix;
|
||||
import flintstones.valuation.fuzzy.FuzzyValuation;
|
||||
|
||||
public class AnalyticHierarchyProcessMCCFuzzy extends AnalyticHierarchyProcessMCC {
|
||||
|
||||
@Override
|
||||
protected void normalizeDecisionMatrix(HashMatrix<ProblemElement, ProblemElement, Valuation> decisionMatrixAggregation) {
|
||||
decisionMatrix = new Double[problemService.getAll(Alternative.Type).length][problemService.getMainElements(Criterion.Type).length];
|
||||
|
||||
int critPos = 0, altPos;
|
||||
for(ProblemElement crit: problemService.getMainElements(Criterion.Type)) {
|
||||
altPos = 0;
|
||||
for(ProblemElement alt: problemService.getAll(Alternative.Type)) {
|
||||
decisionMatrix[altPos][critPos] = ((FuzzyValuation) decisionMatrixAggregation.get(alt, crit)).getFuzzyNumber().getB();
|
||||
altPos++;
|
||||
}
|
||||
critPos++;
|
||||
}
|
||||
normalize();
|
||||
}
|
||||
|
||||
private Double[][] normalize() {
|
||||
double acum, noStandarizedValue;
|
||||
|
||||
for (int i = 0; i < numCriteria; ++i) {
|
||||
acum = sumCriteria(i);
|
||||
for (int j = 0; j < numAlternatives; ++j) {
|
||||
noStandarizedValue = (Double) decisionMatrix[j][i];
|
||||
decisionMatrix[j][i] = (double) Math.round((noStandarizedValue / acum) * 10000d) / 10000d;
|
||||
}
|
||||
}
|
||||
|
||||
return decisionMatrix;
|
||||
}
|
||||
|
||||
private double sumCriteria(int numCriterion) {
|
||||
double value = 0;
|
||||
for (int j = 0; j < numAlternatives; ++j) {
|
||||
value += Math.pow((Double) decisionMatrix[j][numCriterion], 2);
|
||||
}
|
||||
return Math.sqrt(value);
|
||||
}
|
||||
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
package flintstones.entity.sensitiveanalysismodel.ahp.mcc;
|
||||
|
||||
import flintstones.entity.problemelement.entities.Alternative;
|
||||
import flintstones.entity.problemelement.entities.Criterion;
|
||||
import flintstones.entity.problemelement.entities.ProblemElement;
|
||||
import flintstones.entity.valuation.Valuation;
|
||||
import flintstones.helper.data.HashMatrix;
|
||||
import flintstones.valuation.numeric.NumericValuation;
|
||||
|
||||
public class AnalyticHierarchyProcessMCCNumeric extends AnalyticHierarchyProcessMCC {
|
||||
|
||||
@Override
|
||||
protected void normalizeDecisionMatrix(HashMatrix<ProblemElement, ProblemElement, Valuation> decisionMatrixAggregation) {
|
||||
decisionMatrix = new Double[problemService.getAll(Alternative.Type).length][problemService.getSubElements(Criterion.Type).length];
|
||||
|
||||
int critPos = 0, altPos;
|
||||
for(ProblemElement crit: problemService.getSubElements(Criterion.Type)) {
|
||||
altPos = 0;
|
||||
for(ProblemElement alt: problemService.getAll(Alternative.Type)) {
|
||||
decisionMatrix[altPos][critPos] = ((NumericValuation) decisionMatrixAggregation.get(alt, crit)).getValue();
|
||||
altPos++;
|
||||
}
|
||||
critPos++;
|
||||
}
|
||||
normalize();
|
||||
}
|
||||
|
||||
private Double[][] normalize() {
|
||||
double acum, noStandarizedValue;
|
||||
|
||||
for (int i = 0; i < numCriteria; ++i) {
|
||||
acum = sumCriteria(i);
|
||||
for (int j = 0; j < numAlternatives; ++j) {
|
||||
noStandarizedValue = (Double) decisionMatrix[j][i];
|
||||
decisionMatrix[j][i] = (double) Math.round((noStandarizedValue / acum) * 10000d) / 10000d;
|
||||
}
|
||||
}
|
||||
|
||||
return decisionMatrix;
|
||||
}
|
||||
|
||||
private double sumCriteria(int numCriterion) {
|
||||
double value = 0;
|
||||
for (int j = 0; j < numAlternatives; ++j) {
|
||||
value += Math.pow((Double) decisionMatrix[j][numCriterion], 2);
|
||||
}
|
||||
return Math.sqrt(value);
|
||||
}
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
package flintstones.entity.sensitiveanalysismodel.ahp.mcc;
|
||||
|
||||
import flintstones.entity.problemelement.entities.Alternative;
|
||||
import flintstones.entity.problemelement.entities.Criterion;
|
||||
import flintstones.entity.problemelement.entities.ProblemElement;
|
||||
import flintstones.entity.valuation.Valuation;
|
||||
import flintstones.helper.data.HashMatrix;
|
||||
import flintstones.valuation.twoTuple.TwoTupleValuation;
|
||||
|
||||
public class AnalyticHierarchyProcessMCCTwoTuple extends AnalyticHierarchyProcessMCC {
|
||||
|
||||
@Override
|
||||
protected void normalizeDecisionMatrix(HashMatrix<ProblemElement, ProblemElement, Valuation> decisionMatrixAggregation) {
|
||||
decisionMatrix = new Double[problemService.getAll(Alternative.Type).length][problemService.getSubElements(Criterion.Type).length];
|
||||
|
||||
int critPos = 0, altPos;
|
||||
for(ProblemElement crit: problemService.getSubElements(Criterion.Type)) {
|
||||
altPos = 0;
|
||||
for(ProblemElement alt: problemService.getAll(Alternative.Type)) {
|
||||
decisionMatrix[altPos][critPos] = ((TwoTupleValuation) decisionMatrixAggregation.get(alt, crit)).calculateInverseDelta();
|
||||
altPos++;
|
||||
}
|
||||
critPos++;
|
||||
}
|
||||
normalize();
|
||||
}
|
||||
|
||||
private Double[][] normalize() {
|
||||
double acum, noStandarizedValue;
|
||||
|
||||
for (int i = 0; i < numCriteria; ++i) {
|
||||
acum = sumCriteria(i);
|
||||
for (int j = 0; j < numAlternatives; ++j) {
|
||||
noStandarizedValue = (Double) decisionMatrix[j][i];
|
||||
decisionMatrix[j][i] = (double) Math.round((noStandarizedValue / acum) * 10000d) / 10000d;
|
||||
}
|
||||
}
|
||||
|
||||
return decisionMatrix;
|
||||
}
|
||||
|
||||
private double sumCriteria(int numCriterion) {
|
||||
double value = 0;
|
||||
for (int j = 0; j < numAlternatives; ++j) {
|
||||
value += Math.pow((Double) decisionMatrix[j][numCriterion], 2);
|
||||
}
|
||||
return Math.sqrt(value);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user