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,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.entity.sensitiveanalysismodel.ui.wpm.mcm</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<name>[bundle] WPM sensitive analysis model ui</name>
<organization>
<name>Sinbad2</name>
</organization>
</project>
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>flintstones.entity.sensitiveanalysismodel.ui.wpm.mcm</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>1779484362579</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,16 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: WPM sensitive analysis model ui
Bundle-SymbolicName: flintstones.entity.sensitiveanalysismodel.ui.wpm.mcm;singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-Vendor: Sinbad2
Automatic-Module-Name: flintstones.entity.sensitiveanalysismodel.ui.wpm.mcm
Bundle-RequiredExecutionEnvironment: JavaSE-11
Require-Bundle: flintstones.entity.sensitiveanalysismodel.wpm.mcm,
flintstones.entity.sensitiveanalysismodel.ui,
javax.inject,
flintstones.model.problemelement.service,
flintstones.helper.html,
org.eclipse.swt,
flintstones.entity.sensitiveanalysismodel,
org.jfree.chart.jfreechart
@@ -0,0 +1,5 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
plugin.xml
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
point="flintstones.entity.sensitiveanalysismodel.ui.extension">
<sensitivemodel_ui
uid="flintstones.entity.sensitiveanalysismodel.ui.wpm.mcm"
implementation="flintstones.entity.sensitiveanalysismodel.ui.wpm.mcm.WeightedProductModelUI"
sensitivemodel="flintstones.entity.sensitiveanalysismodel.mcm.wpm">
</sensitivemodel_ui>
<sensitivemodel_ui
implementation="flintstones.entity.sensitiveanalysismodel.ui.wpm.mcm.WeightedProductModelUI"
sensitivemodel="flintstones.entity.sensitiveanalysismodel.mcm.wpm.numeric"
uid="flintstones.entity.sensitiveanalysismodel.ui.wpm.mcm.numeric">
</sensitivemodel_ui>
<sensitivemodel_ui
implementation="flintstones.entity.sensitiveanalysismodel.ui.wpm.mcm.WeightedProductModelUI"
sensitivemodel="flintstones.entity.sensitiveanalysismodel.mcm.wpm.fuzzy"
uid="flintstones.entity.sensitiveanalysismodel.ui.wpm.mcm.fuzzy">
</sensitivemodel_ui>
</extension>
</plugin>
@@ -0,0 +1,115 @@
package flintstones.entity.sensitiveanalysismodel.ui.wpm.mcm;
import org.eclipse.swt.widgets.Composite;
import flintstones.entity.problemelement.entities.Criterion;
import flintstones.entity.problemelement.entities.ProblemElement;
import flintstones.entity.sensitiveanalysismodel.SensitiveAnalysisModel.FieldsChanges;
import flintstones.entity.sensitiveanalysismodel.ui.SensitiveAnalysisModelUi;
import flintstones.entity.sensitiveanalysismodel.ui.chart.RankingEvolutionChart;
import flintstones.entity.sensitiveanalysismodel.ui.wpm.mcm.chart.WPMRankingEvolutionChart;
import flintstones.entity.sensitiveanalysismodel.wpm.mcm.WeightedProductModelMCMTwoTuple;
import flintstones.helper.html.table.HtmlTextTable;
public class WeightedProductModelUI extends SensitiveAnalysisModelUi {
public WeightedProductModelUI() {}
@Override
public HtmlTextTable createRankingTable(Composite rankingSection) {
String[] rowHeader = getShortenedPairAlternativesNames();
String[] colHeader = new String[] {"Ratio", "Ranking"};//$NON-NLS-1$ $NON-NLS-2$
rankingTable = new HtmlTextTable(rankingSection, loadRanking(model.getRanking(),
((WeightedProductModelMCMTwoTuple) model).getAlternativesRatioFinalPreferences(),
rowHeader.length, colHeader.length), colHeader, rowHeader);
return rankingTable;
}
private String[][] loadRanking(int[] ranking, Double[][] preferences, int numRows, int numCols) {
String[][] valuesSTR = initialize(numRows, numCols);
//Preferences
int cont = 0;
double preference;
for(int i = 0; i < model.getDecisionMatrix().length - 1; ++i) {
for(int j = i + 1; j < model.getDecisionMatrix().length; ++j) {
preference = Math.round(preferences[i][j] * 100000d) / 100000d;
valuesSTR[cont][0] = "" + preference;
cont++;
}
}
//Ranking
for(int i = 0; i < model.getDecisionMatrix().length; ++i)
valuesSTR[i][1] = "A" + (i + 1) + "->" + ranking[i];
return valuesSTR;
}
private String[][] initialize(int numRows, int numCols) {
String[][] valueSTR = new String[numRows][numCols];
for(int i = 0; i < valueSTR.length; ++i) {
for(int j = 0; j < valueSTR[i].length; ++j) {
valueSTR[i][j] = "";
}
}
return valueSTR;
}
@Override
public HtmlTextTable createChangesTable(Composite changesSection, FieldsChanges typeChange) {
String[] rowHeader = getShortenedAllPairAlternativesNames();
String[] colHeader = getShortenedCriteriaNames();
changesTable = new HtmlTextTable(changesSection, loadChanges(model.getChanges(typeChange), rowHeader.length, colHeader.length),
colHeader, rowHeader);
return changesTable;
}
@SuppressWarnings("static-access")
private String[][] loadChanges(Double[][][] changes, int numRows, int numCols) {
String[][] valuesSTR = new String[numRows][numCols];
Double change;
int cont = 0;
for(int i = 0; i < model.getDecisionMatrix().length - 1; ++i) {
for(int j = 0; j < model.getDecisionMatrix().length; ++j) {
if(i != j) {
for(int k = 0; k < valuesSTR[i].length; k++) {
change = changes[i][j][k];
if(change == model.NON_FEASIBLE)
valuesSTR[cont][k] = "N/F";
else
valuesSTR[cont][k] = "" + Math.round(change * 10000d) / 10000d;
}
cont++;
}
}
}
return valuesSTR;
}
@Override
public void refreshChangesTable(FieldsChanges typeChange) {
changesTable.refresh(loadChanges(model.getChanges(typeChange), changesTable.getNumberOfRows(),
changesTable.getNumberOfColumns()));
changesTable.render();
}
@Override
public void refreshRankingTable() {
rankingTable.refresh(loadRanking(model.getRanking(),
((WeightedProductModelMCMTwoTuple) model).getAlternativesRatioFinalPreferences(),
rankingTable.getNumberOfRows(), rankingTable.getNumberOfColumns()));
rankingTable.render();
}
@Override
public RankingEvolutionChart createRankingEvolutionChart(Composite container, ProblemElement[] criteria, Criterion criterion, int width, int height, int style) {
chart = new WPMRankingEvolutionChart();
chart.initialize(model, criteria, criterion, container, width, height, style);
return chart;
}
}
@@ -0,0 +1,75 @@
package flintstones.entity.sensitiveanalysismodel.ui.wpm.mcm.chart;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import org.jfree.data.xy.XYDataset;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;
import flintstones.entity.problemelement.entities.ProblemElement;
import flintstones.entity.sensitiveanalysismodel.ui.chart.RankingEvolutionChart;
public class WPMRankingEvolutionChart extends RankingEvolutionChart {
@Override
public XYDataset createDataset() {
dataset = new XYSeriesCollection();
List<XYSeries> alternativesSeries = computeEvolutionChart();
for (XYSeries xySerie : alternativesSeries) {
dataset.addSeries(xySerie);
}
return dataset;
}
private List<XYSeries> computeEvolutionChart() {
List<XYSeries> alternativeSeries = new LinkedList<>();
Double preference;
for (int i = 0; i < model.getDecisionMatrix().length - 1; ++i) {
for (int j = (i + 1); j < model.getDecisionMatrix().length; ++j) {
XYSeries serie = new XYSeries("A" + (i + 1) + " - " + "A" + (j + 1)); //$NON-NLS-1$
for (double k = 0.01; k <= 1.01; k += 0.01) {
preference = computeAlternativeRatioFinalPreferenceInferWeights(i, j, computeInferredWeights(j));
serie.add(Math.round(k * 100d) / 100d, preference);
}
alternativeSeries.add(serie);
}
}
return alternativeSeries;
}
private Double computeAlternativeRatioFinalPreferenceInferWeights(int a1, int a2, Double[] w) {
Double[][] decisionMatrix = model.getDecisionMatrix();
double alternativeRatioFinalPreference = 1;
for (int criterion = 0; criterion < this.criteria.length; criterion++) {
alternativeRatioFinalPreference *= Math.pow(((Double) decisionMatrix[a1][criterion] / (Double) decisionMatrix[a2][criterion]),
w[criterion]);
}
return alternativeRatioFinalPreference;
}
private Double[] computeInferredWeights(double evolutionWeight) {
Map<ProblemElement, Double> criteriaWeights = model.getCriteriaWeights();
Double[] inferWeights = new Double[criteriaWeights.size()];
List<ProblemElement> criteria = Arrays.asList(this.criteria);
int indexSelectedCriterion = criteria.indexOf(criterion);
inferWeights[indexSelectedCriterion] = evolutionWeight;
for (ProblemElement cr: criteria) {
if (!cr.equals(criterion))
inferWeights[criteria.indexOf(cr)] = ((1d - evolutionWeight) /
(1d - criteriaWeights.get(criterion))) * criteriaWeights.get(cr);
}
return inferWeights;
}
}