public code v1

This commit is contained in:
Francisco Jesús Martínez Mimbrera
2026-05-23 00:32:57 +02:00
commit 759a8968a2
4357 changed files with 163763 additions and 0 deletions
@@ -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.numeric.common.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.numeric.common.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>1779484362689</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>
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8
@@ -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
@@ -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: %Bundle-Name
Bundle-SymbolicName: flintstones.method.numeric.common.aggregation;singleton:=true
Bundle-Version: 1.0.0.qualifier
Automatic-Module-Name: flintstones.method.numeric.common.aggregation
Bundle-RequiredExecutionEnvironment: JavaSE-11
Require-Bundle: org.eclipse.e4.core.services,
flintstones.entity.method.phase,
javax.inject,
flintstones.model.problemelement.service,
flintstones.operator,
flintstones.model.valuation.service,
flintstones.valuation.numeric,
flintstones.helper.data,
flintstones.valuation.numeric.real,
flintstones.domain.fuzzyset,
flintstones.valuation.linguistic,
flintstones.entity.operator
Export-Package: flintstones.method.numeric.common.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.numeric.common.aggregation.NumericAggregation"
uid="flintstones.method.numeric.common.aggregation">
</phase>
</extension>
</plugin>
@@ -0,0 +1,334 @@
package flintstones.method.numeric.common.aggregation;
import org.eclipse.e4.core.services.nls.Translation;
import flintstones.domain.fuzzyset.FuzzySet;
import flintstones.domain.numeric.NumericDomain;
import flintstones.domain.numeric.real.NumericRealDomain;
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.numeric.common.aggregation.messages.Messages;
import flintstones.model.problemelement.service.IProblemElementService;
import flintstones.model.valuation.service.IValuationService;
import flintstones.operator.service.IOperatorService;
import flintstones.valuation.linguistic.LinguisticValuation;
import flintstones.valuation.numeric.NumericValuation;
import flintstones.valuation.numeric.real.RealValuation;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import javax.inject.Inject;
public class NumericAggregation extends PhaseMethod {
@Inject
IProblemElementService problemService;
@Inject
IOperatorService operatorService;
@Inject
IValuationService valuationService;
@Inject
@Translation
Messages msg;
/**
* Problem alternatives
*/
Alternative[] allAlternatives;
/**
* Problem criteria
*/
Criterion[] allCriteria;
/**
* Problem experts
*/
Expert[] allExperts;
/**
* Collected valuations for [expert][alternative][criterion]
*/
NumericValuation[][][] initialValuations;
/**
* Expert given criteria weights
*/
HashMatrix<Expert, Criterion, Double> initialCritWeights;
/**
* Experts weights
*/
HashMap<ProblemElement, Double> expertsWeights;
/**
* Aggregated valuations
*/
HashMatrix<Alternative, Criterion, Valuation> aggregatedValuations;
/**
* Aggregated criteria weights
*/
HashMap<ProblemElement, Double> aggregatedCriteriaWeights;
/**
* @return Phase name
*/
@Override
public String getName() {
return msg.phase_name;
}
/**
* Get data from previous phases and initial valuations
*/
@SuppressWarnings("unchecked")
public void loadData() {
allAlternatives = ProblemElementHelper.asAlternatives(problemService.getAll(Alternative.Type));
allCriteria = ProblemElementHelper.asCriterions(problemService.getSubElements(Criterion.Type));
allExperts = ProblemElementHelper.asExperts(problemService.getSubElements(Expert.Type));
try {
initialCritWeights = (HashMatrix<Expert, Criterion, Double>) this.getPreviousPhase().importData("criterionWeights");
expertsWeights = (HashMap<ProblemElement, Double>) importData("expertWeights");
} catch (ImportedDataNotFoundException e) {
initialCritWeights = (HashMatrix<Expert, Criterion, Double>) importData("criterionWeights");
expertsWeights = (HashMap<ProblemElement, Double>) this.getPreviousPhase().importData("expertWeights");
}
if(allExperts.length == 1)
aggregatedCriteriaWeights = new LinkedHashMap<>(initialCritWeights.get(allExperts[0]));
else
aggregatedCriteriaWeights = new LinkedHashMap<ProblemElement, Double>();
initialValuations = new NumericValuation[allExperts.length][allAlternatives.length][allCriteria.length];
aggregatedValuations = new HashMatrix<Alternative, Criterion, Valuation>();
loadValuations();
}
/**
* Gets initial valuations casted to NumericValuation
*/
private void loadValuations() {
ProblemElementKey key;
Valuation auxValuation;
ArrayList<String> labels;
NumericRealDomain auxDomain;
for (int e = 0; e < allExperts.length; e++) {
for (int a = 0; a < allAlternatives.length; a++) {
for (int c = 0; c < allCriteria.length; c++) {
// Find every valuation
key = new ProblemElementKey(allExperts[e], allAlternatives[a], allCriteria[c]);
auxValuation = valuationService.getValuationFor(key);
// if not real number valuation
if (!auxValuation.getDomain().getType().equals("flintstones.domain.numeric.real")) {
double value;
double dMax, dMin;
// if linguistic
if (auxValuation.getDomain().getType().equals("flintstones.domain.linguistic")) {
labels = ((FuzzySet) auxValuation.getDomain()).getLabelSet().getLabelsName();
// use label index as value
value = labels.indexOf(((LinguisticValuation) auxValuation).getLabel().getName());
dMin = 0;
dMax = labels.size();
} else { // other numeric type
value = ((NumericValuation) auxValuation).getValue();
NumericDomain temp = (NumericDomain) auxValuation.getDomain();
dMin = temp.getMin();
dMax = temp.getMax();
}
auxDomain = new NumericRealDomain();
auxDomain.setMinMax(dMin, dMax);
auxDomain.setInRange(true);
auxValuation = new RealValuation();
auxValuation.setDomain(auxDomain);
auxValuation.setValueFromString(Double.toString(value));
}
if (e == 0) {
aggregatedValuations.put(allAlternatives[a], allCriteria[c], auxValuation);
}
initialValuations[e][a][c] = (NumericValuation) auxValuation;
}
}
}
}
/**
* Calculate aggregated valuations
*
* @param operatorId ID for aggregation operator
*/
public void computeAggregatedMatrix(AggregationOperator operator) {
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(initialValuations[e][a][c]);
Valuation aggregated = (NumericValuation) operator.computeAggregation(valuations, new ArrayList<Double>(expertsWeights.values()));
aggregatedValuations.put(allAlternatives[a], allCriteria[c], aggregated);
valuations.clear();
}
}
}
/**
* Calculate aggregated weights
*
* @param operatorId ID for aggregation operator
*/
public void computeAggregatedWeights(AggregationOperator operator) {
ArrayList<Valuation> wTemp = new ArrayList<>();
NumericValuation temp;
NumericRealDomain dTemp = new NumericRealDomain();
dTemp.setInRange(true);
dTemp.setMinMax(0.0, 1.0);
for (int c = 0; c < allCriteria.length; c++) {
for (int e = 0; e < allExperts.length; e++) {
temp = new RealValuation();
temp.setDomain(dTemp);
temp.setValue(initialCritWeights.get(allExperts[e], allCriteria[c]));
wTemp.add(temp);
}
temp = (NumericValuation) operator.computeAggregation(wTemp, new ArrayList<Double>(expertsWeights.values()));
aggregatedCriteriaWeights.put(allCriteria[c], Math.round(temp.getValue() * 1000d) / 1000d);
wTemp.clear();
}
}
/**
* Exports aggregated data for next phases
*/
public void exportData() {
this.exportData("criterionWeights", aggregatedCriteriaWeights, true);
this.exportData("decisionmatrix", aggregatedValuations, true);
}
/**
* @return Problem alternatives
*/
public Alternative[] getAlternatives() {
return allAlternatives;
}
/**
* @return Problem criteria
*/
public Criterion[] getCriteria() {
return allCriteria;
}
/**
* @return All alternatives names as array
*/
public String[] getAlternativesNames() {
String[] str = new String[allAlternatives.length];
for (int i = 0; i < allAlternatives.length; i++)
str[i] = problemService.getByName(Alternative.Type, allAlternatives[i].getName()).getName();
return str;
}
/**
* @return All criteria names as array
*/
public String[] getCriteriaNames() {
String[] str = new String[allCriteria.length];
for (int i = 0; i < allCriteria.length; i++)
str[i] = problemService.getByName(Criterion.Type, allCriteria[i].getName()).getName();
return str;
}
/**
* @return All expert names as array
*/
public String[] getExpertsNames() {
String[] str = new String[allExperts.length];
for (int i = 0; i < allExperts.length; i++)
str[i] = problemService.getByName(Expert.Type, allExperts[i].getName()).getName();
return str;
}
/**
* @return Number of criteria
*/
public int numberCriteria() {
return allCriteria.length;
}
/**
* @return Number of experts
*/
public int numberExperts() {
return allExperts.length;
}
/**
* @param expert Expert index
* @param alternative Alternative index
* @param criterion Criterion index
* @return Collected valuation value
*/
public double getInitialData(int expert, int alternative, int criterion) {
return initialValuations[expert][alternative][criterion].getValue();
}
/**
* @param alternative Alternative index
* @param criterion Criterion index
* @return Aggregated valuation value
*/
public double getAggregatedData(int alternative, int criterion) {
return Math.round(
((NumericValuation) aggregatedValuations.get(allAlternatives[alternative], allCriteria[criterion]))
.getValue() * 1000d)
/ 1000d;
}
/**
* @param expertIndex Expert index
* @return Criteria weights for the expert
*/
public HashMap<Criterion, Double> getValuationWeights(int expertIndex) {
return initialCritWeights.get(allExperts[expertIndex]);
}
/**
* @param c Criterion index
* @return Aggregated criterion weight
*/
public double getAggCritWeight(int c) {
return aggregatedCriteriaWeights.get(allCriteria[c]);
}
}
@@ -0,0 +1,8 @@
package flintstones.method.numeric.common.aggregation.messages;
import org.eclipse.e4.core.services.nls.Message;
@Message
public class Messages {
public String phase_name;
}