public code v1
This commit is contained in:
@@ -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.harmonicmean</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<packaging>eclipse-plugin</packaging>
|
||||
<name>[bundle] Harmonicmean</name>
|
||||
</project>
|
||||
@@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>flintstones.operator.aggregation.harmonicmean</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>1779484362733</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>
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding/<project>=UTF-8
|
||||
+7
@@ -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
|
||||
+4
@@ -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: Harmonicmean
|
||||
Bundle-SymbolicName: flintstones.operator.aggregation.harmonicmean;singleton:=true
|
||||
Bundle-Version: 1.0.0.qualifier
|
||||
Automatic-Module-Name: flintstones.operator.aggregation.harmonicmean
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
|
||||
Require-Bundle: flintstones.operator,
|
||||
flintstones.entity.valuation,
|
||||
flintstones.model.valuation.service,
|
||||
flintstones.valuation.numeric.integer,
|
||||
flintstones.helper.validator,
|
||||
flintstones.valuation.numeric.real,
|
||||
flintstones.domain.numeric.real,
|
||||
flintstones.valuation.twoTuple,
|
||||
flintstones.entity.domain,
|
||||
flintstones.entity.operator
|
||||
@@ -0,0 +1,5 @@
|
||||
source.. = src/
|
||||
output.. = bin/
|
||||
bin.includes = META-INF/,\
|
||||
.,\
|
||||
plugin.xml
|
||||
@@ -0,0 +1,24 @@
|
||||
<?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.harmonicmean"
|
||||
implementation="flintstones.operator.aggregation.harmonicmean.HarmonicMean">
|
||||
<aggregation_operator
|
||||
implementation="flintstones.operator.aggregation.harmonicmean.operators.HarmonicMeanInteger"
|
||||
valuationId="flintstones.valuation.integer">
|
||||
</aggregation_operator>
|
||||
<aggregation_operator
|
||||
implementation="flintstones.operator.aggregation.harmonicmean.operators.HarmonicMeanReal"
|
||||
valuationId="flintstones.valuation.real">
|
||||
</aggregation_operator>
|
||||
<aggregation_operator
|
||||
implementation="flintstones.operator.aggregation.harmonicmean.operators.HarmonicMeanTwoTuple"
|
||||
valuationId="flintstones.valuation.twoTuple">
|
||||
</aggregation_operator>
|
||||
</aggregation_operator_type>
|
||||
</extension>
|
||||
|
||||
</plugin>
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package flintstones.operator.aggregation.harmonicmean;
|
||||
|
||||
import flintstones.entity.operator.AggregationOperator;
|
||||
import flintstones.entity.operator.interfaces.IUnweightedAggregationOperator;
|
||||
import flintstones.entity.operator.interfaces.IWeightedAggregationOperator;
|
||||
|
||||
public abstract class HarmonicMean extends AggregationOperator implements IUnweightedAggregationOperator, IWeightedAggregationOperator {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Harmonic Mean";
|
||||
}
|
||||
|
||||
}
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
package flintstones.operator.aggregation.harmonicmean.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.harmonicmean.HarmonicMean;
|
||||
import flintstones.valuation.numeric.integer.IntegerValuation;
|
||||
|
||||
public class HarmonicMeanInteger extends HarmonicMean {
|
||||
|
||||
@Override
|
||||
public Valuation aggregate(List<Valuation> valuations) {
|
||||
IntegerValuation result = null;
|
||||
double value = 0, aux = 0;
|
||||
int size = valuations.size();
|
||||
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("Invalid domain");
|
||||
}
|
||||
|
||||
value += (1d / ((IntegerValuation) valuation).getValue());
|
||||
}
|
||||
|
||||
aux = size / value;
|
||||
value = aux;
|
||||
|
||||
if(domain != null) {
|
||||
result = (IntegerValuation) valuations.get(0).clone();
|
||||
result.setValue(value);
|
||||
}
|
||||
|
||||
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) {
|
||||
int size = measures.size();
|
||||
|
||||
double measure = 0;
|
||||
for (int i = 0; i < size; i++)
|
||||
measure += weights.get(i) / measures.get(i);
|
||||
|
||||
measure = 1d / measure;
|
||||
result = (IntegerValuation) valuations.get(0).clone();
|
||||
result.setValue(measure);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
}
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
package flintstones.operator.aggregation.harmonicmean.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.harmonicmean.HarmonicMean;
|
||||
import flintstones.valuation.numeric.real.RealValuation;
|
||||
|
||||
public class HarmonicMeanReal extends HarmonicMean {
|
||||
|
||||
@Override
|
||||
public Valuation aggregate(List<Valuation> valuations) {
|
||||
RealValuation result = null;
|
||||
double value = 0, aux = 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("Invalid domain");
|
||||
}
|
||||
|
||||
value += (1d / ((RealValuation) valuation).getValue());
|
||||
}
|
||||
|
||||
aux = size / value;
|
||||
value = aux;
|
||||
|
||||
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;
|
||||
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) {
|
||||
int size = measures.size();
|
||||
|
||||
double measure = 0;
|
||||
for (int i = 0; i < size; i++)
|
||||
measure += weights.get(i) / measures.get(i);
|
||||
|
||||
measure = 1d / measure;
|
||||
result = (RealValuation) valuations.get(0).clone();
|
||||
result.setValue(measure);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
package flintstones.operator.aggregation.harmonicmean.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.harmonicmean.HarmonicMean;
|
||||
import flintstones.valuation.twoTuple.TwoTupleValuation;
|
||||
|
||||
public class HarmonicMeanTwoTuple extends HarmonicMean {
|
||||
|
||||
@Override
|
||||
public Valuation aggregate(List<Valuation> valuations) {
|
||||
TwoTupleValuation result = null;
|
||||
double beta = 0, aux =0;
|
||||
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("Invalid domain");
|
||||
}
|
||||
|
||||
beta += 1d / ((TwoTupleValuation) valuation).calculateInverseDelta();
|
||||
}
|
||||
|
||||
aux = valuations.size() / beta;
|
||||
beta = aux;
|
||||
|
||||
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;
|
||||
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) {
|
||||
int size = measures.size();
|
||||
|
||||
double beta = 0;
|
||||
for (int i = 0; i < size; i++)
|
||||
beta += weights.get(i) / measures.get(i);
|
||||
|
||||
beta = 1d / beta;
|
||||
result = (TwoTupleValuation) valuations.get(0).clone();
|
||||
result.calculateDelta(beta);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user