public code v1
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
<?flintstones.helper.data.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,17 @@
|
||||
<?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.valuation.twoTuple</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<packaging>eclipse-plugin</packaging>
|
||||
<name>[bundle] TwoTuple</name>
|
||||
<organization>
|
||||
<name>Sinbad2</name>
|
||||
</organization>
|
||||
</project>
|
||||
@@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>flintstones.valuation.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>
|
||||
<filteredResources>
|
||||
<filter>
|
||||
<id>1779484362753</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: TwoTuple
|
||||
Bundle-SymbolicName: flintstones.valuation.twoTuple;singleton:=true
|
||||
Bundle-Version: 1.0.0.qualifier
|
||||
Bundle-Vendor: Sinbad2
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
|
||||
Require-Bundle: flintstones.operator,
|
||||
flintstones.valuation;visibility:=reexport,
|
||||
flintstones.valuation.linguistic;visibility:=reexport,
|
||||
flintstones.domain.fuzzyset;visibility:=reexport,
|
||||
flintstones.helper.validator,
|
||||
org.eclipse.e4.core.contexts,
|
||||
javax.inject,
|
||||
org.eclipse.e4.core.di,
|
||||
flintstones.helper.data.wxml,
|
||||
flintstones.entity.domain,
|
||||
org.apache.commons.lang,
|
||||
flintstones.entity.valuation
|
||||
Automatic-Module-Name: flintstones.valuation.twoTuple
|
||||
Export-Package: flintstones.valuation.twoTuple
|
||||
Bundle-ActivationPolicy: lazy
|
||||
@@ -0,0 +1,5 @@
|
||||
source.. = src/
|
||||
output.. = bin/
|
||||
bin.includes = META-INF/,\
|
||||
.,\
|
||||
plugin.xml
|
||||
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?eclipse version="3.4"?>
|
||||
<plugin>
|
||||
<extension
|
||||
point="flintstones.valuation">
|
||||
<valuation
|
||||
domain="flintstones.domain.linguistic"
|
||||
uid="flintstones.valuation.twoTuple"
|
||||
implementation="flintstones.valuation.twoTuple.TwoTupleValuation"
|
||||
is_intermediate="true"
|
||||
name="TwoTuple">
|
||||
</valuation>
|
||||
</extension>
|
||||
|
||||
</plugin>
|
||||
+271
@@ -0,0 +1,271 @@
|
||||
package flintstones.valuation.twoTuple;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.commons.lang.builder.EqualsBuilder;
|
||||
import org.apache.commons.lang.builder.HashCodeBuilder;
|
||||
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
|
||||
import org.eclipse.e4.core.contexts.IEclipseContext;
|
||||
import org.eclipse.e4.core.services.nls.Translation;
|
||||
import flintstones.domain.fuzzyset.FuzzySet;
|
||||
import flintstones.domain.fuzzyset.function.types.TrapezoidalFunction;
|
||||
import flintstones.domain.fuzzyset.label.LabelLinguisticDomain;
|
||||
import flintstones.entity.valuation.Valuation;
|
||||
import flintstones.helper.validator.Validator;
|
||||
import flintstones.valuation.linguistic.LinguisticValuation;
|
||||
import flintstones.valuation.twoTuple.messages.Messages;
|
||||
|
||||
public class TwoTupleValuation extends LinguisticValuation {
|
||||
|
||||
@Inject
|
||||
IEclipseContext context;
|
||||
|
||||
@Inject
|
||||
@Translation
|
||||
private Messages messages;
|
||||
|
||||
public static final String ID = "flintstones.valuation.twoTuple"; //$NON-NLS-1$
|
||||
|
||||
private double _alpha;
|
||||
|
||||
|
||||
public TwoTupleValuation() {}
|
||||
|
||||
public TwoTupleValuation(FuzzySet domain){
|
||||
this.domain = domain;
|
||||
this._label = null;
|
||||
this._alpha = 0d;
|
||||
|
||||
this.setId(TwoTupleValuation.ID);
|
||||
}
|
||||
|
||||
public TwoTupleValuation(FuzzySet domain, LabelLinguisticDomain label) {
|
||||
this.domain = domain;
|
||||
this._label = label;
|
||||
this._alpha = 0d;
|
||||
|
||||
this.setId(TwoTupleValuation.ID);
|
||||
}
|
||||
|
||||
public TwoTupleValuation(FuzzySet domain, LabelLinguisticDomain label, double alpha) {
|
||||
this.domain = domain;
|
||||
this._label = label;
|
||||
this._alpha = alpha;
|
||||
|
||||
this.setId(TwoTupleValuation.ID);
|
||||
}
|
||||
|
||||
public void build(FuzzySet domain){
|
||||
this.build(domain, null, 0d);
|
||||
}
|
||||
|
||||
public void build(FuzzySet domain, LabelLinguisticDomain label) {
|
||||
this.build(domain, label, 0d);
|
||||
}
|
||||
|
||||
public void build(FuzzySet domain, LabelLinguisticDomain label, double alpha) {
|
||||
// 0 Params
|
||||
this.setId(TwoTupleValuation.ID);
|
||||
|
||||
// 1 Param
|
||||
if(domain != null) {
|
||||
this.setDomain(domain);
|
||||
this._alpha = 0d;
|
||||
}
|
||||
|
||||
// 2 Params
|
||||
if(label != null) {
|
||||
this.setLabel(label);
|
||||
}
|
||||
|
||||
this.setAlpha(alpha);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLabel(String name) {
|
||||
super.setLabel(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLabel(LabelLinguisticDomain label) {
|
||||
super.setLabel(label);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLabel(int pos) {
|
||||
super.setLabel(pos);
|
||||
}
|
||||
|
||||
public void setAlpha(double alpha) {
|
||||
Validator.notInvalidSize(alpha, -0.5, 0.5, "alpha"); //$NON-NLS-1$
|
||||
|
||||
int pos = ((FuzzySet) this.domain).getLabelSet()
|
||||
.getPos(this._label);
|
||||
|
||||
if ((pos == 0) && (alpha < 0))
|
||||
throw new IllegalArgumentException(this.messages.TwoTuple_Invalid_alpha_value);
|
||||
|
||||
if ((pos == ((FuzzySet) this.domain).getLabelSet()
|
||||
.getCardinality() - 1) && (alpha > 0))
|
||||
throw new IllegalArgumentException(this.messages.TwoTuple_Invalid_alpha_value);
|
||||
|
||||
this._alpha = alpha;
|
||||
}
|
||||
|
||||
public double getAlpha() {
|
||||
return this._alpha;
|
||||
}
|
||||
|
||||
public void calculateDelta(double beta) {
|
||||
int labelIndex = (int) Math.round(beta);
|
||||
this.setLabel(labelIndex);
|
||||
|
||||
double alpha = Math.round((beta - labelIndex) * 10000d) / 10000d;
|
||||
|
||||
if (alpha == 0.5) {
|
||||
labelIndex++;
|
||||
this.setLabel(labelIndex);
|
||||
alpha = -0.5;
|
||||
}
|
||||
|
||||
this.setAlpha(alpha);
|
||||
}
|
||||
|
||||
public double calculateInverseDelta() {
|
||||
return this._alpha + ((FuzzySet) this.domain).getLabelSet()
|
||||
.getPos(this._label);
|
||||
}
|
||||
|
||||
public double calculateReverseDelta() {
|
||||
return (((FuzzySet) this.domain).getLabelSet()
|
||||
.getPos(this._label) / ((FuzzySet) this.domain).getLabelSet().getCardinality() - 1) + this._alpha;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Valuation negateValuation() {
|
||||
TwoTupleValuation result = (TwoTupleValuation) this.clone();
|
||||
|
||||
FuzzySet fdomain = (FuzzySet) this.domain;
|
||||
if (fdomain.getLabelSet().getCardinality() > 1)
|
||||
result.calculateDelta((fdomain.getLabelSet().getCardinality() - 1) - this.calculateInverseDelta());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public TwoTupleValuation transform(FuzzySet fuzzySet) {
|
||||
|
||||
TwoTupleValuation result = null;
|
||||
|
||||
Validator.notNull(fuzzySet);
|
||||
|
||||
if (!fuzzySet.isBLTS())
|
||||
throw new IllegalArgumentException(this.messages.TwoTuple_Not_BLTS_fuzzy_set);
|
||||
|
||||
int thisCardinality = ((FuzzySet) this.domain).getLabelSet().getCardinality();
|
||||
int otherCardinality = fuzzySet.getLabelSet().getCardinality();
|
||||
|
||||
double numerator = this.calculateInverseDelta() * (otherCardinality - 1);
|
||||
double denominator = thisCardinality - 1;
|
||||
|
||||
double beta = numerator / denominator;
|
||||
|
||||
result = ContextInjectionFactory.make(TwoTupleValuation.class, context);
|
||||
result.build(fuzzySet);
|
||||
result.calculateDelta(beta);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public TrapezoidalFunction getFuzzyNumber() {
|
||||
double distance = _alpha / (((FuzzySet) 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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ("[" + this._label + ", " + Math.round(this._alpha * 10000d) / 10000d + "]" + this.messages.TwoTuple_In + this.domain); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
}
|
||||
|
||||
@Override
|
||||
public String changeFormatValuationToString() {
|
||||
return "[" + this._label.getName() + ", " + Math.round(this._alpha * 10000d) / 10000d + "]";
|
||||
}
|
||||
|
||||
public String prettyFormat() {
|
||||
return ("(" + this._label + ", " + Math.round(this._alpha * 100d) / 100d + ")"); //$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 (this.getClass() != obj.getClass())
|
||||
return false;
|
||||
|
||||
TwoTupleValuation other = (TwoTupleValuation) obj;
|
||||
return new EqualsBuilder().append(this._label, other._label)
|
||||
.append(this.domain, other.domain)
|
||||
.append(this._alpha, other._alpha)
|
||||
.isEquals();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return new HashCodeBuilder(17, 31).append(this._label)
|
||||
.append(this.domain)
|
||||
.append(this._alpha)
|
||||
.toHashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Valuation other) {
|
||||
Validator.notNull(other);
|
||||
Validator.notIllegalElementType(other, new String[] { TwoTupleValuation.class.toString() });
|
||||
|
||||
if (this.domain.equals(other.getDomain())) {
|
||||
LabelLinguisticDomain otherLabel = ((TwoTupleValuation) other)._label;
|
||||
double otherAlpha = ((TwoTupleValuation) other)._alpha;
|
||||
|
||||
int aux;
|
||||
if ((aux = this._label.compareTo(otherLabel)) == 0)
|
||||
return Double.compare(this._alpha, otherAlpha);
|
||||
return aux;
|
||||
}
|
||||
throw new IllegalArgumentException(this.messages.TwoTuple_Differentdomains);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object clone() {
|
||||
TwoTupleValuation result = (TwoTupleValuation) super.clone();
|
||||
|
||||
result = ContextInjectionFactory.make(TwoTupleValuation.class, context);
|
||||
result.setId(this.getId());
|
||||
result.domain = domain;
|
||||
result._alpha = _alpha;
|
||||
result._label = _label;
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// This file has been auto-generated
|
||||
package flintstones.valuation.twoTuple.messages;
|
||||
|
||||
import org.eclipse.e4.core.services.nls.Message;
|
||||
|
||||
@Message
|
||||
@SuppressWarnings("javadoc")
|
||||
public class Messages {
|
||||
|
||||
public String TwoTuple_Invalid_alpha_value;
|
||||
public String TwoTuple_Not_BLTS_fuzzy_set;
|
||||
public String TwoTuple_In;
|
||||
public String TwoTuple_Differentdomains;
|
||||
|
||||
}
|
||||
+4
@@ -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.
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
TwoTuple_Different_domains=Diferentes dominios
|
||||
TwoTuple_In=\ en
|
||||
TwoTuple_Invalid_alpha_value=Valor alpha no valido
|
||||
TwoTuple_Not_BLTS_fuzzy_set=No BLTS fuzzy establecido.
|
||||
Reference in New Issue
Block a user