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.decision.common.phase.calculatedistances</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<name>[bundle] Calculatedistances</name>
</project>
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>flintstones.method.decision.common.phase.calculatedistances</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>1779484362655</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,15 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Calculatedistances
Bundle-SymbolicName: flintstones.method.decision.common.phase.calculatedistances;singleton:=true
Bundle-Version: 1.0.0.qualifier
Automatic-Module-Name: flintstones.method.decision.common.phase.calculatedistances
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Require-Bundle: flintstones.entity.problemelement,
flintstones.entity.wvaluation,
flintstones.entity.ahp.decisionmatrix,
flintstones.valuation.numeric,
flintstones.valuation,
flintstones.entity.valuation,
flintstones.entity.method.phase
Export-Package: flintstones.method.decision.common.phase.calculatedistances
@@ -0,0 +1,5 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
plugin.xml
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
point="flintstones.phasemethod.extensionpoint">
<phase
uid="flintstones.method.decision.common.phase.calculatedistances"
implementation="flintstones.method.decision.common.phase.calculatedistances.CalculateDistancesModel">
</phase>
</extension>
</plugin>
@@ -0,0 +1,138 @@
package flintstones.method.decision.common.phase.calculatedistances;
import flintstones.entity.problemelement.entities.Alternative;
/**
* The Class AlternativeCloseness. (Support Class)
*/
public class AlternativeCloseness implements Comparable<AlternativeCloseness>{
/** The alternative. */
private Alternative alternative;
/** The ideal distance. */
double idealDistance = 0.0;
/** The no ideal distance. */
double noIdealDistance = 0.0;
/** The closeness. */
double closeness = 0.0;
/** The cached ranking. */
int cachedRanking = -1;
/**
* Instantiates a new alternative closeness.
*
* @param a the a
* @param idealD the ideal D
* @param noIdealD the no ideal D
*/
public AlternativeCloseness(Alternative a, double idealD, double noIdealD) {
this.alternative = a;
this.idealDistance = idealD;
this.noIdealDistance = noIdealD;
this.closeness = noIdealD/(idealD + noIdealD);
}
/**
* Gets the alternative.
*
* @return the alternative
*/
public Alternative getAlternative() {
return alternative;
}
/**
* Sets the alternative.
*
* @param a the new alternative
*/
public void setAlternative(Alternative a) {
this.alternative = a;
}
/**
* Gets the ideal distance.
*
* @return the ideal distance
*/
public double getIdealDistance() {
return idealDistance;
}
/**
* Sets the ideal distance.
*
* @param idealDistance the new ideal distance
*/
public void setIdealDistance(double idealDistance) {
this.idealDistance = idealDistance;
}
/**
* Gets the no ideal distance.
*
* @return the no ideal distance
*/
public double getNoIdealDistance() {
return noIdealDistance;
}
/**
* Sets the no ideal distance.
*
* @param noIdealDistance the new no ideal distance
*/
public void setNoIdealDistance(double noIdealDistance) {
this.noIdealDistance = noIdealDistance;
}
/**
* Gets the closeness.
*
* @return the closeness
*/
public double getCloseness() {
return closeness;
}
/**
* Sets the closeness.
*
* @param closeness the new closeness
*/
public void setCloseness(double closeness) {
this.closeness = closeness;
}
/**
* Gets the cached ranking.
*
* @return the cached ranking
*/
public int getCachedRanking() {
return cachedRanking;
}
/**
* Sets the cached ranking.
*
* @param cachedRanking the new cached ranking
*/
public void setCachedRanking(int cachedRanking) {
this.cachedRanking = cachedRanking;
}
/* (non-Javadoc)
* @see java.lang.Comparable#compareTo(java.lang.Object)
*/
@Override
public int compareTo(AlternativeCloseness other) {
return this.getCloseness() > other.getCloseness() ? -1 : 1;
}
}
@@ -0,0 +1,95 @@
package flintstones.method.decision.common.phase.calculatedistances;
import java.util.ArrayList;
import java.util.HashMap;
import flintstones.entity.ahp.decisionmatrix.DecisionMatrix;
import flintstones.entity.method.phase.PhaseMethod;
import flintstones.entity.problemelement.entities.Alternative;
import flintstones.entity.problemelement.entities.Criterion;
import flintstones.entity.wvaluation.WValuation;
import flintstones.valuation.numeric.NumericValuation;
/**
* The Class CalculateDistancesModel.
*/
@SuppressWarnings("unchecked")
public class CalculateDistancesModel extends PhaseMethod {
/** The alternatives closeness. */
ArrayList<AlternativeCloseness> alternativesCloseness = new ArrayList<>();;
/* (non-Javadoc)
* @see flintstones.phasemethod.PhaseMethod#getName()
*/
@Override
public String getName() {
return "Calculate Distances";
}
/* (non-Javadoc)
* @see flintstones.phasemethod.PhaseMethod#getInfo()
*/
@Override
public String getInfo() {
return "Se calcula la distancia de cada elemento de la matriz de decisión respecto al valor ideal y no ideal de su columna (criterio)"
+ "Se agrega esta información por filas ( por alternativas ) para obtener la separación de cada alternativa."
+ " Finalmente se calcula el coeficiente de cercania.";
}
/**
* Gets the alternatives closeness.
*
* @return the alternatives closeness
*/
public ArrayList<AlternativeCloseness> getAlternativesCloseness() {
if(!alternativesCloseness.isEmpty())
return alternativesCloseness;
// Cache the best and worst of each column
ArrayList<WValuation> pis = (ArrayList<WValuation>) importData("positiveIdealSolutions");
HashMap<Criterion, WValuation> hashPis = new HashMap<>();
pis.stream().forEach( k -> hashPis.put( k.getPEK().getCriterion(), k));
ArrayList<WValuation> nis = (ArrayList<WValuation>) importData("negativeIdealSolutions");
HashMap<Criterion, WValuation> hashNis = new HashMap<>();
nis.stream().forEach( k -> hashNis.put( k.getPEK().getCriterion(), k));
DecisionMatrix dm = (DecisionMatrix) importData("weightedDecisionMatrix");
Alternative[] alternatives = dm.getAlternatives();
for(Alternative a : alternatives) {
double rowSumPositive = 0.0;
double rowSumNegative = 0.0;
ArrayList<WValuation> row = dm.getRow(a);
for(WValuation item : row) {
NumericValuation current = (NumericValuation) item.getValuation();
NumericValuation best = (NumericValuation) hashPis.get(item.getPEK().getCriterion()).getValuation();
NumericValuation worst = (NumericValuation) hashNis.get(item.getPEK().getCriterion()).getValuation();
double positiveSeparation = best.getValue() - current.getValue();
positiveSeparation = positiveSeparation*positiveSeparation;
rowSumPositive += positiveSeparation;
double negativeSeparation = worst.getValue() - current.getValue();
negativeSeparation = negativeSeparation*negativeSeparation;
rowSumNegative += negativeSeparation;
}
rowSumPositive = Math.sqrt(rowSumPositive);
rowSumNegative = Math.sqrt(rowSumNegative);
AlternativeCloseness ac = new AlternativeCloseness(a, rowSumPositive, rowSumNegative);
alternativesCloseness.add(ac);
}
return alternativesCloseness;
}
}