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
+7
View File
@@ -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>
+1
View File
@@ -0,0 +1 @@
/bin/
+34
View File
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>afryca.twotuple</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,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,9 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-SymbolicName: afryca.twotuple
Bundle-Version: 1.0.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Require-Bundle: afryca.domain.fuzzyset;bundle-version="1.0.0"
Export-Package: afryca.twotuple
Automatic-Module-Name: afryca.twotuple
@@ -0,0 +1,2 @@
#Properties file for afryca.twotuple
Bundle-Name = 2-tuple
+6
View File
@@ -0,0 +1,6 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
OSGI-INF/l10n/bundle.properties,\
OSGI-INF/
@@ -0,0 +1,221 @@
package afryca.twotuple;
import afryca.domain.fuzzyset.FuzzySet;
import afryca.domain.fuzzyset.function.types.TrapezoidalFunction;
import afryca.domain.fuzzyset.labelset.Label;
import afryca.twotuple.i18n.Messages;
import afryca.valueforcer.ValueForcer;
public class TwoTuple {
private Label label;
private float alpha;
private FuzzySet domain;
public TwoTuple(FuzzySet domain) {
setDomain(domain);
alpha = 0;
}
public TwoTuple(FuzzySet domain, Label label) {
setDomain(domain);
setLabel(label);
}
public TwoTuple(FuzzySet domain, Label label, float alpha) {
setDomain(domain);
setLabel(label);
setAlpha(alpha);
}
public void setDomain(FuzzySet domain) {
ValueForcer.notNull(domain);
this.domain = domain;
}
public void setLabel(String name) {
Label label = domain.getLabelSet().getLabel(name);
ValueForcer.notNull(label);
this.label = label;
}
public void setLabel(Label label) {
ValueForcer.notNull(label);
this.label = label;
}
public void setLabel(int pos) {
Label label = domain.getLabelSet().getLabel(pos);
ValueForcer.notNull(label);
this.label = label;
}
public void setAlpha(float alpha) {
ValueForcer.inRange(alpha, -0.5, 0.5); //$NON-NLS-1$
int pos = domain.getLabelSet().getPos(label);
if((pos == 0) && (alpha < 0)) {
throw new IllegalArgumentException(Messages.TwoTuple_Invalid_alpha_value);
}
if((pos == domain.getLabelSet().getCardinality() - 1) && (alpha > 0)) {
throw new IllegalArgumentException(Messages.TwoTuple_Invalid_alpha_value);
}
this.alpha = alpha;
}
public Label getLabel() {
return label;
}
public FuzzySet getDomain() {
return domain;
}
public float getAlpha() {
return alpha;
}
public void calculateDelta(float beta) {
int labelIndex = (int) Math.round(beta);
setLabel(labelIndex);
float alpha = beta - labelIndex;
if(alpha == 0.5) {
labelIndex++;
setLabel(labelIndex);
alpha = -0.5f;
}
setAlpha(alpha);
}
public float calculateInverseDelta() {
return alpha + domain.getLabelSet().getPos(label);
}
public TwoTuple negateValuation() {
TwoTuple result = (TwoTuple) clone();
if(domain.getLabelSet().getCardinality() > 1) {
result.calculateDelta((domain.getLabelSet().getCardinality() - 1) - calculateInverseDelta());
}
return result;
}
public TrapezoidalFunction getFuzzyNumber() {
double distance = alpha / (domain.getLabelSet().getCardinality() - 1);
double a;
if(((TrapezoidalFunction) label.getSemantic()).getA() + distance < 0)
a = ((TrapezoidalFunction) label.getSemantic()).getA();
else
a = ((TrapezoidalFunction) label.getSemantic()).getA() + distance;
double d;
if(((TrapezoidalFunction) label.getSemantic()).getA() + distance > 1)
d = ((TrapezoidalFunction) label.getSemantic()).getD();
else
d = ((TrapezoidalFunction) label.getSemantic()).getD() + distance;
TrapezoidalFunction fuzzyNumber = new TrapezoidalFunction();
fuzzyNumber.setLimits(new double[] {a, ((TrapezoidalFunction) label.getSemantic()).getB() + distance,
((TrapezoidalFunction) label.getSemantic()).getC() + distance, d});
return fuzzyNumber;
}
public TwoTuple transform(FuzzySet fuzzySet) {
TwoTuple result = null;
ValueForcer.notNull(fuzzySet);
if (!fuzzySet.isBLTS()) {
throw new IllegalArgumentException(Messages.TwoTuple_Not_BLTS_fuzzy_set);
}
int thisCardinality = domain.getLabelSet().getCardinality();
int otherCardinality = fuzzySet.getLabelSet().getCardinality();
float numerator = calculateInverseDelta() * ((float) (otherCardinality - 1));
float denominator = (float) (thisCardinality - 1);
float beta = numerator / denominator;
result = new TwoTuple(fuzzySet);
result.calculateDelta(beta);
return result;
}
public double similarityMeasure(TwoTuple twoTuple) {
return 1d - distance(twoTuple);
}
public double distance(TwoTuple twoTuple) {
return Math.abs(this.calculateInverseDelta() - twoTuple.calculateInverseDelta()) / (domain.getLabelSet().getCardinality() - 1);
}
@Override
public String toString() {
return ("[" + label + ", " + Math.round(alpha * 10000d) / 10000d + "]" + Messages.TwoTuple_in + domain); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
public String prettyFormat() {
return ("(" + label + ", " + Math.round(alpha * 10000d) / 10000d + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
TwoTuple other = (TwoTuple) obj;
if (domain != other.domain)
return false;
if (label != other.label)
return false;
if (alpha != other.alpha)
return false;
return true;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + domain.hashCode();
result = prime * result + label.hashCode();
result = prime * result + Double.hashCode(alpha);
return result;
}
public int compareTo(TwoTuple other) {
ValueForcer.notNull(other);
ValueForcer.notIllegalElementType(other, new String[] { TwoTuple.class.toString()});
if(domain.equals(other.getDomain())) {
Label otherLabel = other.label;
double otherAlpha = other.alpha;
int aux;
if((aux = label.compareTo(otherLabel)) == 0) {
return Double.compare(alpha, otherAlpha);
} else {
return aux;
}
} else {
return 1;
}
}
@Override
public Object clone() {
return new TwoTuple(this.domain, this.label, this.alpha);
}
}
@@ -0,0 +1,20 @@
package afryca.twotuple.i18n;
import org.eclipse.osgi.util.NLS;
public class Messages extends NLS {
private static final String BUNDLE_NAME = "afryca.twotuple.i18n.messages"; //$NON-NLS-1$
public static String TwoTuple_Different_domains;
public static String TwoTuple_in;
public static String TwoTuple_Invalid_alpha_value;
public static String TwoTuple_Not_BLTS_fuzzy_set;
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
}
private Messages() {
}
}
@@ -0,0 +1,4 @@
TwoTuple_Different_domains=Different domains
TwoTuple_in=in
TwoTuple_Invalid_alpha_value=Invalid alpha value
TwoTuple_Not_BLTS_fuzzy_set=Not BLTS fuzzy set
@@ -0,0 +1,10 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-SymbolicName: afryca.twotuple
Bundle-Version: 1.0.0.202101221157
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Require-Bundle: afryca.domain.fuzzyset;bundle-version="1.0.0"
Export-Package: afryca.twotuple
Automatic-Module-Name: afryca.twotuple
@@ -0,0 +1,4 @@
TwoTuple_Different_domains=Different domains
TwoTuple_in=in
TwoTuple_Invalid_alpha_value=Invalid alpha value
TwoTuple_Not_BLTS_fuzzy_set=Not BLTS fuzzy set
@@ -0,0 +1,4 @@
#Fri Jan 22 13:00:28 CET 2021
artifact.main=C\:\\Users\\\u00C1lvaro\\Workspaces\\afryca_2020\\afryca\\plugins\\afryca.twotuple\\target\\afryca.twotuple-1.0.0-SNAPSHOT.jar
artifact.attached.p2artifacts=C\:\\Users\\\u00C1lvaro\\Workspaces\\afryca_2020\\afryca\\plugins\\afryca.twotuple\\target\\p2artifacts.xml
artifact.attached.p2metadata=C\:\\Users\\\u00C1lvaro\\Workspaces\\afryca_2020\\afryca\\plugins\\afryca.twotuple\\target\\p2content.xml
@@ -0,0 +1,3 @@
artifactId=afryca.twotuple
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.twotuple' version='1.0.0.202101221157'>
<properties size='5'>
<property name='artifact.size' value='6347'/>
<property name='download.size' value='6347'/>
<property name='maven-groupId' value='afryca.group'/>
<property name='maven-artifactId' value='afryca.twotuple'/>
<property name='maven-version' value='1.0.0-SNAPSHOT'/>
</properties>
</artifact>
</artifacts>
@@ -0,0 +1,44 @@
<?xml version='1.0' encoding='UTF-8'?>
<units size='1'>
<unit id='afryca.twotuple' version='1.0.0.202101221157' singleton='false' generation='2'>
<update id='afryca.twotuple' range='[0.0.0,1.0.0.202101221157)' severity='0'/>
<properties size='5'>
<property name='df_LT.Bundle-Name' value='2-tuple'/>
<property name='org.eclipse.equinox.p2.name' value='%Bundle-Name'/>
<property name='maven-groupId' value='afryca.group'/>
<property name='maven-artifactId' value='afryca.twotuple'/>
<property name='maven-version' value='1.0.0-SNAPSHOT'/>
</properties>
<provides size='6'>
<provided namespace='org.eclipse.equinox.p2.iu' name='afryca.twotuple' version='1.0.0.202101221157'/>
<provided namespace='osgi.bundle' name='afryca.twotuple' version='1.0.0.202101221157'/>
<provided namespace='java.package' name='afryca.twotuple' version='0.0.0'/>
<provided namespace='osgi.identity' name='afryca.twotuple' 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='df_LT' version='1.0.0'/>
</provides>
<requires size='2'>
<required namespace='osgi.bundle' name='afryca.domain.fuzzyset' range='1.0.0'/>
<requiredProperties namespace='osgi.ee' match='(&amp;(osgi.ee=JavaSE)(version=1.8))'>
<description>
afryca.twotuple
</description>
</requiredProperties>
</requires>
<artifacts size='1'>
<artifact classifier='osgi.bundle' id='afryca.twotuple' 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.twotuple&#xA;Bundle-Version: 1.0.0.202101221157&#xA;
</instruction>
</instructions>
</touchpointData>
</unit>
</units>