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-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.ahp.sort.phase.groupaggregation</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<name>[bundle] Groupaggregation</name>
</project>
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>flintstones.method.ahp.sort.phase.groupaggregation</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>1779484362625</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,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,17 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Groupaggregation
Bundle-SymbolicName: flintstones.method.ahp.sort.phase.groupaggregation;singleton:=true
Bundle-Version: 1.0.0.qualifier
Automatic-Module-Name: flintstones.method.ahp.sort.phase.groupaggregation
Bundle-RequiredExecutionEnvironment: JavaSE-11
Require-Bundle: flintstones.entity.problemelement,
flintstones.entity.extensionenum,
flintstones.helper.data,
flintstones.method.ahp.sort.phase.ranking,
javax.inject,
flintstones.model.problemelement.service,
flintstones.model.ahpsort.profileassignment.service,
flintstones.entity.ahpsort.profileassignment,
flintstones.entity.method.phase
Export-Package: flintstones.method.ahp.sort.phase.groupaggregation
@@ -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.ahp.sort.phase.groupaggregation"
implementation="flintstones.method.ahp.sort.phase.groupaggregation.AHPSortGroupAggregationModel">
</phase>
</extension>
</plugin>
@@ -0,0 +1,243 @@
package flintstones.method.ahp.sort.phase.groupaggregation;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map.Entry;
import javax.inject.Inject;
import flintstones.entity.problemelement.entities.SortingClass;
import flintstones.entity.extensionenum.ExtensionEnum;
import flintstones.entity.method.phase.PhaseMethod;
import flintstones.entity.problemelement.entities.Alternative;
import flintstones.entity.problemelement.entities.Expert;
import flintstones.entity.problemelement.entities.ProblemElement;
import flintstones.helper.data.HashMatrix;
import flintstones.helper.data.Pair;
import flintstones.method.ahp.sort.phase.ranking.ExpertAHPSortModel;
import flintstones.model.problemelement.service.IProblemElementService;
/**
* The Class AHPSortGroupAggregationModel.
*/
public class AHPSortGroupAggregationModel extends PhaseMethod {
// TODO: 06/06 revisar
boolean isOptimisitcx = false;
boolean isCentralx = false;
/** The problem service. */
@Inject
IProblemElementService problemService;
/**
* The Enum ClassificationType.
*/
public static enum ClassificationType implements ExtensionEnum {
/** All agree in the class. */
AllAgree,
/** One class have at least 1 more than the others. */
MostAgree,
/** There where a tie and it was solved. */
SolvedTie,
/** Tie finally solved optimistic */
SolvedTieOptimistic,
/** Tie solved pesimistic . */
SolvedTiePesimistic
}
/** The results. */
ArrayList<GAHPSortResult> results = new ArrayList<>();
/** The models. */
// previous phase
private HashMap<Expert, ExpertAHPSortModel> models;
/** The experts. */
private Expert[] experts;
/*
* (non-Javadoc)
*
* @see flintstones.phasemethod.PhaseMethod#getName()
*/
@Override
public String getName() {
return "Group Aggregation";
}
/**
* Execute.
*/
@SuppressWarnings("unchecked")
public void execute(boolean useCentralProfiles) {
isCentralx = useCentralProfiles;
models = (HashMap<Expert, ExpertAHPSortModel>) importData("expertModels");
experts = models.keySet().stream().toArray(Expert[]::new);
ProblemElement[] alternatives = problemService.getAll(Alternative.Type);
for (ProblemElement a : alternatives) {
Pair<SortingClass, ClassificationType> pair = classify((Alternative) a);
SortingClass cclass = pair.getKey();
ClassificationType type = pair.getValue();
results.add(new GAHPSortResult((Alternative) a, cclass, type));
}
}
/**
* Classify.
*
* @param a the a
* @return the pair
*/
private Pair<SortingClass, ClassificationType> classify(Alternative a) {
// AllAgree/MostAgree
HashMap<SortingClass, Integer> groups = new HashMap<>();
for (Expert e : experts) {
SortingClass cclass = models.get(e).getClassification().get(a);
Integer count = groups.get(cclass);
if (count == null)
count = 0;
count++;
groups.put(cclass, count);
}
// All Agree
if (groups.size() == 1) {
SortingClass cclass = groups.keySet().iterator().next();
ClassificationType type = ClassificationType.AllAgree;
Pair<SortingClass, ClassificationType> pair = new Pair<>(cclass, type);
return pair;
}
SortingClass biggerClass = null;
int biggerValue = 0;
boolean maxRepeated = false;
for (Entry<SortingClass, Integer> entry : groups.entrySet()) {
int count = entry.getValue();
if (count > biggerValue) {
biggerValue = count;
biggerClass = entry.getKey();
maxRepeated = false;
} else if (count == biggerValue) {
maxRepeated = true;
}
}
// We have a winner!
if (!maxRepeated) {
SortingClass cclass = biggerClass;
ClassificationType type = ClassificationType.MostAgree;
Pair<SortingClass, ClassificationType> pair = new Pair<>(cclass, type);
return pair;
}
// SolvedTie
// Separate decision makers in groups
HashMap<SortingClass, ArrayList<Expert>> classes = new HashMap<>();
SortingClass[] tieClasses = groups.keySet().stream().toArray(SortingClass[]::new);
// Init the lists
Arrays.stream(tieClasses).forEach(k -> classes.put(k, new ArrayList<>()));
// Add each expert to the corresponding list
Arrays.stream(experts).forEach(e -> classes.get(models.get(e).getClassification().get(a)).add(e));
for (int i = 0; i < tieClasses.length - 1; i++) {
SortingClass tieA = tieClasses[i];
SortingClass tieB = tieClasses[i + 1];
Expert[] groupA = classes.get(tieA).toArray(new Expert[0]);
Expert[] groupB = classes.get(tieB).toArray(new Expert[0]);
int comparaison = compare(groupA, groupB, a, i);
if (comparaison > 0)
return new Pair<>(tieA, ClassificationType.SolvedTie);
else if (comparaison == 0)
if (isOptimisitcx)
return new Pair<>(tieA, ClassificationType.SolvedTie);
else
return new Pair<>(tieB, ClassificationType.SolvedTie);
}
return new Pair<>(tieClasses[tieClasses.length-1], ClassificationType.SolvedTie);
}
private int compare(Expert[] arr1, Expert[] arr2, Alternative a, int index) {
Double sum1 = 0.0;
Double sum2 = 0.0;
for (Expert classExpert : arr1) {
// Sum all the values for the alternative ignoring class.
Double alternativeGlobalPriorityAgg = models.get(classExpert).getAlternativeGlobalPriorities().get(a)
.get(index);
HashMatrix<Integer, Alternative, Double> map = models.get(classExpert).getProfileGlobalPriorities();
Double profileGlobalPriorityAgg = map.get(index).get(a);
Double result = alternativeGlobalPriorityAgg - profileGlobalPriorityAgg;
if (isCentralx) {
result = alternativeGlobalPriorityAgg - profileGlobalPriorityAgg;
result = result < 0 ? result * -1 : result;
}
sum1 += result;
}
for (Expert classExpert : arr2) {
// Sum all the values for the alternative ignoring class.
Double alternativeGlobalPriorityAgg = models.get(classExpert).getAlternativeGlobalPriorities().get(a)
.get(index);
HashMatrix<Integer, Alternative, Double> map = models.get(classExpert).getProfileGlobalPriorities();
Double profileGlobalPriorityAgg = map.get(index).get(a);
Double result = profileGlobalPriorityAgg - alternativeGlobalPriorityAgg;
if (isCentralx) {
result = profileGlobalPriorityAgg - alternativeGlobalPriorityAgg;
result = result < 0 ? result * -1 : result;
}
sum2 += result;
}
return sum1.compareTo(sum2);
}
/**
* Gets the result.
*
* @return the result
*/
public ArrayList<GAHPSortResult> getResult() {
return results;
}
}
@@ -0,0 +1,62 @@
package flintstones.method.ahp.sort.phase.groupaggregation;
import flintstones.entity.problemelement.entities.SortingClass;
import flintstones.entity.problemelement.entities.Alternative;
import flintstones.method.ahp.sort.phase.groupaggregation.AHPSortGroupAggregationModel.ClassificationType;
/**
* The Class GAHPSortResult. (Support class)
*/
public class GAHPSortResult {
/** The alternative. */
Alternative alternative;
/** The cclass. */
SortingClass cclass;
/** The type. */
ClassificationType type;
/**
* Instantiates a new GAHP sort result.
*
* @param alternative the alternative
* @param cclass the cclass
* @param type the type
*/
public GAHPSortResult(Alternative alternative, SortingClass cclass, ClassificationType type) {
this.alternative = alternative;
this.cclass = cclass;
this.type = type;
}
/**
* Gets the alternative.
*
* @return the alternative
*/
public Alternative getAlternative() {
return alternative;
}
/**
* Gets the sort class.
*
* @return the sort class
*/
public SortingClass getSortClass() {
return cclass;
}
/**
* Gets the type.
*
* @return the type
*/
public ClassificationType getType() {
return type;
}
}