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.gathering</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<packaging>eclipse-plugin</packaging>
|
||||
<name>[bundle] Gathering</name>
|
||||
</project>
|
||||
@@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>flintstones.method.todim.phase.gathering</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>1779484362699</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,20 @@
|
||||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: Gathering
|
||||
Bundle-SymbolicName: flintstones.method.todim.phase.gathering;singleton:=true
|
||||
Bundle-Version: 1.0.0.qualifier
|
||||
Automatic-Module-Name: flintstones.method.todim.phase.gathering
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
|
||||
Require-Bundle: org.eclipse.e4.core.contexts,
|
||||
flintstones.valuation,
|
||||
flintstones.model.problemelement.service,
|
||||
flintstones.entity.problemelement,
|
||||
flintstones.valuation.numeric,
|
||||
flintstones.helper.ui,
|
||||
flintstones.entity.method.phase,
|
||||
javax.inject,
|
||||
flintstones.model.valuation.service,
|
||||
flintstones.model.domain.service,
|
||||
flintstones.entity.valuation,
|
||||
flintstones.helper.data
|
||||
Export-Package: flintstones.method.todim.phase.gathering
|
||||
@@ -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.gathering"
|
||||
implementation="flintstones.method.todim.phase.gathering.phaseTodim">
|
||||
</phase>
|
||||
</extension>
|
||||
|
||||
</plugin>
|
||||
+191
@@ -0,0 +1,191 @@
|
||||
package flintstones.method.todim.phase.gathering;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.eclipse.e4.core.contexts.IEclipseContext;
|
||||
|
||||
import flintstones.entity.method.phase.PhaseMethod;
|
||||
import flintstones.entity.problemelement.ProblemElementKey;
|
||||
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.entity.valuation.Valuation;
|
||||
import flintstones.helper.data.HashMatrix;
|
||||
import flintstones.model.domain.service.IDomainService;
|
||||
import flintstones.model.problemelement.service.IProblemElementService;
|
||||
import flintstones.model.valuation.service.IValuationService;
|
||||
import flintstones.valuation.numeric.NumericValuation;
|
||||
|
||||
public class phaseTodim extends PhaseMethod {
|
||||
|
||||
@Inject
|
||||
IEclipseContext context;
|
||||
|
||||
@Inject
|
||||
IValuationService valuationService;
|
||||
|
||||
@Inject
|
||||
IDomainService domainService;
|
||||
|
||||
@Inject
|
||||
IProblemElementService problemService;
|
||||
|
||||
// Atributos
|
||||
HashMap<ProblemElementKey, Valuation> mapVAluations;
|
||||
HashMatrix<Expert, Criterion, Double> hmWeights;
|
||||
Alternative[] allAlternatives;
|
||||
Criterion[] allCriterion;
|
||||
Expert[] allexperts;
|
||||
|
||||
double[][] initialMatrix;
|
||||
double[][] normalizeMatrix;
|
||||
double[] weights;
|
||||
double[] relativeWeights;
|
||||
double[] scaleNormalization;
|
||||
|
||||
double maxWeight;
|
||||
double totalRelativeWeight;
|
||||
|
||||
public phaseTodim() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "TODIM";
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void initialize() {
|
||||
ProblemElement[] pes = problemService.getAll(Alternative.Type);
|
||||
allAlternatives = ProblemElementHelper.asAlternatives(pes);
|
||||
|
||||
pes = problemService.getAll(Criterion.Type);
|
||||
allCriterion = ProblemElementHelper.asCriterions(pes);
|
||||
|
||||
pes = problemService.getAll(Expert.Type);
|
||||
allexperts = ProblemElementHelper.asExperts(pes);
|
||||
|
||||
hmWeights = (HashMatrix<Expert, Criterion, Double>) this.importData("criterionWeights");
|
||||
|
||||
this.weights = getWeights();
|
||||
}
|
||||
|
||||
public Criterion[] getCriteria() {
|
||||
return this.allCriterion;
|
||||
}
|
||||
|
||||
public Alternative[] getAlternatives() {
|
||||
return this.allAlternatives;
|
||||
}
|
||||
|
||||
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[allCriterion.length];
|
||||
|
||||
for (int i = 0; i < allCriterion.length; i++)
|
||||
str[i] = allCriterion[i].getCanonicalName();
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
public void executeMethod(Expert e, double[] scaleNormalization) {
|
||||
this.scaleNormalization = scaleNormalization;
|
||||
|
||||
this.initialMatrix = this.getValuations(e);
|
||||
|
||||
normalize();
|
||||
|
||||
getRelativeWeight();
|
||||
|
||||
// exportamos los datos a la ventana de resultados.
|
||||
this.exportData("normalizeMatrix", normalizeMatrix);
|
||||
this.exportData("relativeWeights", relativeWeights);
|
||||
this.exportData("maxWeight", maxWeight);
|
||||
this.exportData("totalRelativeWeight", totalRelativeWeight);
|
||||
|
||||
}
|
||||
|
||||
public HashMap<ProblemElementKey, Valuation> getMapValuations(Expert e) {
|
||||
ProblemElement pE = problemService.getByCanonicalName(Expert.Type, e.getCanonicalName());
|
||||
mapVAluations = valuationService.getAllValuationsKVWith(pE);
|
||||
return mapVAluations;
|
||||
}
|
||||
|
||||
public double[][] getValuations(Expert e) {
|
||||
|
||||
double[][] valuation = new double[allAlternatives.length][allCriterion.length];
|
||||
|
||||
ProblemElement pE = problemService.getByCanonicalName(Expert.Type, e.getCanonicalName());
|
||||
mapVAluations = valuationService.getAllValuationsKVWith(pE);
|
||||
|
||||
int a = 0, b = 0;
|
||||
for (Entry<ProblemElementKey, Valuation> entry : mapVAluations.entrySet()) {
|
||||
NumericValuation nV = (NumericValuation) entry.getValue();
|
||||
|
||||
for (int i = 0; i < allAlternatives.length; i++)
|
||||
if (entry.getKey().getAlternative().getId().equals(allAlternatives[i].getId())) {
|
||||
a = i;
|
||||
break;
|
||||
}
|
||||
|
||||
for (int i = 0; i < allCriterion.length; i++)
|
||||
if (entry.getKey().getCriterion().getId().equals(allCriterion[i].getId())) {
|
||||
b = i;
|
||||
break;
|
||||
}
|
||||
|
||||
valuation[a][b] = Double.valueOf(nV.getValue());
|
||||
a = 0;
|
||||
b = 0;
|
||||
}
|
||||
|
||||
return valuation;
|
||||
}
|
||||
|
||||
private double[] getWeights() {
|
||||
double[] ws = new double[allCriterion.length];
|
||||
double w;
|
||||
|
||||
for (int i = 0; i < allCriterion.length; i++) {
|
||||
w = hmWeights.get(allexperts[0], allCriterion[i]);
|
||||
ws[i] = w;
|
||||
}
|
||||
|
||||
return ws;
|
||||
}
|
||||
|
||||
private void normalize() {
|
||||
normalizeMatrix = new double[allAlternatives.length][allCriterion.length];
|
||||
for (int i = 0; i < initialMatrix.length; i++)
|
||||
for (int j = 0; j < initialMatrix[i].length; j++)
|
||||
normalizeMatrix[i][j] = initialMatrix[i][j] / scaleNormalization[j];
|
||||
}
|
||||
|
||||
private void getRelativeWeight() {
|
||||
|
||||
maxWeight = Arrays.stream(weights).max().getAsDouble();
|
||||
|
||||
relativeWeights = new double[allCriterion.length];
|
||||
for (int i = 0; i < relativeWeights.length; i++)
|
||||
relativeWeights[i] = weights[i] / maxWeight;
|
||||
|
||||
|
||||
totalRelativeWeight = 0.0f;
|
||||
for (int i = 0; i < relativeWeights.length; i++)
|
||||
totalRelativeWeight += relativeWeights[i];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user