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-11"/>
|
||||
<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.fuzzy.common.phase.aggregation</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<packaging>eclipse-plugin</packaging>
|
||||
<name>[bundle] Bundle-Name</name>
|
||||
</project>
|
||||
@@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>flintstones.method.fuzzy.common.phase.aggregation</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>1779484362673</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
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
|
||||
org.eclipse.jdt.core.compiler.compliance=11
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
|
||||
org.eclipse.jdt.core.compiler.release=enabled
|
||||
org.eclipse.jdt.core.compiler.source=11
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
activeProfiles=
|
||||
eclipse.preferences.version=1
|
||||
resolveWorkspaceProjects=true
|
||||
version=1
|
||||
@@ -0,0 +1,19 @@
|
||||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: %Bundle-Name
|
||||
Bundle-SymbolicName: flintstones.method.fuzzy.common.phase.aggregation;singleton:=true
|
||||
Bundle-Version: 1.0.0.qualifier
|
||||
Automatic-Module-Name: flintstones.method.fuzzy.common.phase.aggregation
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-11
|
||||
Require-Bundle: org.eclipse.e4.core.services,
|
||||
flintstones.entity.method.phase,
|
||||
javax.inject,
|
||||
flintstones.model.problemelement.service,
|
||||
flintstones.model.valuation.service,
|
||||
flintstones.domain.fuzzyset,
|
||||
flintstones.helper.data,
|
||||
flintstones.model.domain.service,
|
||||
flintstones.operator,
|
||||
flintstones.valuation.fuzzy,
|
||||
flintstones.entity.operator
|
||||
Export-Package: flintstones.method.fuzzy.common.phase.aggregation
|
||||
@@ -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
|
||||
implementation="flintstones.method.fuzzy.common.phase.aggregation.FuzzyAggregation"
|
||||
uid="flintstones.method.fuzzy.common.phase.aggregation">
|
||||
</phase>
|
||||
</extension>
|
||||
|
||||
</plugin>
|
||||
+254
@@ -0,0 +1,254 @@
|
||||
package flintstones.method.fuzzy.common.phase.aggregation;
|
||||
|
||||
import org.eclipse.e4.core.services.nls.Translation;
|
||||
|
||||
import flintstones.domain.fuzzyset.function.types.TrapezoidalFunction;
|
||||
import flintstones.entity.method.phase.ImportedDataNotFoundException;
|
||||
import flintstones.entity.method.phase.PhaseMethod;
|
||||
import flintstones.entity.operator.AggregationOperator;
|
||||
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.method.fuzzy.common.phase.aggregation.messages.Messages;
|
||||
import flintstones.model.problemelement.service.IProblemElementService;
|
||||
import flintstones.model.valuation.service.IValuationService;
|
||||
import flintstones.operator.service.IOperatorService;
|
||||
import flintstones.valuation.fuzzy.FuzzyValuation;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
/**
|
||||
* Common phase for fuzzy valuation aggregation
|
||||
* @author jcfer
|
||||
*
|
||||
*/
|
||||
public class FuzzyAggregation extends PhaseMethod {
|
||||
|
||||
@Inject
|
||||
IProblemElementService problemService;
|
||||
|
||||
@Inject
|
||||
IOperatorService operatorService;
|
||||
|
||||
@Inject
|
||||
IValuationService valuationService;
|
||||
|
||||
@Inject
|
||||
@Translation
|
||||
Messages msg;
|
||||
|
||||
/**
|
||||
* Experts' valuations
|
||||
*/
|
||||
HashMap<ProblemElementKey, Valuation> valuations;
|
||||
|
||||
/**
|
||||
* Experts weights
|
||||
*/
|
||||
HashMap<ProblemElement, TrapezoidalFunction> expWeights;
|
||||
|
||||
/**
|
||||
* Criteria weights
|
||||
*/
|
||||
HashMatrix<ProblemElement, ProblemElement, TrapezoidalFunction> criWeights;
|
||||
|
||||
/**
|
||||
* Aggregated criteria weights
|
||||
*/
|
||||
ArrayList<TrapezoidalFunction> aggCriWeights;
|
||||
|
||||
/**
|
||||
* All the alternatives
|
||||
*/
|
||||
Alternative[] allAlternatives;
|
||||
|
||||
/**
|
||||
* All the criteria
|
||||
*/
|
||||
Criterion[] allCriteria;
|
||||
|
||||
/**
|
||||
* All the experts
|
||||
*/
|
||||
Expert[] allExperts;
|
||||
|
||||
/**
|
||||
* Experts' valuations
|
||||
*/
|
||||
Valuation[][][] initialValues;
|
||||
|
||||
/**
|
||||
* Aggregated decision matrix
|
||||
*/
|
||||
HashMatrix<ProblemElement, ProblemElement, TrapezoidalFunction> aggregatedValues;
|
||||
|
||||
/**
|
||||
* @return Phase name
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return msg.phase_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Export data
|
||||
*/
|
||||
public void exportData() {
|
||||
exportData("aggregatedValues", aggregatedValues);
|
||||
exportData("aggregatedWeights", aggCriWeights);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Experts of the problem
|
||||
*/
|
||||
public Expert[] getExperts() {
|
||||
return allExperts;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Criteria of the problem
|
||||
*/
|
||||
public Criterion[] getCriteria() {
|
||||
return allCriteria;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Alternatives of the problem
|
||||
*/
|
||||
public Alternative[] getAlternatives() {
|
||||
return allAlternatives;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load data from previous phase and compute aggregated decision matrix
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public void loadData() {
|
||||
// Problem data
|
||||
allAlternatives = ProblemElementHelper.asAlternatives(problemService.getAll(Alternative.Type));
|
||||
allCriteria = ProblemElementHelper.asCriterions(problemService.getAll(Criterion.Type));
|
||||
allExperts = ProblemElementHelper.asExperts(problemService.getAll(Expert.Type));
|
||||
|
||||
// Gathering data
|
||||
expWeights = (HashMap<ProblemElement, TrapezoidalFunction>) getPreviousPhase().importData("expertsWeights");
|
||||
criWeights = (HashMatrix<ProblemElement, ProblemElement, TrapezoidalFunction>) importData("criterionsWeights");
|
||||
|
||||
try {
|
||||
valuations = (HashMap<ProblemElementKey, Valuation>) importData("twoTupleUnifiedValuations");//unification phase before
|
||||
} catch(ImportedDataNotFoundException e) {
|
||||
valuations = valuationService.getAllKV();
|
||||
}
|
||||
|
||||
// Object creation
|
||||
initialValues = new Valuation[allExperts.length][allAlternatives.length][allCriteria.length];
|
||||
aggregatedValues = new HashMatrix<>();
|
||||
|
||||
// For each combination of expert, alternative and criterion, add the valuation to array
|
||||
ProblemElementKey key;
|
||||
for (int i = 0; i < allExperts.length; i++) {
|
||||
for (int j = 0; j < allAlternatives.length; j++) {
|
||||
for (int k = 0; k < allCriteria.length; k++) {
|
||||
key = new ProblemElementKey(allExperts[i], allAlternatives[j], allCriteria[k]);
|
||||
initialValues[i][j][k] = valuations.get(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Index of expert
|
||||
* @return Valuations of the expert
|
||||
*/
|
||||
public String getStringExpertValuation(int e, int a, int c) {
|
||||
return initialValues[e][a][c].toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param e Index of expert
|
||||
* @return Criterion weights of the expert
|
||||
*/
|
||||
public TrapezoidalFunction[] getExpertWeights(int e) {
|
||||
Object[] temp = criWeights.get(allExperts[e]).values().toArray();
|
||||
TrapezoidalFunction[] crits = new TrapezoidalFunction[temp.length];
|
||||
for(int i = 0; i < temp.length; i++) {
|
||||
crits[i] = (TrapezoidalFunction) temp[i];
|
||||
}
|
||||
return crits;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate aggregated valuations
|
||||
*
|
||||
* @param operatorId ID for aggregation operator
|
||||
*/
|
||||
public void computeAggregatedMatrix(AggregationOperator operator) {
|
||||
aggregatedValues = new HashMatrix<ProblemElement, ProblemElement, TrapezoidalFunction>();
|
||||
|
||||
LinkedList<Valuation> valuations = new LinkedList<>();
|
||||
|
||||
for (int a = 0; a < allAlternatives.length; a++) {
|
||||
for (int c = 0; c < allCriteria.length; c++) {
|
||||
for (int e = 0; e < allExperts.length; e++) {
|
||||
valuations.add(initialValues[e][a][c]);
|
||||
}
|
||||
|
||||
// Aggregates each valuation [alternative][criterion] for each expert
|
||||
Valuation aggregated = operator.computeAggregation(valuations, new ArrayList<TrapezoidalFunction>(expWeights.values()));
|
||||
aggregatedValues.put(allAlternatives[a], allCriteria[c], ((FuzzyValuation) aggregated).getFuzzyNumber());
|
||||
valuations.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate aggregated weights
|
||||
*
|
||||
* @param operatorId ID for aggregation operator
|
||||
*/
|
||||
public void computeAggregatedWeights(AggregationOperator operator) {
|
||||
aggCriWeights = new ArrayList<TrapezoidalFunction>();
|
||||
|
||||
ArrayList<Valuation> wTemp = new ArrayList<>();
|
||||
FuzzyValuation temp;
|
||||
|
||||
for (int c = 0; c < allCriteria.length; c++) {
|
||||
for (int e = 0; e < allExperts.length; e++) {
|
||||
temp = new FuzzyValuation();
|
||||
temp.setFuzzyNumber(criWeights.get(allExperts[e], allCriteria[c]));
|
||||
wTemp.add(temp);
|
||||
}
|
||||
|
||||
temp = (FuzzyValuation) operator.computeAggregation(wTemp, new ArrayList<TrapezoidalFunction>(expWeights.values()));
|
||||
aggCriWeights.add(temp.getFuzzyNumber());
|
||||
|
||||
wTemp.clear();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param c Criterion
|
||||
* @param a Alternative
|
||||
* @return Aggregated valuation
|
||||
*/
|
||||
public TrapezoidalFunction getAggregatedValuation(Alternative a, Criterion c) {
|
||||
return aggregatedValues.get(a, c);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param c Index of criterion
|
||||
* @return Aggregated weight
|
||||
*/
|
||||
public TrapezoidalFunction getAggregatedWeight(int c) {
|
||||
return aggCriWeights.get(c);
|
||||
}
|
||||
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package flintstones.method.fuzzy.common.phase.aggregation.messages;
|
||||
|
||||
import org.eclipse.e4.core.services.nls.Message;
|
||||
|
||||
@Message
|
||||
public class Messages {
|
||||
public String phase_name;
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
phase_name=Aggregation
|
||||
+1
@@ -0,0 +1 @@
|
||||
phase_name=Agregación
|
||||
Reference in New Issue
Block a user