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.operator.aggregation.geometricMean</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<name>[bundle] GeometricMean</name>
</project>
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>flintstones.operator.aggregation.geometricMean</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>1779484362732</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,22 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: GeometricMean
Bundle-SymbolicName: flintstones.operator.aggregation.geometricMean;singleton:=true
Bundle-Version: 1.0.0.qualifier
Automatic-Module-Name: flintstones.operator.aggregation.geometricMean
Bundle-RequiredExecutionEnvironment: JavaSE-11
Require-Bundle: flintstones.operator,
flintstones.entity.valuation,
flintstones.model.valuation.service,
flintstones.domain.numeric.real,
flintstones.valuation.numeric.real,
flintstones.valuation.numeric.integer,
flintstones.valuation.twoTuple,
flintstones.entity.domain,
flintstones.entity.operator,
flintstones.valuation.elicit,
org.eclipse.e4.core.contexts,
javax.inject,
org.eclipse.e4.core.di,
flintstones.valuation.fuzzy
Export-Package: flintstones.operator.aggregation.geometricMean
@@ -0,0 +1,5 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
plugin.xml
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
point="flintstones.operator.aggregation.extensionpoint">
<aggregation_operator_type
uid="flintstones.operator.aggregation.geometricMean"
implementation="flintstones.operator.aggregation.geometricMean.GeometricMean">
<aggregation_operator
implementation="flintstones.operator.aggregation.geometricMean.operators.GeometricMeanInteger"
valuationId="flintstones.valuation.integer">
</aggregation_operator>
<aggregation_operator
implementation="flintstones.operator.aggregation.geometricMean.operators.GeometricMeanReal"
valuationId="flintstones.valuation.real">
</aggregation_operator>
<aggregation_operator
implementation="flintstones.operator.aggregation.geometricMean.operators.GeometricMeanTwoTuple"
valuationId="flintstones.valuation.twoTuple">
</aggregation_operator>
<aggregation_operator
implementation="flintstones.operator.aggregation.geometricMean.operators.GeometricMeanFuzzy"
valuationId="flintstones.valuation.fuzzy">
</aggregation_operator>
<aggregation_operator
implementation="flintstones.operator.aggregation.geometricMean.operators.GeometricMeanELICIT"
valuationId="flintstones.valuation.elicit">
</aggregation_operator>
</aggregation_operator_type>
</extension>
</plugin>
@@ -0,0 +1,14 @@
package flintstones.operator.aggregation.geometricMean;
import flintstones.entity.operator.AggregationOperator;
import flintstones.entity.operator.interfaces.IUnweightedAggregationOperator;
import flintstones.entity.operator.interfaces.IWeightedAggregationOperator;
public abstract class GeometricMean extends AggregationOperator implements IUnweightedAggregationOperator, IWeightedAggregationOperator {
@Override
public String getName() {
return "Geometric Mean";
}
}
@@ -0,0 +1,81 @@
package flintstones.operator.aggregation.geometricMean.operators;
import java.util.List;
import javax.inject.Inject;
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
import org.eclipse.e4.core.contexts.IEclipseContext;
import flintstones.domain.fuzzyset.function.types.TrapezoidalFunction;
import flintstones.entity.valuation.Valuation;
import flintstones.helper.validator.Validator;
import flintstones.operator.aggregation.geometricMean.GeometricMean;
import flintstones.valuation.elicit.ELICIT;
public class GeometricMeanELICIT extends GeometricMean {
@Inject
IEclipseContext context;
@Override
public Valuation aggregate(List<Valuation> valuations) {
ELICIT v = null;
TrapezoidalFunction tpf,
tpfResult = new TrapezoidalFunction();
tpfResult.setLimits(new double[] {1, 1, 1, 1});
int size = valuations.size();
for(int i = 0; i < size; ++i) {
v = (ELICIT) valuations.get(i);
Validator.notIllegalElementType(v, new String[] { ELICIT.class.toString() });
if(((ELICIT) v).getBeta() == null)
tpf = ((ELICIT) v).calculateFuzzyEnvelope();
else
tpf = ((ELICIT) v).getBeta();
tpfResult = tpfResult.multiplicationAlphaCuts(tpf);
}
tpfResult = tpfResult.potence(1d / size);
ELICIT aggregatedElicit = ContextInjectionFactory.make(ELICIT.class, context);
aggregatedElicit.setDomain(valuations.get(0).getDomain());
aggregatedElicit.createRelation(tpfResult);
return aggregatedElicit;
}
@Override
public Valuation aggregate(List<Valuation> valuations, List<Double> weights) {
ELICIT v = null;
TrapezoidalFunction tpf,
tpfResult = new TrapezoidalFunction();
tpfResult.setLimits(new double[] {1, 1, 1, 1});
int size = valuations.size();
for(int i = 0; i < size; ++i) {
v = (ELICIT) valuations.get(i);
Validator.notIllegalElementType(v, new String[] { ELICIT.class.toString() });
if(((ELICIT) v).getBeta() == null)
tpf = ((ELICIT) v).calculateFuzzyEnvelope();
else
tpf = ((ELICIT) v).getBeta();
tpf = tpf.potence(weights.get(i));
tpfResult = tpfResult.multiplicationAlphaCuts(tpf);
}
ELICIT aggregatedElicit = ContextInjectionFactory.make(ELICIT.class, context);
aggregatedElicit.setDomain(valuations.get(0).getDomain());
aggregatedElicit.createRelation(tpfResult);
return aggregatedElicit;
}
}
@@ -0,0 +1,88 @@
package flintstones.operator.aggregation.geometricMean.operators;
import java.util.ArrayList;
import java.util.List;
import flintstones.domain.fuzzyset.function.types.TrapezoidalFunction;
import flintstones.entity.operator.interfaces.IFuzzyWeightedAggregationOperator;
import flintstones.entity.valuation.Valuation;
import flintstones.helper.validator.Validator;
import flintstones.operator.aggregation.geometricMean.GeometricMean;
import flintstones.valuation.fuzzy.FuzzyValuation;
public class GeometricMeanFuzzy extends GeometricMean implements IFuzzyWeightedAggregationOperator {
public Valuation aggregate(List<Valuation> valuations) {
FuzzyValuation v = null;
TrapezoidalFunction tpf,
tpfResult = new TrapezoidalFunction();
tpfResult.setLimits(new double[] {1, 1, 1, 1});
int size = valuations.size();
for(int i = 0; i < size; ++i) {
v = (FuzzyValuation) valuations.get(i);
Validator.notIllegalElementType(v, new String[] { FuzzyValuation.class.toString() });
tpf = ((FuzzyValuation) v).getFuzzyNumber();
tpfResult = tpfResult.multiplicationAlphaCuts(tpf);
}
tpfResult = tpfResult.potence(1d / size);
FuzzyValuation aggregatedFuzzyValuation = new FuzzyValuation(tpfResult, valuations.get(0).getDomain());
return aggregatedFuzzyValuation;
}
@Override
public Valuation aggregate(List<Valuation> valuations, List<Double> weights) {
FuzzyValuation v = null;
TrapezoidalFunction tpf,
tpfResult = new TrapezoidalFunction();
tpfResult.setLimits(new double[] {1, 1, 1, 1});
int size = valuations.size();
for(int i = 0; i < size; ++i) {
v = (FuzzyValuation) valuations.get(i);
Validator.notIllegalElementType(v, new String[] { FuzzyValuation.class.toString() });
tpf = ((FuzzyValuation) v).getFuzzyNumber();
tpf = tpf.potence(weights.get(i));
tpfResult = tpfResult.multiplicationAlphaCuts(tpf);
}
FuzzyValuation aggregatedFuzzyValuation = new FuzzyValuation(tpfResult, valuations.get(0).getDomain());
return aggregatedFuzzyValuation;
}
//TODO Fix to a proper fuzzy weighted geometric mean aggregation operator
@Override
public Valuation aggregateF(List<Valuation> valuations, List<TrapezoidalFunction> weights) {
List<Double> defuzziedWeights = new ArrayList<Double>();
double acum = 0, centroid;
for(TrapezoidalFunction w: weights) {
centroid = w.centroid();
if(Double.valueOf(centroid).isNaN())//Fuzzy number (1, 1, 1)
centroid = w.getLimits()[1];
defuzziedWeights.add(centroid);
acum += centroid;
}
List<Double> normalizedDefuzziedWeights = new ArrayList<Double>();
for(Double dw: defuzziedWeights)
normalizedDefuzziedWeights.add(dw / acum);
return aggregate(valuations, normalizedDefuzziedWeights);
}
}
@@ -0,0 +1,63 @@
package flintstones.operator.aggregation.geometricMean.operators;
import java.util.LinkedList;
import java.util.List;
import flintstones.domain.numeric.integer.NumericIntegerDomain;
import flintstones.entity.valuation.Valuation;
import flintstones.helper.validator.Validator;
import flintstones.operator.aggregation.geometricMean.GeometricMean;
import flintstones.valuation.numeric.integer.IntegerValuation;
public class GeometricMeanInteger extends GeometricMean {
public Valuation aggregate(List<Valuation> valuations) {
IntegerValuation result = null;
double value = 1;
for (Valuation valuation : valuations)
value *= ((IntegerValuation) valuation).getValue();
double aux = (long) Math.pow(value, 1d / valuations.size());
result = (IntegerValuation) valuations.get(0).clone();
result.setValue(aux);
return result;
}
@Override
public Valuation aggregate(List<Valuation> valuations, List<Double> weights) {
IntegerValuation result = null;
NumericIntegerDomain domain = null;
List<Double> measures = new LinkedList<Double>();
for(Valuation valuation : valuations) {
Validator.notIllegalElementType(valuation, new String[] { IntegerValuation.class.toString() });
if (domain == null)
domain = (NumericIntegerDomain) valuation.getDomain();
else if (!domain.equals(valuation.getDomain()))
throw new IllegalArgumentException("Invalid domain");
measures.add(((IntegerValuation) valuation).getValue());
}
if (domain != null) {
double measure = 1;
for (int i = 0; i < measures.size(); i++)
measure *= Math.pow(measures.get(i), weights.get(i));
result = (IntegerValuation) valuations.get(0).clone();
result.setValue(measure);
}
return result;
}
}
@@ -0,0 +1,64 @@
package flintstones.operator.aggregation.geometricMean.operators;
import java.util.LinkedList;
import java.util.List;
import flintstones.domain.numeric.real.NumericRealDomain;
import flintstones.entity.valuation.Valuation;
import flintstones.helper.validator.Validator;
import flintstones.operator.aggregation.geometricMean.GeometricMean;
import flintstones.valuation.numeric.real.RealValuation;
public class GeometricMeanReal extends GeometricMean {
@Override
public Valuation aggregate(List<Valuation> valuations) {
RealValuation result = null;
double value = 1;
for (Valuation valuation : valuations)
value *= ((RealValuation) valuation).getValue();
double aux = Math.pow(value, 1d / valuations.size());
result = (RealValuation) valuations.get(0).clone();
result.setValue(aux);
return result;
}
@Override
public Valuation aggregate(List<Valuation> valuations, List<Double> weights) {
RealValuation result = null;
NumericRealDomain domain = null;
List<Double> measures = new LinkedList<Double>();
for(Valuation valuation : valuations) {
Validator.notIllegalElementType(valuation, new String[] { RealValuation.class.toString() });
if (domain == null)
domain = (NumericRealDomain) valuation.getDomain();
else if (!domain.equals(valuation.getDomain()))
throw new IllegalArgumentException("Invalid domain");
measures.add(((RealValuation) valuation).getValue());
}
if (domain != null) {
double measure = 1;
for (int i = 0; i < measures.size(); i++)
measure *= Math.pow(measures.get(i), weights.get(i));
result = (RealValuation) valuations.get(0).clone();
result.setValue(measure);
}
return result;
}
}
@@ -0,0 +1,59 @@
package flintstones.operator.aggregation.geometricMean.operators;
import java.util.LinkedList;
import java.util.List;
import flintstones.domain.fuzzyset.FuzzySet;
import flintstones.entity.valuation.Valuation;
import flintstones.helper.validator.Validator;
import flintstones.operator.aggregation.geometricMean.GeometricMean;
import flintstones.valuation.twoTuple.TwoTupleValuation;
public class GeometricMeanTwoTuple extends GeometricMean {
public Valuation aggregate(List<Valuation> valuations) {
TwoTupleValuation result = null;
double beta = 1;
for (Valuation valuation : valuations)
beta *= (((TwoTupleValuation) valuation).calculateInverseDelta());
double aux = Math.pow(beta, 1d / valuations.size());
result = (TwoTupleValuation) valuations.get(0).clone();
result.calculateDelta(aux);
return result;
}
@Override
public Valuation aggregate(List<Valuation> valuations, List<Double> weights) {
TwoTupleValuation result = null;
FuzzySet domain = null;
List<Double> measures = new LinkedList<Double>();
for(Valuation valuation : valuations) {
Validator.notIllegalElementType(valuation, new String[] { TwoTupleValuation.class.toString() });
if (domain == null)
domain = (FuzzySet) valuation.getDomain();
else if (!domain.equals(valuation.getDomain()))
throw new IllegalArgumentException("Invalid domain");
measures.add(((TwoTupleValuation) valuation).calculateInverseDelta());
}
if (domain != null) {
double beta = 1;
for (int i = 0; i < measures.size(); i++)
beta *= Math.pow(measures.get(i), weights.get(i));
result = (TwoTupleValuation) valuations.get(0).clone();
result.calculateDelta(beta);
}
return result;
}
}