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.unifiedValuation</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<packaging>eclipse-plugin</packaging>
|
||||
<name>[bundle] UnifiedValuation</name>
|
||||
<organization>
|
||||
<name>Sinbad2</name>
|
||||
</organization>
|
||||
</project>
|
||||
@@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>flintstones.valuation.unifiedValuation</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>1779484362755</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
|
||||
@@ -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,19 @@
|
||||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: UnifiedValuation
|
||||
Bundle-SymbolicName: flintstones.valuation.unifiedValuation
|
||||
Bundle-Version: 1.0.0.qualifier
|
||||
Bundle-Vendor: Sinbad2
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
|
||||
Require-Bundle: flintstones.entity.valuation,
|
||||
flintstones.model.valuation.service,
|
||||
flintstones.valuation.twoTuple,
|
||||
flintstones.valuation.linguistic,
|
||||
flintstones.helper.validator,
|
||||
org.eclipse.e4.core.contexts,
|
||||
javax.inject,
|
||||
flintstones.helper.data.wxml,
|
||||
flintstones.entity.domain,
|
||||
org.eclipse.e4.core.di
|
||||
Export-Package: flintstones.valuation.unifiedValuation
|
||||
Automatic-Module-Name: flintstones.valuation.unifiedValuation
|
||||
@@ -0,0 +1,4 @@
|
||||
source.. = src/
|
||||
output.. = bin/
|
||||
bin.includes = META-INF/,\
|
||||
.
|
||||
+142
@@ -0,0 +1,142 @@
|
||||
package flintstones.valuation.unifiedValuation;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import javax.xml.stream.XMLStreamWriter;
|
||||
|
||||
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.label.LabelLinguisticDomain;
|
||||
import flintstones.entity.domain.Domain;
|
||||
import flintstones.entity.valuation.Valuation;
|
||||
import flintstones.helper.data.wxml.WNode;
|
||||
import flintstones.helper.validator.Validator;
|
||||
import flintstones.valuation.twoTuple.TwoTupleValuation;
|
||||
import flintstones.valuation.unifiedValuation.messages.Messages;
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public class UnifiedValuation extends Valuation {
|
||||
|
||||
@Inject
|
||||
@Translation
|
||||
private Messages messages;
|
||||
|
||||
@Inject
|
||||
IEclipseContext context;
|
||||
|
||||
private Domain domain;
|
||||
|
||||
public Domain getDomain() {
|
||||
return domain;
|
||||
}
|
||||
|
||||
public void setDomain(Domain domain) {
|
||||
this.domain = domain;
|
||||
}
|
||||
|
||||
public UnifiedValuation() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Valuation other) {
|
||||
Validator.notNull(other);
|
||||
Validator.notIllegalElementType(other, new String[] { UnifiedValuation.class.toString() });
|
||||
|
||||
FuzzySet thisDomain = (FuzzySet) this.domain;
|
||||
FuzzySet otherDomain = (FuzzySet) other.getDomain();
|
||||
for (int i = 0; i < thisDomain.getLabelSet()
|
||||
.getCardinality(); i++)
|
||||
if (!thisDomain.getLabelSet()
|
||||
.getLabel(i)
|
||||
.equals(otherDomain.getLabelSet()
|
||||
.getLabel(i)))
|
||||
throw new IllegalArgumentException(this.messages.Differentdomains);
|
||||
|
||||
TwoTupleValuation thisDisunification = this.disunification(thisDomain);
|
||||
TwoTupleValuation otherDisunification = this.disunification(otherDomain);
|
||||
|
||||
return thisDisunification.compareTo(otherDisunification);
|
||||
}
|
||||
|
||||
public TwoTupleValuation disunification(FuzzySet fuzzySet) {
|
||||
Validator.notNull(fuzzySet);
|
||||
|
||||
TwoTupleValuation result = ContextInjectionFactory.make(TwoTupleValuation.class, context);
|
||||
result.build((FuzzySet) fuzzySet.clone());
|
||||
|
||||
int size = fuzzySet.getLabelSet().getCardinality();
|
||||
double numerator = 0, denominator = 0, measure, beta = 0;
|
||||
for (int i = 0; i < size; i++) {
|
||||
((FuzzySet) result.getDomain()).setValue(i, 0d);
|
||||
measure = fuzzySet.getValue(i);
|
||||
numerator += measure * i;
|
||||
denominator += measure;
|
||||
}
|
||||
|
||||
if (denominator != 0)
|
||||
beta = numerator / denominator;
|
||||
|
||||
result.calculateDelta(beta);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String changeFormatValuationToString() {
|
||||
FuzzySet domain2 = (FuzzySet) this.domain;
|
||||
StringBuilder result = new StringBuilder("{"); //$NON-NLS-1$
|
||||
List<LabelLinguisticDomain> labels = domain2.getLabelSet()
|
||||
.getLabels();
|
||||
String name, measure;
|
||||
|
||||
for (int i = 0; i < labels.size(); i++) {
|
||||
name = labels.get(i)
|
||||
.getName();
|
||||
measure = domain2.getValue(i)
|
||||
.toString();
|
||||
if (measure.length() > 4)
|
||||
measure = measure.substring(0, 4);
|
||||
result.append("(" + name + "," + measure + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
if ((i + 1) != labels.size())
|
||||
result.append(","); //$NON-NLS-1$
|
||||
}
|
||||
result.append("}"); //$NON-NLS-1$
|
||||
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.changeFormatValuationToString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Valuation negateValuation() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(XMLStreamWriter writer) throws XMLStreamException {
|
||||
// TODO Auto-generated method stub x
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(WNode node) {
|
||||
// TODO Auto-generated method stub x
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initFromString(String value) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// This file has been auto-generated
|
||||
package flintstones.valuation.unifiedValuation.messages;
|
||||
|
||||
import org.eclipse.e4.core.services.nls.Message;
|
||||
|
||||
@Message
|
||||
@SuppressWarnings("javadoc")
|
||||
public class Messages {
|
||||
|
||||
public String Differentdomains;
|
||||
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
Differentdomains=Different domains
|
||||
+1
@@ -0,0 +1 @@
|
||||
Differentdomains=Diferentes dominios
|
||||
Reference in New Issue
Block a user