public code v1

This commit is contained in:
2026-05-22 11:14:29 +02:00
parent 427197ec5a
commit b8141736eb
28859 changed files with 575079 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 @@
/bin
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>afryca.consensusmodel.chiclana2008</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>
</projectDescription>
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
line.separator=\n
@@ -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,10 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-SymbolicName: afryca.consensusmodel.chiclana2008;singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-Vendor: %Bundle-Vendor
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Require-Bundle: afryca.consensusmodel,
afryca.fpr
Automatic-Module-Name: afryca.consensusmodel.chiclana2008
@@ -0,0 +1,13 @@
#Properties file for afryca.consensusmodel.chiclana2008
Bundle-Vendor = Sinbad\u00B2
Bundle-Name = Chiclana2008
afryca.consensusmodel.chiclana2008.information = Paper: F. Chiclana, F. Mata, L. Mart\u00EDnez, E. Herrera-Viedma, S. Alonso, Integration of a consistency control module within a consensus model. International Journal of Uncertainty, Fuzziness and Knowledge-based Systems, vol. 16, issue supp01, pp. 35-53, 2008.\\n\\nA model characterized by an adaptive feedback mechanism, in which the direction rules generated for experts depend on the level of agreement achieved at each round. To do this, three different consensus threshold are utilized. Consensus is computed at three levels based on similarity degrees between pairs of experts in their assessments.
afryca.consensusmodel.chiclana2008.mainfeature = Fuzzy preference relations\\nAdaptive feedback mechanism\\nSimilarities between experts\\n3-level consensus degrees
afryca.consensusmodel.chiclana2008.name = F. Chiclana et al. (2008)
afryca.consensusmodel.chiclana2008.observations = \u0020
afryca.consensusmodel.chiclana2008.variable.gamma.description = Consensus threshold indicating minimum agreement level to be reached
afryca.consensusmodel.chiclana2008.variable.consistency_control_module.description = Consistency control module
afryca.consensusmodel.chiclana2008.variable.theta1.description = Low consensus threshold: If consensus degree is lower than this value, a low consensus preference search is applied
afryca.consensusmodel.chiclana2008.variable.theta2.description = Medium consensus threshold: a medium or high consensus preference search is applied depending on whether consensus degree is lower or higher than this value, respectively
afryca.consensusmodel.chiclana2008.variable.beta.description = Consistency threshold for preferences
afryca.consensusmodel.chiclana2008.variable.maxrounds.description = Maximum number of consensus rounds allowed
@@ -0,0 +1,13 @@
#Archivo de propiedades para afryca.consensusmodel.chiclana2008
Bundle-Vendor = Sinbad\u00B2
Bundle-Name = Chiclana2008
afryca.consensusmodel.chiclana2008.information = Paper: F. Chiclana, F. Mata, L. Mart\u00EDnez, E. Herrera-Viedma, S. Alonso, Integration of a consistency control module within a consensus model. International Journal of Uncertainty, Fuzziness and Knowledge-based Systems, vol. 16, issue supp01, pp. 35-53, 2008.\\n\\nUn modelo caracterizado por un mecanismo de feedback adaptativo, en el cual la dirección de las reglas generadas para los expertos depende el grado de acuerdo alcanzada en cada ronda. Para hacer esto, tres umbrales de consenso diferentes son utilizados. El consenso es calculado a tres niveles en base a los grados de similitud entre pares de expertos en sus valoraciones.
afryca.consensusmodel.chiclana2008.mainfeature = Relaciones de preferencia difusas\\nMecanismo de feedback adaptativo\\nSimilitud entre expertos\\n3 niveles de grados de consenso
afryca.consensusmodel.chiclana2008.name = F. Chiclana et al. (2008)
afryca.consensusmodel.chiclana2008.observations = \u0020
afryca.consensusmodel.chiclana2008.variable.gamma.description = Umbral de consenso indicando el nivel mínimo de acuerdo a alcanzar
afryca.consensusmodel.chiclana2008.variable.consistency_control_module.description = Módulo de control de consistencia
afryca.consensusmodel.chiclana2008.variable.theta1.description = Umbral mínimo de consenso: Si el grado de consenso es menor que este valor, es aplicada una búsqueda de preferencias con bajo consenso
afryca.consensusmodel.chiclana2008.variable.theta2.description = Umbral medio de consenso: Una búsqueda de medio o alto consenso es aplicada en función de si el grado de consenso es mejor o superior a este valor, respectivamente
afryca.consensusmodel.chiclana2008.variable.beta.description = Umbral de consistencia para las preferencias
afryca.consensusmodel.chiclana2008.variable.maxrounds.description = Máximo número de rondas de consenso permitidas
@@ -0,0 +1,6 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
plugin.xml,\
OSGI-INF/
@@ -0,0 +1,115 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
point="afryca.consensusmodel">
<ConsensusModel
ConsensusModel="afryca.consensusmodel.Chiclana2008"
Information="%afryca.consensusmodel.chiclana2008.information"
MainFeatures="%afryca.consensusmodel.chiclana2008.mainfeature"
Multicriteria="false"
Name="%afryca.consensusmodel.chiclana2008.name"
Observations="%afryca.consensusmodel.chiclana2008.observations"
Structure="afryca.fpr"
WithFeedback="true"
id="Chiclana2008">
<Variable
default_value="0.85"
description="%afryca.consensusmodel.chiclana2008.variable.gamma.description"
id="gamma"
is_array="false"
is_internal="false"
type="Float">
<Restriction
type="lower_limit"
value="0">
</Restriction>
<Restriction
type="upper_limit"
value="1">
</Restriction>
</Variable>
<Variable
default_value="false"
description="%afryca.consensusmodel.chiclana2008.variable.consistency_control_module.description"
id="consistency_control_module"
is_array="false"
is_internal="false"
type="Boolean">
</Variable>
<Variable
default_value="0.7"
description="%afryca.consensusmodel.chiclana2008.variable.theta1.description"
id="theta1"
is_array="false"
is_internal="false"
type="Float">
<Restriction
type="lower_limit"
value="0">
</Restriction>
<Restriction
type="upper_limit"
value="1">
</Restriction>
<Relation
type="lower_than"
variable="theta2">
</Relation>
</Variable>
<Variable
default_value="0.8"
description="%afryca.consensusmodel.chiclana2008.variable.theta2.description"
id="theta2"
is_array="false"
is_internal="false"
type="Float">
<Restriction
type="lower_limit"
value="0">
</Restriction>
<Restriction
type="upper_limit"
value="1">
</Restriction>
<Relation
type="greater_than"
variable="theta1">
</Relation>
<Relation
type="lower_than"
variable="gamma">
</Relation>
</Variable>
<Variable
default_value="0.8"
description="%afryca.consensusmodel.chiclana2008.variable.beta.description"
id="beta"
is_array="false"
is_internal="false"
type="Float">
<Restriction
type="lower_limit"
value="0">
</Restriction>
<Restriction
type="upper_limit"
value="1">
</Restriction>
</Variable>
<Variable
default_value="15"
description="%afryca.consensusmodel.chiclana2008.variable.maxrounds.description"
id="maxrounds"
is_array="false"
is_internal="false"
type="Integer">
<Restriction
type="lower_limit"
value="1">
</Restriction>
</Variable>
</ConsensusModel>
</extension>
</plugin>
@@ -0,0 +1,836 @@
package afryca.consensusmodel;
import java.util.HashMap;
import java.util.HashSet;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import afryca.cm.CM;
import afryca.consensusmodel.definition.EResultElements;
import afryca.fpr.FPR;
import afryca.structure.Structure;
/**
* Chiclana2008 consensus model
*
* @author Sinbad²
* @version 3.0
*/
public class Chiclana2008 extends ConsensusModel {
private static final String CONSENSUS_MODEL_NAME = "F. Chiclana et al. (2008)"; //$NON-NLS-1$
private static final String GAMMA = "gamma"; //$NON-NLS-1$
private static final String THETA1 = "theta1"; //$NON-NLS-1$
private static final String THETA2 = "theta2"; //$NON-NLS-1$
private static final String MAXROUNDS = "maxrounds"; //$NON-NLS-1$
private static final String CONSISTENCY_CONTROL_MODULE = "consistency_control_module"; //$NON-NLS-1$
private static final String BETA = "beta"; //$NON-NLS-1$
private Float gamma;
private Float theta1;
private Float theta2;
private Integer maxrounds;
private int round;
private Float cr;
private int[] advises;
@Override
protected void setModelConfiguration() {
}
@Override
protected void obtainConfigurationValues() {
gamma = (Float) configuration.getValue(GAMMA);
theta1 = (Float) configuration.getValue(THETA1);
theta2 = (Float) configuration.getValue(THETA2);
maxrounds = (Integer) configuration.getValue(MAXROUNDS);
if ((Boolean) configuration.getValue(CONSISTENCY_CONTROL_MODULE)) {
consistencyControlModule(numberOfExperts, numberOfAlternatives, (Structure[]) preferences, (Float) configuration.getValue(BETA));
}
round = 0;
cr = 0f;
advises = null;
}
@Override
protected Float[][][] obtainVisualizeValues() {
Structure[] auxPreferences = (Structure[]) clonePreferencesUnion(preferences, ConsensusEngine.groupPreferences(numberOfExperts, numberOfAlternatives, preferences));
Float[][][] preferencesGroupVisualization = new Float[numberOfExperts + 1][numberOfAlternatives][numberOfAlternatives];
for (int k = 0; k < numberOfExperts+1; k++) {
preferencesGroupVisualization[k] = auxPreferences[k].obtainVisualizeValues();
}
return preferencesGroupVisualization;
}
@Override
protected void preFirstSaveRoundResults() {
int round = 1;
Structure[] auxPreferences = (Structure[]) clonePreferencesUnion(preferences, ConsensusEngine.groupPreferences(numberOfExperts, numberOfAlternatives, preferences));
CM[][] sm_matrices = ConsensusEngine.similarityMatrices(numberOfExperts, numberOfAlternatives, auxPreferences);
CM cm = ConsensusEngine.consensusMatrixBasedOnSimilarityBetweenFPRs(numberOfExperts, numberOfAlternatives, sm_matrices);
Float[] ac = ConsensusEngine.computeAlternativesConsensus(numberOfAlternatives, cm);
Float consensusDegreeAchieved = ConsensusEngine.consensusBasedOnAlternativesConsensus(numberOfAlternatives, ac);
preSaveRoundResult(round, auxPreferences, obtainVisualizeValues(), consensusDegreeAchieved);
result.put(EResultElements.initial_consensus_degree, consensusDegreeAchieved);
result.put(EResultElements.maxround, maxrounds);
result.put(EResultElements.consensus_threshold, gamma);
result.put(EResultElements.consensus_model, CONSENSUS_MODEL_NAME);
}
@Override
protected void preSaveRoundResults() {
preSaveRoundResult(round + 1, preferences, obtainVisualizeValues(), cr);
}
@Override
protected void consensusRound() {
computeCollective();
CM[] proximityMatrices = ConsensusEngine.similarityMatricesRespectCollective(numberOfExperts, numberOfAlternatives, preferences, preferences[numberOfExperts]);
Float[][] proximityOnAlternatives = computeProximityOnAlternatives(numberOfExperts, numberOfAlternatives, proximityMatrices);
CM[][] sm_matrices = ConsensusEngine.similarityMatrices(numberOfExperts, numberOfAlternatives, preferences);
CM cm = ConsensusEngine.consensusMatrixBasedOnSimilarityBetweenFPRs(numberOfExperts, numberOfAlternatives, sm_matrices);
Float[] consensusOnAlternatives = ConsensusEngine.computeAlternativesConsensus(numberOfAlternatives, cm);
computeConsensusDegree(consensusOnAlternatives);
//
// Consensus control
//
if (cr < gamma) {
//
// Adaptive module
//
List<List<Advice>> listOfAdvises;
if (cr <= theta1) {
// Execute low consensus preferences search
listOfAdvises = lowConsensusPreferencesSearch(numberOfExperts, numberOfAlternatives, cm, cr, (Structure[]) preferences);
} else {
if (cr <= theta2) {
// Execute medium consensus preferences search
listOfAdvises = mediumConsensusPreferencesSearch(numberOfExperts, numberOfAlternatives, cm, cr, consensusOnAlternatives, proximityOnAlternatives, (Structure[]) preferences);
} else {
// Execute high consensus preferences search
listOfAdvises = highConsensusPreferencesSearch(numberOfExperts, numberOfAlternatives, cm, cr, consensusOnAlternatives, proximityOnAlternatives, proximityMatrices,
(Structure[]) preferences);
}
}
advises = new int[numberOfExperts];
for (int expert = 0; expert < numberOfExperts; expert++) {
advises[expert] = 0;
for (Advice p : listOfAdvises.get(expert)) {
if (p.getChange() != EChangeType.NotChange) {
advises[expert] = advises[expert] + 1;
}
}
}
// Make Prefechs
makePrefechs((Structure[]) preferences, listOfAdvises);
round++;
}
}
private void computeCollective() {
preferences[numberOfExperts] = ConsensusEngine.groupPreferences(numberOfExperts, numberOfAlternatives, preferences);
}
private void computeConsensusDegree(Float[] consensusOnAlternatives) {
cr = ConsensusEngine.consensusBasedOnAlternativesConsensus(numberOfAlternatives, consensusOnAlternatives);
}
@Override
protected void posSaveRoundResults() {
computeCollective();
CM[][] sm_matrices = ConsensusEngine.similarityMatrices(numberOfExperts, numberOfAlternatives, preferences);
CM cm = ConsensusEngine.consensusMatrixBasedOnSimilarityBetweenFPRs(numberOfExperts, numberOfAlternatives, sm_matrices);
Float[] consensusOnAlternatives = ConsensusEngine.computeAlternativesConsensus(numberOfAlternatives, cm);
computeConsensusDegree(consensusOnAlternatives);
posSaveRoundResult(preferences, obtainVisualizeValues(), cr, advises, preferences[numberOfExperts]);
}
@Override
protected boolean mustBeCarriedOutAnotherRound() {
return (cr < gamma) && (round < maxrounds);
}
@Override
protected void saveExecutionResults() {
this.configuration.setValue(PREFERENCES, preferences);
result.put(EResultElements.number_of_rounds_required, round);
result.put(EResultElements.consensus_degree_achieved, cr);
}
/**
* Execute consistency control module
*
* @param experts
* Number of experts
* @param alternatives
* Number of alternatives
* @param preferences
* All experts FPR
* @param beta
* Consistency degree threshold
*/
private static void consistencyControlModule(Integer experts, Integer alternatives, Structure[] preferences, Float beta) {
// Computing consistency degrees
FPR[] consistencyDegrees = consistencyDegreesMatrices(experts, alternatives, preferences);
// Computing alternatives consistency degrees
Float[][] alternativesConsistencyDegree = alternativesConsistencyDegree(experts, alternatives, consistencyDegrees);
// Computing experts consistency degrees
Float[] expertsConsistencyDegrees = expertsConsistencyDegree(experts, alternativesConsistencyDegree);
// Execute consistency advice system
consistencyAdviceSystem(experts, alternatives, beta, preferences, consistencyDegrees, alternativesConsistencyDegree, expertsConsistencyDegrees);
}
/**
* Computing consistency degrees matrices
*
* @param expert
* Number of experts
* @param alternatives
* Number of alternatives
* @param preferences
* All FPR
* @return Consistency degrees
*/
private static FPR[] consistencyDegreesMatrices(Integer experts, Integer alternatives, Structure[] preferences) {
FPR[] result = new FPR[experts];
FPR estimatedFPR;
for (int i = 0; i < experts; i++) {
estimatedFPR = estimatedFPR(alternatives, (FPR) preferences[i]);
result[i] = consistencyDegreeMatrix(alternatives, estimatedFPR, (FPR) preferences[i]);
}
return result;
}
/**
* Computing consistency degrees matrix
*
* @param estimated
* Estimated FPR
* @param real
* Real FPR
* @return Consistency degrees matrix
*/
private static FPR consistencyDegreeMatrix(Integer alternatives, FPR estimated, FPR real) {
FPR result = new FPR(alternatives);
for (int i = 0; i < alternatives; i++) {
for (int j = 0; j < alternatives; j++) {
if (i == j) {
result.getPreferences()[i][j] = 0.5f;
} else {
result.getPreferences()[i][j] = 1f - Math.abs((Float) estimated.getValue(i, j) - (Float) real.getValue(i, j));
}
}
}
return result;
}
/**
* Computing estimated FPR
*
* @param alternatives
* Number of alternatives
* @param fpr
* FPR
* @return Estimated FPR
*/
private static FPR estimatedFPR(Integer alternatives, FPR fpr) {
FPR result = new FPR(alternatives);
result.initialize();
Float value;
for (int i = 0; i < (alternatives - 1); i++) {
for (int j = (i + 1); j < alternatives; j++) {
value = overallEstimateValue(alternatives, i, j, fpr);
if (value > 1) {
value = 1f;
} else if (value < 0) {
value = 0f;
}
result.setValueSymmetrically(i, j, value);
}
}
return result;
}
/**
* Computing overall estimate value
*
* @param alternatives
* Number of alternatives
* @param row
* Row
* @param column
* Column
* @param fpr
* FPR
* @return Overall estimate value
*/
private static Float overallEstimateValue(Integer alternatives, Integer row, Integer column, FPR fpr) {
Float result = 0f;
Float numerator = 0f;
Float denominator = alternatives - 2f;
for (int i = 0; i < alternatives; i++) {
if ((i != row) && (i != column)) {
numerator += (Float) fpr.getValue(row, i) + (Float) fpr.getValue(i, column) - 0.5f;
}
}
result = numerator / denominator;
return result;
}
/**
* Compute alternatives consistency degree for all experts
*
* @param experts
* Number of experts
* @param alternatives
* Number of alternatives
* @param cds
* Consistency degrees matrices
* @return Alternatives consistency degree for all experts
*/
private static Float[][] alternativesConsistencyDegree(Integer experts, Integer alternatives, FPR[] cds) {
Float[][] result = new Float[experts][alternatives];
for (int i = 0; i < experts; i++) {
result[i] = alternativesConsistencyDegree(alternatives, cds[i]);
}
return result;
}
/**
* Compute alternatives consistency degree
*
* @param alternatives
* Number of alternatives
* @param fpr
* FPR
* @return Alternatives consistency degree
*/
private static Float[] alternativesConsistencyDegree(Integer alternatives, FPR fpr) {
Float[] result = new Float[alternatives];
for (int i = 0; i < alternatives; i++) {
result[i] = 0f;
for (int j = 0; j < alternatives; j++) {
if (i != j) {
result[i] += (Float) fpr.getValue(i, j);
}
}
result[i] /= ((float) alternatives - 1);
}
return result;
}
/**
* Compute experts consistency degrees
*
* @param experts
* Number of experts
* @param alternativesConsistencyDegree
* Alternatives consistency degree for all experts
* @return Experts consistency degrees
*/
private static Float[] expertsConsistencyDegree(Integer experts, Float[][] alternativesConsistencyDegree) {
Float[] result = new Float[experts];
for (int i = 0; i < experts; i++) {
result[i] = expertConsistencyDegree(alternativesConsistencyDegree[i]);
}
return result;
}
/**
* Compute expert consistency degree
*
* @param alternativesConsistencyDegree
* Alternatives consistency degree for expert
* @return Expert consistency degree
*/
private static Float expertConsistencyDegree(Float[] alternativesConsistencyDegree) {
Float result = 0f;
for (Float alternativeConsistencyDegree : alternativesConsistencyDegree) {
result += alternativeConsistencyDegree;
}
result /= ((float) alternativesConsistencyDegree.length);
return result;
}
/**
* Execute consistency advice system
*
* @param experts
* Number of experts
* @param alternatives
* Number of alternatives
* @param beta
* Consistency degree threshold
* @param preferences
* All experts FPR
* @param consistencyDegrees
* Experts consistency degrees
* @param alternativesConsistencyDegree
* Alternatives consistency degrees by experts
* @param expertsConsistencyDegrees
* Experts consistency degrees
*/
private static void consistencyAdviceSystem(Integer experts, Integer alternatives, Float beta, Structure[] preferences, FPR[] consistencyDegrees, Float[][] alternativesConsistencyDegree,
Float[] expertsConsistencyDegrees) {
Float aux;
Float sign;
Float cp;
Float cd;
Float p;
for (int i = 0; i < expertsConsistencyDegrees.length; i++) {
if (expertsConsistencyDegrees[i] < beta) {
for (int j = 0; j < alternativesConsistencyDegree[i].length; j++) {
if (alternativesConsistencyDegree[i][j] < beta) {
for (int k = 0; k < (alternatives - 1); k++) {
for (int l = (k + 1); l < alternatives; l++) {
if ((Float) consistencyDegrees[i].getValue(k, l) < beta) {
p = (Float) preferences[i].getValue(k, l);
cp = overallEstimateValue(alternatives, k, l, (FPR) preferences[i]);
if (cp > 1) {
cp = 1f;
} else if (cp < 0) {
cp = 0f;
}
cd = 1f - Math.abs(cp - p);
if ((cp - p) >= 0) {
sign = 1f;
} else {
sign = -1f;
}
aux = p + sign * (beta - cd);
((FPR) preferences[i]).setValueSymmetrically(i, j, aux);
}
}
}
}
}
}
}
}
/**
* Compute proximity on alternatives for all experts
*
* @param experts
* Number of experts
* @param alternatives
* Number of alternatives
* @param proximityMatrices
* Proximity matrices
* @return Proximity on alternatives for all experts
*/
private static Float[][] computeProximityOnAlternatives(Integer experts, Integer alternatives, CM[] proximityMatrices) {
Float[][] result = new Float[experts][alternatives];
for (int i = 0; i < experts; i++) {
result[i] = ConsensusEngine.computeAlternativesConsensus(alternatives, proximityMatrices[i]);
}
return result;
}
/**
* Search low consensus Prefech for all experts
*
* @param experts
* Number of experts
* @param alternatives
* Number of alternatives
* @param cm
* Consensus matrix
* @param cr
* Consensus on the relation
* @param preferences
* All FPR
* @return Low consensus Prefech for all experts
*/
private static List<List<Advice>> lowConsensusPreferencesSearch(Integer experts, Integer alternatives, CM cm, float cr, Structure[] preferences) {
List<List<Advice>> result = new ArrayList<>();
for (int i = 0; i < experts; i++) {
result.add(lowConsensusPreferencesSearch(alternatives, cm, cr, (FPR) preferences[experts], (FPR) preferences[i]));
}
return result;
}
/**
* Search low consensus Prefech for one expert
*
* @param alternatives
* Number of alternatives
* @param cm
* Consensus matrix
* @param cr
* Consensus on the relation
* @param gP
* Group preferences
* @param eP
* Expert preferences
* @return Low consensus Prefech for one expert
*/
private static List<Advice> lowConsensusPreferencesSearch(Integer alternatives, CM cm, float cr, FPR gP, FPR eP) {
List<Advice> result = new ArrayList<>();
Advice prefech;
for (int i = 0; i < alternatives - 1; i++) {
for (int j = (i + 1); j < alternatives; j++) {
if ((float) cm.getValue(i, j) < cr) {
prefech = new Advice(i, j);
prefech.setGroupValue((Float) gP.getValue(i, j));
prefech.setExpertValue((Float) eP.getValue(i, j));
result.add(prefech);
prefech = new Advice(j, i);
prefech.setGroupValue((Float) gP.getValue(j, i));
prefech.setExpertValue((Float) eP.getValue(j, i));
result.add(prefech);
}
}
}
return result;
}
/**
* Search medium consensus Prefech for all experts
*
* @param experts
* Number of experts
* @param alternatives
* Number of alternatives
* @param cm
* Consensus matrix
* @param cr
* Consensus on the relation
* @param consensusOnAlternatives
* Consensus on alternatives
* @param proximityOnAlternatives
* Proximity on alternatives for all experts
* @param preferences
* All FPR
* @return Medium consensus Prefech for all experts
*/
private static List<List<Advice>> mediumConsensusPreferencesSearch(Integer experts, Integer alternatives, CM cm, float cr, Float[] consensusOnAlternatives, Float[][] proximityOnAlternatives,
Structure[] preferences) {
List<List<Advice>> result = new ArrayList<>();
Float[] proximityAverageForAlternatives = new Float[alternatives];
float value;
for (int alternative = 0; alternative < alternatives; alternative++) {
value = 0;
for (int expert = 0; expert < experts; expert++) {
value += proximityOnAlternatives[expert][alternative];
}
proximityAverageForAlternatives[alternative] = value / ((float) experts);
}
for (int expert = 0; expert < experts; expert++) {
result.add(mediumConsensusPreferencesSearch(alternatives, cm, cr, consensusOnAlternatives, proximityOnAlternatives[expert], proximityAverageForAlternatives, (FPR) preferences[experts],
(FPR) preferences[expert]));
}
return result;
}
/**
* Search medium consensus Prefech for one expert
*
* @param alternatives
* Number of alternatives
* @param cm
* Consensus matrix
* @param cr
* Consensus on the relation
* @param consensusOnAlternatives
* Consensus on alternatives
* @param proximityOnAlternativesForExpert
* Proximity on alternatives for expert
* @param proximityAverageForAlternatives
* Proximity average for alternatives
* @param gP
* Group preferences
* @param eP
* Expert preferences
* @return Medium consensus Prefech for one expert
*/
private static List<Advice> mediumConsensusPreferencesSearch(Integer alternatives, CM cm, float cr, Float[] consensusOnAlternatives, Float[] proximityOnAlternativesForExpert,
Float[] proximityAverageForAlternatives, FPR gP, FPR eP) {
List<Advice> result = new ArrayList<>();
Map<Integer, Set<Integer>> insertedPrefech = new HashMap<>();
for (int i = 0; i < alternatives; i++) {
insertedPrefech.put(i, new HashSet<Integer>());
}
Advice prefech;
for (int i = 0; i < alternatives; i++) {
if (consensusOnAlternatives[i] < cr) {
for (int j = 0; j < alternatives; j++) {
if (i != j) {
if ((float) cm.getValue(i, j) < cr) {
if (proximityOnAlternativesForExpert[i] < proximityAverageForAlternatives[i]) {
if (!insertedPrefech.get(i).contains(j)) {
prefech = new Advice(i, j);
prefech.setGroupValue((Float) gP.getValue(i, j));
prefech.setExpertValue((Float) eP.getValue(i, j));
result.add(prefech);
insertedPrefech.get(i).add(j);
}
if (!insertedPrefech.get(j).contains(i)) {
prefech = new Advice(j, i);
prefech.setGroupValue((Float) gP.getValue(j, i));
prefech.setExpertValue((Float) eP.getValue(j, i));
result.add(prefech);
insertedPrefech.get(j).add(i);
}
}
}
}
}
}
}
return result;
}
/**
* Search high consensus Prefech for all experts
*
* @param experts
* Number of experts
* @param alternatives
* Number of alternatives
* @param cm
* Consensus matrix
* @param cr
* Consensus on the relation
* @param consensusOnAlternatives
* Consensus on alternatives
* @param proximityOnAlternatives
* Proximity on alternatives for all experts
* @param proximityMatrices
* Proximity matrices
* @param preferences
* All FPR
* @return High consensus Prefech for all experts
*/
private static List<List<Advice>> highConsensusPreferencesSearch(Integer experts, Integer alternatives, CM cm, float cr, Float[] consensusOnAlternatives, Float[][] proximityOnAlternatives,
CM[] proximityMatrices, Structure[] preferences) {
List<List<Advice>> result = new ArrayList<>();
// Compute proximity average for alternatives
Float[] proximityAverageForAlternatives = new Float[alternatives];
float value;
for (int alternative = 0; alternative < alternatives; alternative++) {
value = 0;
for (int expert = 0; expert < experts; expert++) {
value += proximityOnAlternatives[expert][alternative];
}
proximityAverageForAlternatives[alternative] = value / ((float) experts);
}
// Compute proximity average for preferences
CM cmAverage = new CM(alternatives);
for (int i = 0; i < (alternatives - 1); i++) {
for (int j = (i + 1); j < alternatives; j++) {
value = 0;
for (int k = 0; k < experts; k++) {
value += (float) proximityMatrices[k].getValue(i, j);
}
cmAverage.setValue(i, j, value / ((float) experts));
}
}
for (int expert = 0; expert < experts; expert++) {
result.add(highConsensusPreferencesSearch(alternatives, cm, cr, consensusOnAlternatives, proximityOnAlternatives[expert], proximityAverageForAlternatives, proximityMatrices[expert],
cmAverage, (FPR) preferences[experts], (FPR) preferences[expert]));
}
return result;
}
/**
* Search high consensus Prefech for one expert
*
* @param alternatives
* Number of alternatives
* @param cm
* Consensus matrix
* @param cr
* Consensus on the relation
* @param consensusOnAlternatives
* Consensus on alternatives
* @param proximityOnAlternativesForExpert
* Proximity on alternatives for expert
* @param proximityAverageForAlternatives
* Proximity average for alternatives
* @param eCM
* Expert consensus matrix
* @param aCM
* Average consensus matrix
* @param gP
* Group preferences
* @param eP
* Expert preferences
* @return High consensus Prefech for one expert
*/
private static List<Advice> highConsensusPreferencesSearch(Integer alternatives, CM cm, float cr, Float[] consensusOnAlternatives, Float[] proximityOnAlternativesForExpert,
Float[] proximityAverageForAlternatives, CM eCM, CM aCM, FPR gP, FPR eP) {
List<Advice> result = new ArrayList<>();
Map<Integer, Set<Integer>> insertedPrefech = new HashMap<>();
for (int i = 0; i < alternatives; i++) {
insertedPrefech.put(i, new HashSet<Integer>());
}
Advice prefech;
for (int i = 0; i < alternatives; i++) {
if (consensusOnAlternatives[i] < cr) {
for (int j = 0; j < alternatives; j++) {
if (i != j) {
if ((float) cm.getValue(i, j) < cr) {
if (proximityOnAlternativesForExpert[i] < proximityAverageForAlternatives[i]) {
if ((float) eCM.getValue(i, j) < (float) aCM.getValue(i, j)) {
if (!insertedPrefech.get(i).contains(j)) {
prefech = new Advice(i, j);
prefech.setGroupValue((Float) gP.getValue(i, j));
prefech.setExpertValue((Float) eP.getValue(i, j));
result.add(prefech);
insertedPrefech.get(i).add(j);
}
if (!insertedPrefech.get(j).contains(i)) {
prefech = new Advice(j, i);
prefech.setGroupValue((Float) gP.getValue(j, i));
prefech.setExpertValue((Float) eP.getValue(j, i));
result.add(prefech);
insertedPrefech.get(j).add(i);
}
}
}
}
}
}
}
}
return result;
}
/**
* Make Prefechs
*
* @param preferences
* All FPR
* @param prefechs
* List of Prefech for all experts
*/
private void makePrefechs(Structure[] preferences, List<List<Advice>> prefechs) {
int experts = prefechs.size();
List<Advice> expertPrefech;
List<Advice> upperDiagonalPrefech;
List<Advice> changesToMake;
FPR eP;
for (int expert = 0; expert < experts; expert++) {
expertPrefech = prefechs.get(expert);
eP = (FPR) preferences[expert];
// Select upper diagonal Prefechs
upperDiagonalPrefech = new ArrayList<>();
for (Advice p : expertPrefech) {
if (p.getAlternative1() < p.getAlternative2()) {
upperDiagonalPrefech.add(p);
}
}
// Select changes to make
changesToMake = new ArrayList<>();
for (Advice p : upperDiagonalPrefech) {
if (p.getChange() != EChangeType.NotChange) {
changesToMake.add(p);
}
}
// Get behavior for changes
double[] changes = getNChanges(changesToMake.size());
// Set changes sign
for (int i = 0; i < changes.length; i++) {
if (changesToMake.get(i).getChange() == EChangeType.Decrease) {
changes[i] *= -1f;
}
}
// Make changes
int a1;
int a2;
Float value;
for (int i = 0; i < changes.length; i++) {
a1 = changesToMake.get(i).getAlternative1();
a2 = changesToMake.get(i).getAlternative2();
value = (float) (changes[i] + (Float) eP.getValue(a1, a2));
if (value > 1f) {
value = 1f;
} else if (value < 0f) {
value = 0f;
}
eP.setValueSymmetrically(a1, a2, value);
}
}
}
}
@@ -0,0 +1,10 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-SymbolicName: afryca.consensusmodel.chiclana2008;singleton:=true
Bundle-Version: 1.0.0.202101221157
Bundle-Vendor: %Bundle-Vendor
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Require-Bundle: afryca.consensusmodel,afryca.fpr
Automatic-Module-Name: afryca.consensusmodel.chiclana2008
@@ -0,0 +1,4 @@
#Fri Jan 22 13:00:49 CET 2021
artifact.main=C\:\\Users\\\u00C1lvaro\\Workspaces\\afryca_2020\\afryca\\plugins\\afryca.consensusmodel.chiclana2008\\target\\afryca.consensusmodel.chiclana2008-1.0.0-SNAPSHOT.jar
artifact.attached.p2artifacts=C\:\\Users\\\u00C1lvaro\\Workspaces\\afryca_2020\\afryca\\plugins\\afryca.consensusmodel.chiclana2008\\target\\p2artifacts.xml
artifact.attached.p2metadata=C\:\\Users\\\u00C1lvaro\\Workspaces\\afryca_2020\\afryca\\plugins\\afryca.consensusmodel.chiclana2008\\target\\p2content.xml
@@ -0,0 +1,3 @@
artifactId=afryca.consensusmodel.chiclana2008
groupId=afryca.group
version=1.0.0-SNAPSHOT
@@ -0,0 +1,13 @@
<?xml version='1.0' encoding='UTF-8'?>
<?artifactRepository version='1.1.0'?>
<artifacts size='1'>
<artifact classifier='osgi.bundle' id='afryca.consensusmodel.chiclana2008' version='1.0.0.202101221157'>
<properties size='5'>
<property name='artifact.size' value='12978'/>
<property name='download.size' value='12978'/>
<property name='maven-groupId' value='afryca.group'/>
<property name='maven-artifactId' value='afryca.consensusmodel.chiclana2008'/>
<property name='maven-version' value='1.0.0-SNAPSHOT'/>
</properties>
</artifact>
</artifacts>
@@ -0,0 +1,49 @@
<?xml version='1.0' encoding='UTF-8'?>
<units size='1'>
<unit id='afryca.consensusmodel.chiclana2008' version='1.0.0.202101221157' generation='2'>
<update id='afryca.consensusmodel.chiclana2008' range='[0.0.0,1.0.0.202101221157)' severity='0'/>
<properties size='9'>
<property name='es.Bundle-Name' value='Chiclana2008'/>
<property name='es.Bundle-Vendor' value='Sinbad²'/>
<property name='df_LT.Bundle-Name' value='Chiclana2008'/>
<property name='df_LT.Bundle-Vendor' value='Sinbad²'/>
<property name='org.eclipse.equinox.p2.name' value='%Bundle-Name'/>
<property name='org.eclipse.equinox.p2.provider' value='%Bundle-Vendor'/>
<property name='maven-groupId' value='afryca.group'/>
<property name='maven-artifactId' value='afryca.consensusmodel.chiclana2008'/>
<property name='maven-version' value='1.0.0-SNAPSHOT'/>
</properties>
<provides size='6'>
<provided namespace='org.eclipse.equinox.p2.iu' name='afryca.consensusmodel.chiclana2008' version='1.0.0.202101221157'/>
<provided namespace='osgi.bundle' name='afryca.consensusmodel.chiclana2008' version='1.0.0.202101221157'/>
<provided namespace='osgi.identity' name='afryca.consensusmodel.chiclana2008' version='1.0.0.202101221157'>
<properties size='1'>
<property name='type' value='osgi.bundle'/>
</properties>
</provided>
<provided namespace='org.eclipse.equinox.p2.eclipse.type' name='bundle' version='1.0.0'/>
<provided namespace='org.eclipse.equinox.p2.localization' name='es' version='1.0.0'/>
<provided namespace='org.eclipse.equinox.p2.localization' name='df_LT' version='1.0.0'/>
</provides>
<requires size='3'>
<required namespace='osgi.bundle' name='afryca.consensusmodel' range='0.0.0'/>
<required namespace='osgi.bundle' name='afryca.fpr' range='0.0.0'/>
<requiredProperties namespace='osgi.ee' match='(&amp;(osgi.ee=JavaSE)(version=1.8))'>
<description>
afryca.consensusmodel.chiclana2008
</description>
</requiredProperties>
</requires>
<artifacts size='1'>
<artifact classifier='osgi.bundle' id='afryca.consensusmodel.chiclana2008' version='1.0.0.202101221157'/>
</artifacts>
<touchpoint id='org.eclipse.equinox.p2.osgi' version='1.0.0'/>
<touchpointData size='1'>
<instructions size='1'>
<instruction key='manifest'>
Bundle-SymbolicName: afryca.consensusmodel.chiclana2008;singleton:=true&#xA;Bundle-Version: 1.0.0.202101221157&#xA;
</instruction>
</instructions>
</touchpointData>
</unit>
</units>