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-11"/>
|
||||
<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.proportionaltwotuple</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<packaging>eclipse-plugin</packaging>
|
||||
<name>[bundle] Proportional 2-tuple</name>
|
||||
<organization>
|
||||
<name>Sinbad2</name>
|
||||
</organization>
|
||||
</project>
|
||||
@@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>flintstones.valuation.proportionaltwotuple</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>1779484362752</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
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
|
||||
org.eclipse.jdt.core.compiler.compliance=11
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
|
||||
org.eclipse.jdt.core.compiler.release=enabled
|
||||
org.eclipse.jdt.core.compiler.source=11
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
activeProfiles=
|
||||
eclipse.preferences.version=1
|
||||
resolveWorkspaceProjects=true
|
||||
version=1
|
||||
@@ -0,0 +1,15 @@
|
||||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: Proportional 2-tuple
|
||||
Bundle-SymbolicName: flintstones.valuation.proportionaltwotuple;singleton:=true
|
||||
Bundle-Version: 1.0.0.qualifier
|
||||
Bundle-Vendor: Sinbad2
|
||||
Automatic-Module-Name: flintstones.valuation.proportionaltwotuple
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-11
|
||||
Require-Bundle: flintstones.entity.valuation,
|
||||
javax.inject,
|
||||
org.eclipse.e4.core.contexts,
|
||||
flintstones.domain.fuzzyset,
|
||||
flintstones.valuation.twoTuple,
|
||||
flintstones.helper.data
|
||||
Export-Package: flintstones.valuation.proportionaltwotuple
|
||||
@@ -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"
|
||||
implementation="flintstones.valuation.proportionaltwotuple.ProportionalTwoTuple"
|
||||
is_intermediate="false"
|
||||
name="Proportional 2-tuple"
|
||||
uid="flintstones.valuation.proportionaltwotuple">
|
||||
</valuation>
|
||||
</extension>
|
||||
|
||||
</plugin>
|
||||
+226
@@ -0,0 +1,226 @@
|
||||
package flintstones.valuation.proportionaltwotuple;
|
||||
|
||||
import javax.xml.stream.XMLStreamWriter;
|
||||
|
||||
import flintstones.domain.fuzzyset.FuzzySet;
|
||||
import flintstones.domain.fuzzyset.label.LabelLinguisticDomain;
|
||||
import flintstones.entity.valuation.Valuation;
|
||||
import flintstones.helper.DoubleHelper;
|
||||
import flintstones.helper.data.wxml.WNode;
|
||||
import flintstones.helper.validator.Validator;
|
||||
import flintstones.valuation.twoTuple.TwoTupleValuation;
|
||||
|
||||
public class ProportionalTwoTuple extends Valuation {
|
||||
|
||||
public static final String ID = "flintstones.valuation.proportionaltwotuple"; //$NON-NLS-1$
|
||||
|
||||
private double alpha;
|
||||
private double beta;
|
||||
private LabelLinguisticDomain term1;
|
||||
private LabelLinguisticDomain term2;
|
||||
|
||||
public ProportionalTwoTuple() {
|
||||
super();
|
||||
}
|
||||
|
||||
public ProportionalTwoTuple(FuzzySet domain) {
|
||||
super();
|
||||
|
||||
Validator.notNull(domain);
|
||||
|
||||
this.domain = domain;
|
||||
this.term1 = null;
|
||||
this.term2 = null;
|
||||
this.alpha = 0.5;
|
||||
this.beta = 0.5;
|
||||
|
||||
this.setId(ProportionalTwoTuple.ID);
|
||||
}
|
||||
|
||||
public ProportionalTwoTuple(FuzzySet domain, LabelLinguisticDomain term1, LabelLinguisticDomain term2) {
|
||||
super();
|
||||
|
||||
Validator.notNull(domain);
|
||||
Validator.notNull(term1);
|
||||
Validator.notNull(term2);
|
||||
|
||||
this.domain = domain;
|
||||
|
||||
if (domain.getLabelSet().containsLabel(term1) && (domain.getLabelSet().containsLabel(term2))) {
|
||||
this.term1 = term1;
|
||||
this.term2 = term2;
|
||||
} else
|
||||
throw new IllegalArgumentException("Term does not belong to the linguistic domain");
|
||||
|
||||
this.alpha = 0.5;
|
||||
this.beta = 0.5;
|
||||
|
||||
this.setId(ProportionalTwoTuple.ID);
|
||||
}
|
||||
|
||||
public ProportionalTwoTuple(FuzzySet domain, LabelLinguisticDomain term1, LabelLinguisticDomain term2, double alpha,
|
||||
double beta) {
|
||||
super();
|
||||
|
||||
Validator.notNull(domain);
|
||||
Validator.notNull(term1);
|
||||
Validator.notNull(term2);
|
||||
|
||||
this.domain = domain;
|
||||
|
||||
if (domain.getLabelSet().getPos(term1) != domain.getLabelSet().getPos(term2) - 1)
|
||||
throw new IllegalArgumentException("Terms are not consecutive"); //$NON-NLS-1$
|
||||
|
||||
if (domain.getLabelSet().containsLabel(term1) && (domain.getLabelSet().containsLabel(term2))) {
|
||||
this.term1 = term1;
|
||||
this.term2 = term2;
|
||||
} else
|
||||
throw new IllegalArgumentException("Term does not belong to the linguistic domain");
|
||||
|
||||
if (alpha + beta != 1)
|
||||
throw new IllegalArgumentException("The sum of proportions is not equal to 1");
|
||||
|
||||
this.alpha = alpha;
|
||||
this.beta = beta;
|
||||
|
||||
this.setId(ProportionalTwoTuple.ID);
|
||||
}
|
||||
|
||||
public double getAlpha() {
|
||||
return alpha;
|
||||
}
|
||||
|
||||
public void setAlpha(double alpha) {
|
||||
this.alpha = alpha;
|
||||
}
|
||||
|
||||
public double getBeta() {
|
||||
return beta;
|
||||
}
|
||||
|
||||
public void setBeta(double beta) {
|
||||
this.beta = beta;
|
||||
}
|
||||
|
||||
public LabelLinguisticDomain getTerm1() {
|
||||
return term1;
|
||||
}
|
||||
|
||||
public void setTerm1(LabelLinguisticDomain term1) {
|
||||
if (((FuzzySet) this.domain).getLabelSet().containsLabel(term1)) {
|
||||
this.term1 = term1;
|
||||
} else
|
||||
throw new IllegalArgumentException(
|
||||
"[ProportionalTwoTuple::setTerm1] -> Term does not belong to the linguistic domain");
|
||||
}
|
||||
|
||||
public LabelLinguisticDomain getTerm2() {
|
||||
return term2;
|
||||
}
|
||||
|
||||
public void setTerm2(LabelLinguisticDomain term2) {
|
||||
if (((FuzzySet) this.domain).getLabelSet().containsLabel(term2)) {
|
||||
this.term2 = term2;
|
||||
} else
|
||||
throw new IllegalArgumentException(
|
||||
"[ProportionalTwoTuple::setTerm2] -> Term does not belong to the linguistic domain");
|
||||
}
|
||||
|
||||
public double calculatePi() {
|
||||
int i = ((FuzzySet) this.domain).getLabelSet().getPos(this.term1);
|
||||
return i + (1d - this.alpha);
|
||||
}
|
||||
|
||||
public void calculateInversePi(double x) {
|
||||
int i = (int) Math.round(x);
|
||||
|
||||
this.beta = x - i;
|
||||
this.alpha = 1 - this.beta;
|
||||
this.term1 = ((FuzzySet) this.domain).getLabelSet().getLabel(i);
|
||||
this.term2 = ((FuzzySet) this.domain).getLabelSet().getLabel(i + 1);
|
||||
}
|
||||
|
||||
public TwoTupleValuation calculateH() {
|
||||
if (this.alpha >= 0 && this.alpha <= 0.5d)
|
||||
return new TwoTupleValuation((FuzzySet) this.domain, term2, -this.alpha);
|
||||
else if (this.alpha >= 0.5d && this.alpha <= 1)
|
||||
return new TwoTupleValuation((FuzzySet) this.domain, term1, 1d - this.alpha);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Valuation o) {
|
||||
ProportionalTwoTuple other = (ProportionalTwoTuple) o;
|
||||
|
||||
int i = ((FuzzySet) this.domain).getLabelSet().getPos(this.term1);
|
||||
int j = ((FuzzySet) other.getDomain()).getLabelSet().getPos(other.getTerm1());
|
||||
|
||||
if (i < j) {
|
||||
if (i == j - 1 && this.alpha == 0 && other.getAlpha() == 0)
|
||||
return 0;
|
||||
else
|
||||
return -1;
|
||||
} else if (i == j) {
|
||||
if (this.alpha == other.getAlpha())
|
||||
return 0;
|
||||
else if (this.alpha < other.getAlpha())
|
||||
return -1;
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initFromString(String value) {
|
||||
throw new UnsupportedOperationException("Implementar, debería recibir la info y setearla");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Valuation negateValuation() {
|
||||
ProportionalTwoTuple negation = new ProportionalTwoTuple((FuzzySet) this.domain);
|
||||
|
||||
int g = ((FuzzySet) this.domain).getLabelSet().getCardinality() - 1;
|
||||
int i = ((FuzzySet) this.domain).getLabelSet().getPos(this.term1);
|
||||
|
||||
negation.setTerm1(((FuzzySet) this.domain).getLabelSet().getLabel(g - i - 1));
|
||||
negation.setTerm2(((FuzzySet) this.domain).getLabelSet().getLabel(g - i));
|
||||
negation.setAlpha(1d - this.getAlpha());
|
||||
negation.setBeta(this.getAlpha());
|
||||
|
||||
return negation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String changeFormatValuationToString() {
|
||||
return "(" + alpha + term1 + ", " + beta + term2 + ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(XMLStreamWriter writer) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(WNode node) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object clone() {
|
||||
ProportionalTwoTuple result = (ProportionalTwoTuple) super.clone();
|
||||
result.setDomain(domain);
|
||||
result.setTerm1(term1);
|
||||
result.setTerm2(term2);
|
||||
result.setAlpha(alpha);
|
||||
result.setBeta(beta);
|
||||
result.setId(this.getId());
|
||||
return result;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return DoubleHelper.Draw(alpha) + term1 + " " + DoubleHelper.Draw(beta) + term2;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user