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.quantifiers.yager</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<packaging>eclipse-plugin</packaging>
|
||||
<name>[bundle] Yager</name>
|
||||
</project>
|
||||
@@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>flintstones.quantifiers.yager</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>1779484362740</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,8 @@
|
||||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: Yager
|
||||
Bundle-SymbolicName: flintstones.quantifiers.yager
|
||||
Bundle-Version: 1.0.0.qualifier
|
||||
Automatic-Module-Name: flintstones.quantifiers.yager
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
|
||||
Export-Package: flintstones.quantifiers.yager
|
||||
@@ -0,0 +1,4 @@
|
||||
source.. = src/
|
||||
output.. = bin/
|
||||
bin.includes = META-INF/,\
|
||||
.
|
||||
+297
@@ -0,0 +1,297 @@
|
||||
package flintstones.quantifiers.yager;
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public class YagerQuantifiers {
|
||||
|
||||
public enum QuantificationType {
|
||||
most("most"), at_least_half("at least half"), as_many_as_possible("as_many_as_possible"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
|
||||
private QuantificationType(String text) {
|
||||
}
|
||||
}
|
||||
|
||||
public enum NumeredQuantificationType {
|
||||
FilevYager("Filev-Yager"); //$NON-NLS-1$
|
||||
|
||||
private final String _text;
|
||||
|
||||
private NumeredQuantificationType(String text) {
|
||||
this._text = text;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return this._text;
|
||||
}
|
||||
}
|
||||
|
||||
private static double RIM(double r, double alpha, double beta) {
|
||||
|
||||
if (r <= alpha)
|
||||
return 0;
|
||||
else if (r > beta)
|
||||
return 1;
|
||||
else
|
||||
return ((r - alpha) / (beta - alpha));
|
||||
}
|
||||
|
||||
public static double[] Q(int numberOfValuations, double alpha, double beta) {
|
||||
|
||||
double[] result = new double[numberOfValuations];
|
||||
|
||||
double value1 = -1;
|
||||
double value2 = -1;
|
||||
for (int i = 0; i < numberOfValuations; i++) {
|
||||
if (value1 == -1)
|
||||
value2 = (((double) i) / ((double) numberOfValuations));
|
||||
else
|
||||
value2 = value1;
|
||||
value1 = (((double) (i + 1)) / ((double) numberOfValuations));
|
||||
|
||||
result[i] = YagerQuantifiers.RIM(value1, alpha, beta) - YagerQuantifiers.RIM(value2, alpha, beta);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static double[] QWeighted(NumeredQuantificationType type, int g, int[] envelope, Boolean lower) {
|
||||
|
||||
double[] result = null;
|
||||
|
||||
if (type == NumeredQuantificationType.FilevYager) {
|
||||
int values;
|
||||
double alpha;
|
||||
if (lower == null) { // Between
|
||||
if (envelope[0] == envelope[1]) {
|
||||
result = new double[1];
|
||||
result[0] = 1;
|
||||
} else if ((envelope[0] + envelope[1]) % 2 == 0) {
|
||||
values = (envelope[1] - envelope[0] + 2) / 2;
|
||||
result = new double[values];
|
||||
alpha = envelope[0] / g;
|
||||
for (int i = 0; i < values; ++i)
|
||||
if (i == 0)
|
||||
result[i] = Math.pow(alpha, (envelope[1] - envelope[0] / 2d));
|
||||
else if (i == values - 1)
|
||||
result[i] = 1 - alpha;
|
||||
else
|
||||
result[i] = (1 - alpha) * Math.pow(alpha, (envelope[1] - envelope[0] - (i + 1)) / 2d);
|
||||
} else {
|
||||
values = (envelope[1] - envelope[0] + 1) / 2;
|
||||
result = new double[values];
|
||||
alpha = envelope[0] / g;
|
||||
for (int i = 0; i < values; ++i)
|
||||
if (i == 0)
|
||||
result[i] = Math.pow(alpha, (envelope[1] - envelope[0] - 1 / 2d));
|
||||
else if (i == values - 1)
|
||||
result[i] = 1 - alpha;
|
||||
else
|
||||
result[i] = (1 - alpha) * Math.pow(alpha, (envelope[1] - envelope[0] - (i + 2)) / 2d);
|
||||
}
|
||||
} else {
|
||||
int aux;
|
||||
|
||||
if (lower) {// At most and Lower than
|
||||
values = envelope[1] + 1;
|
||||
aux = values - 1;
|
||||
|
||||
result = new double[values];
|
||||
alpha = (((double) values) - 1) / g;
|
||||
|
||||
for (int i = 0; i <= aux; i++)
|
||||
if (i == aux)
|
||||
result[i] = Math.pow(1d - alpha, i);
|
||||
else
|
||||
result[i] = alpha * Math.pow(1d - alpha, i);
|
||||
|
||||
} else { // At least and Greater than
|
||||
values = (envelope[1] - envelope[0]) + 1;
|
||||
aux = values - 1;
|
||||
|
||||
result = new double[values];
|
||||
alpha = ((double) envelope[0]) / g;
|
||||
|
||||
for (int i = 0; i <= aux; i++)
|
||||
if (i == 0)
|
||||
result[i] = Math.pow(alpha, g - envelope[0]);
|
||||
else
|
||||
result[i] = (1d - alpha) * Math.pow(alpha, g - envelope[0] - i);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static double[] QWeigthedBinaryRelation(NumeredQuantificationType type, int g, int[] envelope, Boolean pointB, Double alpha) {
|
||||
double[] result = null;
|
||||
|
||||
if (type == NumeredQuantificationType.FilevYager) {
|
||||
if (envelope[0] == envelope[1]) {
|
||||
result = new double[1];
|
||||
result[0] = 1;
|
||||
} else {
|
||||
if(pointB) {
|
||||
return QWeightedBetweenPointB(g, envelope, alpha);
|
||||
} else {
|
||||
return QWeightedBetweenPointC(g, envelope, alpha);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static double[] QWeightedBetweenPointB(int g, int[] envelope, Double alpha) {
|
||||
double[] result = null;
|
||||
int values;
|
||||
|
||||
if (envelope[0] == envelope[1]) {
|
||||
result = new double[1];
|
||||
result[0] = 1;
|
||||
} else {
|
||||
if((envelope[0] + envelope[1]) % 2 == 0) {
|
||||
values = (envelope[1] - envelope[0] + 2) / 2;
|
||||
result = new double[values];
|
||||
alpha = (alpha == null) ? envelope[0] / g : alpha;
|
||||
for(int i = 0; i < values; ++i) {
|
||||
if(i == 0) {
|
||||
result[i] = Math.pow(alpha, (envelope[1] - envelope[0] / 2d));
|
||||
} else if(i == values - 1) {
|
||||
result[i] = 1 - alpha;
|
||||
} else {
|
||||
result[i] = (1 - alpha) * Math.pow(alpha, (envelope[1] - envelope[0] - (i + 1)) / 2d);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
values = (envelope[1] - envelope[0] + 1) / 2;
|
||||
result = new double[values];
|
||||
alpha = (alpha == null) ? envelope[0] / g : alpha;
|
||||
for(int i = 0; i < values; ++i) {
|
||||
if(i == 0) {
|
||||
result[i] = Math.pow(alpha, (envelope[1] - envelope[0] - 1 / 2d));
|
||||
} else if(i == values - 1) {
|
||||
result[i] = 1 - alpha;
|
||||
} else {
|
||||
result[i] = (1 - alpha) * Math.pow(alpha, (envelope[1] - envelope[0] - (i + 2)) / 2d);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static double[] QWeightedBetweenPointC(int g, int[] envelope, Double alpha) {
|
||||
double[] result = null;
|
||||
int values;
|
||||
double alpha2;
|
||||
|
||||
if (envelope[0] == envelope[1]) {
|
||||
result = new double[1];
|
||||
result[0] = 1;
|
||||
} else {
|
||||
if((envelope[0] + envelope[1]) % 2 == 0) {
|
||||
values = (envelope[1] - envelope[0] + 2) / 2;
|
||||
result = new double[values];
|
||||
alpha2 = (alpha == null) ? (g - envelope[0]) / g : alpha;
|
||||
|
||||
for(int i = 0; i < values; ++i) {
|
||||
if(i == 0) {
|
||||
result[i] = alpha2;
|
||||
} else if(i == values - 1) {
|
||||
result[i] = Math.pow(1 - alpha2, (envelope[1] - envelope[0]) / 2d);
|
||||
} else {
|
||||
result[i] = alpha2 * Math.pow(1d - alpha2, (envelope[1] - envelope[0] - (i + 1)) / 2d);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
values = (envelope[1] - envelope[0] + 1) / 2;
|
||||
result = new double[values];
|
||||
alpha2 = (alpha == null) ? (g - envelope[0]) / g : alpha;
|
||||
|
||||
for(int i = 0; i < values; ++i) {
|
||||
if(i == 0) {
|
||||
result[i] = alpha2;
|
||||
} else if(i == values - 1) {
|
||||
result[i] = Math.pow(1d - alpha2, (envelope[1] - envelope[0] - 1d) / 2d);
|
||||
} else {
|
||||
result[i] = (alpha2) * Math.pow(1d - alpha2, (envelope[1] - envelope[0] - (i + 2)) / 2d);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static double[] QWeigthedUnaryRelation(NumeredQuantificationType type, int g, int[] envelope, Boolean atMost, Double alpha) {
|
||||
|
||||
double[] result = null;
|
||||
|
||||
int aux, values;
|
||||
|
||||
if(atMost) {//At most and Lower than
|
||||
values = envelope[1] + 1;
|
||||
aux = values - 1;
|
||||
|
||||
result = new double[values];
|
||||
alpha = (alpha == null) ? (((double) values) - 1) / g : alpha;
|
||||
|
||||
for (int i = 0; i <= aux; i++) {
|
||||
if (i == aux) {
|
||||
result[i] = Math.pow(1d - alpha, i);
|
||||
} else {
|
||||
result[i] = alpha * Math.pow(1d - alpha, i);
|
||||
}
|
||||
}
|
||||
} else { //At least and Greater than
|
||||
values = (envelope[1] - envelope[0]) + 1;
|
||||
aux = values - 1;
|
||||
|
||||
result = new double[values];
|
||||
alpha = (alpha == null) ? ((double) envelope[0]) / g : alpha;
|
||||
|
||||
for (int i = 0; i <= aux; i++) {
|
||||
if (i == 0) {
|
||||
result[i] = Math.pow(alpha, g - envelope[0]);
|
||||
} else {
|
||||
result[i] = (1d - alpha) * Math.pow(alpha, g - envelope[0] - i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public static double[] Quantification(QuantificationType type, int numberOfValuations) {
|
||||
|
||||
switch (type) {
|
||||
case most:
|
||||
return YagerQuantifiers.Q(numberOfValuations, 0.3, 0.8);
|
||||
|
||||
case at_least_half:
|
||||
return YagerQuantifiers.Q(numberOfValuations, 0, 0.5);
|
||||
|
||||
case as_many_as_possible:
|
||||
return YagerQuantifiers.Q(numberOfValuations, 0.5, 1);
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static double[] getQuantificationParams(QuantificationType type) {
|
||||
switch (type) {
|
||||
case most:
|
||||
return new double[] { 0.3, 0.8 };
|
||||
|
||||
case at_least_half:
|
||||
return new double[] { 0, 0.5 };
|
||||
|
||||
case as_many_as_possible:
|
||||
return new double[] { 0.5, 1 };
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user