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.method.todim.phase.result</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<packaging>eclipse-plugin</packaging>
|
||||
<name>[bundle] Result</name>
|
||||
</project>
|
||||
@@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>flintstones.method.todim.phase.result</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>1779484362701</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
|
||||
@@ -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
|
||||
@@ -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: Result
|
||||
Bundle-SymbolicName: flintstones.method.todim.phase.result;singleton:=true
|
||||
Bundle-Version: 1.0.0.qualifier
|
||||
Automatic-Module-Name: flintstones.method.todim.phase.result
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
|
||||
Require-Bundle: org.eclipse.e4.core.contexts,
|
||||
flintstones.model.problemelement.service,
|
||||
flintstones.entity.problemelement,
|
||||
flintstones.model.domain.service,
|
||||
javax.inject,
|
||||
flintstones.entity.method.phase,
|
||||
flintstones.helper.data
|
||||
Export-Package: flintstones.method.todim.phase.result
|
||||
@@ -0,0 +1,5 @@
|
||||
source.. = src/
|
||||
output.. = bin/
|
||||
bin.includes = META-INF/,\
|
||||
.,\
|
||||
plugin.xml
|
||||
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?eclipse version="3.4"?>
|
||||
<plugin>
|
||||
<extension
|
||||
point="flintstones.phasemethod.extensionpoint">
|
||||
<phase
|
||||
uid="flintstones.method.todim.phase.result"
|
||||
implementation="flintstones.method.todim.phase.result.TODIMResult">
|
||||
</phase>
|
||||
</extension>
|
||||
|
||||
</plugin>
|
||||
+300
@@ -0,0 +1,300 @@
|
||||
package flintstones.method.todim.phase.result;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.eclipse.e4.core.contexts.IEclipseContext;
|
||||
|
||||
import flintstones.entity.method.phase.PhaseMethod;
|
||||
import flintstones.entity.problemelement.entities.Alternative;
|
||||
import flintstones.entity.problemelement.entities.Criterion;
|
||||
import flintstones.entity.problemelement.entities.Expert;
|
||||
import flintstones.entity.problemelement.entities.ProblemElement;
|
||||
import flintstones.entity.problemelement.entities.ProblemElementHelper;
|
||||
import flintstones.helper.data.Pair;
|
||||
import flintstones.model.domain.service.IDomainService;
|
||||
import flintstones.model.problemelement.service.IProblemElementService;
|
||||
|
||||
public class TODIMResult extends PhaseMethod {
|
||||
|
||||
@Inject
|
||||
IEclipseContext context;
|
||||
|
||||
@Inject
|
||||
IDomainService domainService;
|
||||
|
||||
@Inject
|
||||
IProblemElementService problemService;
|
||||
|
||||
Alternative[] allAlternatives;
|
||||
Criterion[] allCriteria;
|
||||
Expert[] allexperts;
|
||||
|
||||
double[][] normalizeMatrix;
|
||||
|
||||
double maxWeight;
|
||||
double totalRelativeWeight;
|
||||
double[] relativeWeights;
|
||||
|
||||
String[] pairAlternatives;
|
||||
|
||||
LinkedHashMap<ProblemElement, List<LinkedHashMap<Pair<ProblemElement, ProblemElement>, Double>>> phiMatrix;
|
||||
LinkedHashMap<Pair<ProblemElement, ProblemElement>, Double> deltaMatrix;
|
||||
LinkedHashMap<ProblemElement, Double> etaRanking;
|
||||
|
||||
double deltaSumMax;
|
||||
double deltaSumMin;
|
||||
|
||||
float theta;
|
||||
|
||||
ArrayList< float[] > sensitiveData;
|
||||
|
||||
|
||||
public TODIMResult() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "TODIM Result";
|
||||
}
|
||||
|
||||
//------------------------------- GETS AND SETTERS ---------------------------------
|
||||
public void loadData() {
|
||||
ProblemElement[] pes = problemService.getAll(Alternative.Type);
|
||||
allAlternatives = ProblemElementHelper.asAlternatives(pes);
|
||||
|
||||
pes = problemService.getAll(Criterion.Type);
|
||||
allCriteria = ProblemElementHelper.asCriterions(pes);
|
||||
|
||||
pes = problemService.getAll(Expert.Type);
|
||||
allexperts = ProblemElementHelper.asExperts(pes);
|
||||
|
||||
normalizeMatrix = (double[][]) this.importData("normalizeMatrix");
|
||||
relativeWeights = (double[]) this.importData("relativeWeights");
|
||||
totalRelativeWeight = (double) this.importData("totalRelativeWeight");
|
||||
|
||||
pairAlternatives = new String[allAlternatives.length * (allAlternatives.length - 1)];
|
||||
|
||||
int cont = 0;
|
||||
for(int i = 0; i < allAlternatives.length; ++i) {
|
||||
for(int j = 0; j < allAlternatives.length; ++j) {
|
||||
if(i != j) {
|
||||
pairAlternatives[cont] = allAlternatives[i].getCanonicalName() + " > " + allAlternatives[j].getCanonicalName();
|
||||
cont++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public double[][] getNormalizedMatrix() {
|
||||
return normalizeMatrix;
|
||||
}
|
||||
|
||||
public LinkedHashMap<ProblemElement, List<LinkedHashMap<Pair<ProblemElement, ProblemElement>, Double>>> getPhiMatrix(){
|
||||
return phiMatrix;
|
||||
}
|
||||
|
||||
public LinkedHashMap<Pair<ProblemElement, ProblemElement>, Double> getDeltaMatrix(){
|
||||
return deltaMatrix;
|
||||
}
|
||||
|
||||
public LinkedHashMap<ProblemElement, Double> getEtaRanking() {
|
||||
return etaRanking;
|
||||
}
|
||||
|
||||
public ProblemElement[] getAlternatives() {
|
||||
return allAlternatives;
|
||||
}
|
||||
|
||||
public ProblemElement[] getCriteria() {
|
||||
return allCriteria;
|
||||
}
|
||||
|
||||
public String[] getPairAlternativesNames() {
|
||||
return pairAlternatives;
|
||||
}
|
||||
|
||||
public String[] getAlternativesNames() {
|
||||
String[] str = new String[allAlternatives.length];
|
||||
|
||||
for(int i = 0; i < allAlternatives.length; i++)
|
||||
str[i] = allAlternatives[i].getCanonicalName();
|
||||
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
public String[] getCriterionNames() {
|
||||
String[] str = new String[allCriteria.length];
|
||||
|
||||
for(int i = 0; i < allCriteria.length; i++)
|
||||
str[i] = allCriteria[i].getCanonicalName();
|
||||
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
public ArrayList<float[]> getSensitiveData() {
|
||||
return this.sensitiveData;
|
||||
}
|
||||
|
||||
public void calculateData(float thetaNumber) {
|
||||
theta = thetaNumber;
|
||||
|
||||
calculatePhi();
|
||||
calculateDelta();
|
||||
calculateOverallDominance();
|
||||
}
|
||||
|
||||
/*public void calculateSensitiveData(float thetaNumber, int repetitions) {
|
||||
sensitiveData = new ArrayList<float[]>();
|
||||
float n = thetaNumber / repetitions;
|
||||
|
||||
for(float t = 0; t < thetaNumber; t += n) {
|
||||
theta = t;
|
||||
calculatePhi();
|
||||
calculateDelta();
|
||||
calculateOverallDominance();
|
||||
|
||||
sensitiveData.add(this.etaRanking);
|
||||
}
|
||||
}*/
|
||||
|
||||
private void calculatePhi() {
|
||||
phiMatrix = new LinkedHashMap<ProblemElement, List<LinkedHashMap<Pair<ProblemElement, ProblemElement>, Double>>>();
|
||||
|
||||
double x_in, x_kn;
|
||||
|
||||
List<LinkedHashMap<Pair<ProblemElement, ProblemElement>, Double>> pairs = new ArrayList<>();
|
||||
LinkedHashMap<Pair<ProblemElement, ProblemElement>, Double> pairAlternatives = new LinkedHashMap<>();
|
||||
|
||||
for(int n = 0; n < allCriteria.length; n++) {
|
||||
|
||||
pairs = new ArrayList<>();
|
||||
|
||||
for(int i = 0; i < allAlternatives.length; i++ ) {
|
||||
|
||||
for(int k = 0; k < allAlternatives.length; k++ ) {
|
||||
|
||||
if(i != k) {
|
||||
|
||||
pairAlternatives = new LinkedHashMap<>();
|
||||
|
||||
x_in = normalizeMatrix[i][n];
|
||||
x_kn = normalizeMatrix[k][n];
|
||||
|
||||
if(x_in - x_kn < 0) //losses
|
||||
pairAlternatives.put(new Pair<ProblemElement, ProblemElement>(allAlternatives[i], allAlternatives[k]),
|
||||
(-1 / theta) * (Math.sqrt( Math.abs((x_kn - x_in)) * totalRelativeWeight / relativeWeights[n])));
|
||||
else //gains
|
||||
pairAlternatives.put(new Pair<ProblemElement, ProblemElement>(allAlternatives[i], allAlternatives[k]),
|
||||
Math.sqrt( (x_in - x_kn) * relativeWeights[n] / totalRelativeWeight));
|
||||
|
||||
pairs.add(pairAlternatives);
|
||||
|
||||
}
|
||||
|
||||
phiMatrix.put(allCriteria[n], pairs);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void calculateDelta() {
|
||||
deltaMatrix = new LinkedHashMap<Pair<ProblemElement, ProblemElement>, Double>();
|
||||
|
||||
double acum;
|
||||
for(ProblemElement i: allAlternatives) {
|
||||
|
||||
for(ProblemElement k: allAlternatives) {
|
||||
|
||||
acum = 0;
|
||||
|
||||
if(!i.getId().equals(k.getId())) {
|
||||
|
||||
for(ProblemElement n: allCriteria) {
|
||||
|
||||
List<LinkedHashMap<Pair<ProblemElement, ProblemElement>, Double>> pairsCriterion = phiMatrix.get(n);
|
||||
|
||||
for(LinkedHashMap<Pair<ProblemElement, ProblemElement>, Double> pair: pairsCriterion) {
|
||||
|
||||
if(pair.containsKey(new Pair<ProblemElement, ProblemElement>(i, k))) {
|
||||
acum += pair.get(new Pair<ProblemElement, ProblemElement>(i, k));
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
deltaMatrix.put(new Pair<ProblemElement, ProblemElement>(i, k), acum);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void calculateOverallDominance() {
|
||||
LinkedHashMap<ProblemElement, Double> disorderedEtaRanking = new LinkedHashMap<ProblemElement, Double>();
|
||||
|
||||
computeDeltaSumAlternatives();
|
||||
|
||||
for(ProblemElement alt: allAlternatives)
|
||||
disorderedEtaRanking.put(alt, (computeDeltaSumAlternative(alt) - deltaSumMin) / (deltaSumMax - deltaSumMin));
|
||||
|
||||
etaRanking = disorderedEtaRanking
|
||||
.entrySet()
|
||||
.stream()
|
||||
.sorted(Collections.reverseOrder(Map.Entry.comparingByValue()))
|
||||
.collect(Collectors.toMap(e -> e.getKey(), e -> e.getValue(), (e1, e2) -> e2,
|
||||
LinkedHashMap::new));
|
||||
}
|
||||
|
||||
private void computeDeltaSumAlternatives() {
|
||||
|
||||
double[] dominanceDegrees = new double[allAlternatives.length];
|
||||
double acum;
|
||||
|
||||
int cont = 0;
|
||||
for(ProblemElement i: allAlternatives) {
|
||||
|
||||
acum = 0;
|
||||
|
||||
for(ProblemElement k: allAlternatives) {
|
||||
|
||||
if(!i.getId().equals(k.getId()))
|
||||
|
||||
acum += deltaMatrix.get(new Pair<ProblemElement, ProblemElement>(i, k));
|
||||
|
||||
}
|
||||
|
||||
dominanceDegrees[cont] = acum;
|
||||
|
||||
cont++;
|
||||
}
|
||||
|
||||
deltaSumMax = Arrays.stream(dominanceDegrees).max().getAsDouble();
|
||||
deltaSumMin = Arrays.stream(dominanceDegrees).min().getAsDouble();
|
||||
}
|
||||
|
||||
|
||||
private double computeDeltaSumAlternative(ProblemElement alt) {
|
||||
|
||||
double acum = 0;
|
||||
|
||||
for(ProblemElement k: allAlternatives) {
|
||||
|
||||
if(!alt.getId().equals(k.getId()))
|
||||
|
||||
acum += deltaMatrix.get(new Pair<ProblemElement, ProblemElement>(alt, k));
|
||||
}
|
||||
|
||||
return acum;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user