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.arithmeticmean</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<name>[bundle] Arithmetic Mean</name>
</project>
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>flintstones.operator.aggregation.arithmeticmean</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>1779484362731</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,8 @@
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.release=disabled
org.eclipse.jdt.core.compiler.source=1.8
@@ -0,0 +1,4 @@
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
@@ -0,0 +1,25 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Arithmetic Mean
Bundle-SymbolicName: flintstones.operator.aggregation.arithmeticmean;singleton:=true
Bundle-Version: 1.0.0.qualifier
Automatic-Module-Name: flintstones.operator.aggregation.arithmeticmean
Bundle-RequiredExecutionEnvironment: JavaSE-11
Require-Bundle: flintstones.operator,
flintstones.entity.valuation,
flintstones.model.valuation.service,
flintstones.valuation.numeric.integer,
flintstones.valuation.numeric.real,
flintstones.valuation.linguistic,
flintstones.valuation.twoTuple,
flintstones.valuation.proportionaltwotuple,
flintstones.valuation.fuzzy,
flintstones.valuation.elicit,
flintstones.domain.numeric.real,
org.eclipse.e4.core.contexts,
javax.inject,
org.eclipse.e4.core.di,
flintstones.entity.domain,
flintstones.entity.operator
Export-Package: flintstones.operator.aggregation.arithmeticmean
Import-Package: org.eclipse.jface.wizard
@@ -0,0 +1,5 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
plugin.xml
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xml>
<?eclipse version="3.4"?>
<plugin>
<extension
point="flintstones.operator.aggregation.extensionpoint">
<aggregation_operator_type
uid="flintstones.operator.aggregation.arithmeticmean"
implementation="flintstones.operator.aggregation.arithmeticmean.ArithmeticMean">
<aggregation_operator
implementation="flintstones.operator.aggregation.arithmeticmean.operators.ArithmeticMeanInteger"
valuationId="flintstones.valuation.integer">
</aggregation_operator>
<aggregation_operator
implementation="flintstones.operator.aggregation.arithmeticmean.operators.ArithmeticMeanDouble"
valuationId="flintstones.valuation.real">
</aggregation_operator>
<aggregation_operator
implementation="flintstones.operator.aggregation.arithmeticmean.operators.ArithmeticMeanTwoTuple"
valuationId="flintstones.valuation.twoTuple">
</aggregation_operator>
<aggregation_operator
implementation="flintstones.operator.aggregation.arithmeticmean.operators.ArithmeticMeanProportionalTwoTuple"
valuationId="flintstones.valuation.proportionaltwotuple">
</aggregation_operator>
<aggregation_operator
implementation="flintstones.operator.aggregation.arithmeticmean.operators.ArithmeticMeanFuzzy"
valuationId="flintstones.valuation.fuzzy">
</aggregation_operator>
<aggregation_operator
implementation="flintstones.operator.aggregation.arithmeticmean.operators.ArithmeticMeanELICIT"
valuationId="flintstones.valuation.elicit">
</aggregation_operator>
</aggregation_operator_type>
</extension>
</plugin>
@@ -0,0 +1,19 @@
package flintstones.operator.aggregation.arithmeticmean;
import flintstones.entity.operator.AggregationOperator;
import flintstones.entity.operator.interfaces.IUnweightedAggregationOperator;
import flintstones.entity.operator.interfaces.IWeightedAggregationOperator;
/**
* The Class ArithmeticMean.
* https://en.wikipedia.org/wiki/Arithmetic_mean
*/
public abstract class ArithmeticMean extends AggregationOperator implements IUnweightedAggregationOperator, IWeightedAggregationOperator {
public static final String ID = "flintstones.operator.aggregation.arithmeticmean";
@Override
public String getName() {
return "Arithmetic Mean";
}
}
@@ -0,0 +1,77 @@
package flintstones.operator.aggregation.arithmeticmean.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.arithmeticmean.ArithmeticMean;
import flintstones.valuation.numeric.real.RealValuation;
public class ArithmeticMeanDouble extends ArithmeticMean {
@Override
public Valuation aggregate(List<Valuation> valuations) {
RealValuation result = null;
double value = 0;
int size = valuations.size();
NumericRealDomain domain = null;
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("Messages.RealOperator_Invalid_domain");
}
value += (((RealValuation) valuation).getValue()) / size;
}
if(domain != null) {
result = (RealValuation) valuations.get(0).clone();
result.setValue(value);
}
return result;
}
@Override
public Valuation aggregate(List<Valuation> valuations, List<Double> weights) {
RealValuation result = null;
double measure = 0;
List<Double> measures = new LinkedList<Double>();
NumericRealDomain domain = null;
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("Messages.RealOperator_Invalid_domain");
}
measures.add(((RealValuation) valuation).getValue());
}
if (domain != null) {
int size = measures.size();
for (int i = 0; i < size; i++) {
measure += weights.get(i) * measures.get(i);
}
result = (RealValuation) valuations.get(0).clone();
result.setValue( measure);
}
return result;
}
}
@@ -0,0 +1,79 @@
package flintstones.operator.aggregation.arithmeticmean.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.arithmeticmean.ArithmeticMean;
import flintstones.valuation.elicit.ELICIT;
public class ArithmeticMeanELICIT extends ArithmeticMean {
@Inject
IEclipseContext context;
@Override
public Valuation aggregate(List<Valuation> valuations) {
ELICIT v = null;
TrapezoidalFunction tpf,
tpfResult = new TrapezoidalFunction();
tpfResult.setLimits(new double[] {0, 0, 0, 0});
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.additionAlphaCuts(tpf);
}
tpfResult = tpfResult.divisionScalar(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[] {0, 0, 0, 0});
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.multiplicationScalar(weights.get(i));
tpfResult = tpfResult.additionAlphaCuts(tpf);
}
ELICIT aggregatedElicit = ContextInjectionFactory.make(ELICIT.class, context);
aggregatedElicit.setDomain(valuations.get(0).getDomain());
aggregatedElicit.createRelation(tpfResult);
return aggregatedElicit;
}
}
@@ -0,0 +1,86 @@
package flintstones.operator.aggregation.arithmeticmean.operators;
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.arithmeticmean.ArithmeticMean;
import flintstones.valuation.fuzzy.FuzzyValuation;
public class ArithmeticMeanFuzzy extends ArithmeticMean implements IFuzzyWeightedAggregationOperator {
@Override
public Valuation aggregate(List<Valuation> valuations) {
FuzzyValuation v = null;
TrapezoidalFunction tpf, tpfResult = new TrapezoidalFunction();
tpfResult.setLimits(new double[] { 0, 0, 0, 0 });
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 = v.getFuzzyNumber();
tpfResult = tpfResult.additionAlphaCuts(tpf);
}
tpfResult = tpfResult.divisionScalar(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[] { 0, 0, 0, 0 });
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 = v.getFuzzyNumber();
tpf = tpf.multiplicationScalar(weights.get(i));
tpfResult = tpfResult.additionAlphaCuts(tpf);
}
FuzzyValuation aggregatedFuzzyValuation = new FuzzyValuation(tpfResult, valuations.get(0).getDomain());
return aggregatedFuzzyValuation;
}
@Override
public Valuation aggregateF(List<Valuation> valuations, List<TrapezoidalFunction> weights) {
FuzzyValuation v = null;
TrapezoidalFunction tpf, tpfResult = new TrapezoidalFunction();
tpfResult.setLimits(new double[] { 0, 0, 0, 0 });
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 = v.getFuzzyNumber();
tpf = tpf.multiplication(weights.get(i));
tpfResult = tpfResult.additionAlphaCuts(tpf);
}
tpfResult = tpfResult.divisionScalar(size);
FuzzyValuation aggregatedFuzzyValuation = new FuzzyValuation(tpfResult, valuations.get(0).getDomain());
return aggregatedFuzzyValuation;
}
}
@@ -0,0 +1,72 @@
package flintstones.operator.aggregation.arithmeticmean.operators;
import java.util.LinkedList;
import java.util.List;
import java.util.OptionalDouble;
import javax.inject.Inject;
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
import org.eclipse.e4.core.contexts.IEclipseContext;
import flintstones.domain.numeric.integer.NumericIntegerDomain;
import flintstones.entity.valuation.Valuation;
import flintstones.helper.validator.Validator;
import flintstones.operator.aggregation.arithmeticmean.ArithmeticMean;
import flintstones.valuation.numeric.integer.IntegerValuation;
public class ArithmeticMeanInteger extends ArithmeticMean {
@Inject
IEclipseContext context;
@Override
public Valuation aggregate(List<Valuation> valuations) {
OptionalDouble averageOptional = valuations.stream().mapToDouble(k -> ((IntegerValuation) k).getValue())
.average();
double average = averageOptional.getAsDouble();
// Es necesario mantener el dominio? (clonar)
IntegerValuation result = ContextInjectionFactory.make(IntegerValuation.class, context);
result.setDomain(valuations.get(0).getDomain());
result.setValue(Math.round(average));
return result;
}
@Override
public Valuation aggregate(List<Valuation> valuations, List<Double> weights) {
IntegerValuation result = null;
double measure = 0;
List<Double> measures = new LinkedList<Double>();
NumericIntegerDomain domain = null;
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("Messages.IntegerOperator_Invalid_domain");
}
measures.add(((IntegerValuation) valuation).getValue());
}
if (domain != null) {
int size = measures.size();
for (int i = 0; i < size; i++) {
measure += weights.get(i) * measures.get(i);
}
result = (IntegerValuation) valuations.get(0).clone();
result.setValue(measure);
}
return result;
}
}
@@ -0,0 +1,75 @@
package flintstones.operator.aggregation.arithmeticmean.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.arithmeticmean.ArithmeticMean;
import flintstones.valuation.proportionaltwotuple.ProportionalTwoTuple;
import flintstones.valuation.twoTuple.TwoTupleValuation;
public class ArithmeticMeanProportionalTwoTuple extends ArithmeticMean {
@Override
public Valuation aggregate(List<Valuation> valuations) {
ProportionalTwoTuple result = null;
FuzzySet domain = null;
double beta = 0;
for(Valuation valuation : valuations) {
Validator.notIllegalElementType(valuation, new String[] { ProportionalTwoTuple.class.toString() });
if(domain == null)
domain = (FuzzySet) valuation.getDomain();
else if(!domain.equals(valuation.getDomain()))
throw new IllegalArgumentException("Invalid_domain");
beta += ((ProportionalTwoTuple) valuation).calculatePi();
}
beta /= valuations.size();
if (domain != null) {
result = (ProportionalTwoTuple) valuations.get(0).clone();
result.calculateInversePi(beta);
}
return result;
}
@Override
public Valuation aggregate(List<Valuation> valuations, List<Double> weights) {
ProportionalTwoTuple 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(((ProportionalTwoTuple) valuation).calculatePi());
}
if (domain != null) {
double beta = 0;
for (int i = 0; i < measures.size(); i++)
beta += weights.get(i) * measures.get(i);
result = (ProportionalTwoTuple) valuations.get(0).clone();
result.calculateInversePi(beta);
}
return result;
}
}
@@ -0,0 +1,81 @@
package flintstones.operator.aggregation.arithmeticmean.operators;
import java.util.LinkedList;
import java.util.List;
import javax.inject.Inject;
import org.eclipse.e4.core.contexts.IEclipseContext;
import flintstones.domain.fuzzyset.FuzzySet;
import flintstones.entity.valuation.Valuation;
import flintstones.helper.validator.Validator;
import flintstones.operator.aggregation.arithmeticmean.ArithmeticMean;
import flintstones.valuation.twoTuple.TwoTupleValuation;
public class ArithmeticMeanTwoTuple extends ArithmeticMean {
@Inject
IEclipseContext context;
@Override
public Valuation aggregate(List<Valuation> valuations) {
TwoTupleValuation result = null;
double beta = 0;
FuzzySet domain = null;
int size = valuations.size();
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("Messages.TwoTupleOperator_Invalid_domain");
}
beta += (((TwoTupleValuation) valuation).calculateInverseDelta());
}
beta /= size;
if (domain != null) {
result = (TwoTupleValuation) valuations.get(0).clone();
result.calculateDelta(beta);
}
return result;
}
@Override
public Valuation aggregate(List<Valuation> valuations, List<Double> weights) {
TwoTupleValuation result = null;
List<Double> measures = new LinkedList<Double>();
FuzzySet domain = null;
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("Messages.TwoTupleOperator_Invalid_domain");
}
measures.add(((TwoTupleValuation) valuation).calculateInverseDelta());
}
if (domain != null) {
int size = measures.size();
double beta = 0;
for (int i = 0; i < size; i++) {
beta += weights.get(i) * measures.get(i);
}
result = (TwoTupleValuation) valuations.get(0).clone();
result.calculateDelta(beta);
}
return result;
}
}