public code v1

This commit is contained in:
Francisco Jesús Martínez Mimbrera
2026-05-23 00:32:57 +02:00
commit 759a8968a2
4357 changed files with 163763 additions and 0 deletions
@@ -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.method.common.phase.unification</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<name>[bundle] Unification</name>
</project>
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>flintstones.method.common.phase.unification</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>1779484362654</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,24 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Unification
Bundle-SymbolicName: flintstones.method.common.phase.unification;singleton:=true
Bundle-Version: 1.0.0.qualifier
Automatic-Module-Name: flintstones.method.common.unification
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Require-Bundle: flintstones.entity.valuation,
flintstones.model.valuation.service,
flintstones.valuation.unifiedValuation,
flintstones.valuation.twoTuple,
flintstones.valuation.linguistic,
flintstones.entity.problemelement,
flintstones.domain.numeric,
flintstones.operator,
org.eclipse.e4.core.contexts,
javax.inject,
flintstones.model.domain.service,
flintstones.entity.domain,
org.eclipse.e4.core.di,
flintstones.entity.method.phase,
flintstones.model.method.phase.service,
flintstones.operator.unification
Export-Package: flintstones.method.common.phase.unification
@@ -0,0 +1,5 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
plugin.xml
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
point="flintstones.phasemethod.extensionpoint">
<phase
uid="flintstones.method.common.unification.unification"
implementation="flintstones.method.common.phase.unification.UnificationPhase">
</phase>
</extension>
</plugin>
@@ -0,0 +1,187 @@
/*
*
*/
package flintstones.method.common.phase.unification;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import javax.inject.Inject;
import org.eclipse.e4.core.contexts.IEclipseContext;
import flintstones.domain.fuzzyset.FuzzySet;
import flintstones.domain.numeric.NumericDomain;
import flintstones.entity.domain.Domain;
import flintstones.entity.method.phase.PhaseMethod;
import flintstones.entity.problemelement.ProblemElementKey;
import flintstones.entity.problemelement.entities.Criterion;
import flintstones.entity.valuation.Valuation;
import flintstones.model.domain.service.IDomainService;
import flintstones.model.method.phase.IPhaseMethodService;
import flintstones.model.valuation.service.IValuationService;
import flintstones.operator.unification.service.IUnificationOperatorService;
import flintstones.valuation.unifiedValuation.UnifiedValuation;
/**
* The Class UnificationPhase.
*/
public class UnificationPhase extends PhaseMethod {
/** The unification service. */
@Inject
IUnificationOperatorService unificationService;
/** The domain service. */
@Inject
IDomainService domainService;
/** The valuation service. */
@Inject
IValuationService valuationService;
/** The phase service. */
@Inject
IPhaseMethodService phaseService;
/** The context. */
@Inject
IEclipseContext context;
/** The two tuple unified valuations. */
private Map<ProblemElementKey, Valuation> twoTupleUnifiedValuations = new HashMap<>();
/** The unification domain. */
FuzzySet unificationDomain;
/**
* Instantiates a new unification phase.
*/
public UnificationPhase() {
}
/* (non-Javadoc)
* @see flintstones.phasemethod.PhaseMethod#getName()
*/
@Override
public String getName() {
return "Unification";
}
/* (non-Javadoc)
* @see flintstones.phasemethod.PhaseMethod#canBeExecuted()
*/
@Override
public boolean canBeExecuted() {
if (domainService.getAll().length == 1 && domainService.getAll()[0] instanceof NumericDomain )
return false;
return true;
}
public void initDomain() {
FuzzySet domain = (FuzzySet) this.importData("unifiedDomain");
if(domain == null)
domain = getBLTSDomainMaximumGranularity();
unificationDomain = domain;
}
private FuzzySet getBLTSDomainMaximumGranularity() {
int g = 0;
FuzzySet blts = null;
for(Domain d: domainService.getAll()) {
if(d instanceof FuzzySet) {
if(((FuzzySet) d).getLabelSet().getCardinality() > g) {
g = ((FuzzySet) d).getLabelSet().getCardinality();
blts = (FuzzySet) d;
}
}
}
return blts;
}
public FuzzySet getUnificationDomain() {
return unificationDomain;
}
public FuzzySet getImportedDomain() {
return (FuzzySet) this.importData("unifiedDomain");
}
/**
* Gets all the unified valuations.
*
* @return the unified valuations
*/
public Map<ProblemElementKey, Valuation> unify(boolean cost) {
twoTupleUnifiedValuations = new LinkedHashMap<>();
if (unificationDomain == null)
initDomain();
Map<ProblemElementKey, Valuation> valuations = valuationService.getAllKV();
for (ProblemElementKey vk : valuations.keySet()) {
Valuation v = unificateThis(vk, cost);
if (v != null)
twoTupleUnifiedValuations.put(vk, v);
else
System.err.println("UnifiedValuation is null");
}
exportTwoTupleUnifiedValuations();
return twoTupleUnifiedValuations;
}
/**
* Unificate this pek with this domain.
*
* @param pek the pek
* @param unificationDomain the unified domain X
* @param cost
* @return the unified valuation
*/
protected Valuation unificateThis(ProblemElementKey pek, boolean cost) {
Valuation valuation = valuationService.getValuationFor(pek);
if(cost) {
Criterion criterion = pek.getCriterion();
Boolean isCost = criterion.isCost();
if (isCost)
valuation = valuation.negateValuation();
}
if (valuation instanceof UnifiedValuation)
throw new Error("Not supported valuation."); //$NON-NLS-1$
String methodId = (String) this.importDataFromMethod("methodId");
String finalValuationId = (String) this.importDataFromMethod("finalValuationId");
return unificationService.unify(unificationDomain, valuation, finalValuationId, methodId);
}
/**
* Gets the two tuple unified valuations.
*
* @return the twoTupleUnifiedValuations
*/
public Map<ProblemElementKey, Valuation> getTwoTupleUnifiedValuations() {
return twoTupleUnifiedValuations;
}
/**
* Sets the two tuple unified valuations.
*
* @param twoTupleUnifiedValuations the twoTupleUnifiedValuations to set
*/
public void exportTwoTupleUnifiedValuations() {
exportData("unifiedDomain", twoTupleUnifiedValuations.values().iterator().next().getDomain(), true);
exportData("twoTupleUnifiedValuations", twoTupleUnifiedValuations, true);
}
}