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,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.mcc</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.mcc</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>1779484362578</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
|
||||
+7
@@ -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
|
||||
+4
@@ -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.mcc;singleton:=true
|
||||
Bundle-Version: 1.0.0.qualifier
|
||||
Bundle-Vendor: Sinbad2
|
||||
Automatic-Module-Name: flintstones.entity.sensitiveanalysismodel.ui.wpm.mcc
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-11
|
||||
Require-Bundle: flintstones.entity.sensitiveanalysismodel.wpm.mcc,
|
||||
flintstones.entity.sensitiveanalysismodel.ui,
|
||||
flintstones.helper.html,
|
||||
flintstones.entity.sensitiveanalysismodel,
|
||||
org.eclipse.swt,
|
||||
flintstones.model.problemelement.service,
|
||||
javax.inject,
|
||||
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.mcc"
|
||||
implementation="flintstones.entity.sensitiveanalysismodel.ui.wpm.mcc.WeightedProductModelUI"
|
||||
sensitivemodel="flintstones.entity.sensitiveanalysismodel.mcc.wpm">
|
||||
</sensitivemodel_ui>
|
||||
<sensitivemodel_ui
|
||||
implementation="flintstones.entity.sensitiveanalysismodel.ui.wpm.mcc.WeightedProductModelUI"
|
||||
sensitivemodel="flintstones.entity.sensitiveanalysismodel.mcc.wpm.numeric"
|
||||
uid="flintstones.entity.sensitiveanalysismodel.ui.wpm.mcc.numeric">
|
||||
</sensitivemodel_ui>
|
||||
<sensitivemodel_ui
|
||||
implementation="flintstones.entity.sensitiveanalysismodel.ui.wpm.mcc.WeightedProductModelUI"
|
||||
sensitivemodel="flintstones.entity.sensitiveanalysismodel.mcc.wpm.fuzzy"
|
||||
uid="flintstones.entity.sensitiveanalysismodel.ui.wpm.mcc.fuzzy">
|
||||
</sensitivemodel_ui>
|
||||
</extension>
|
||||
|
||||
</plugin>
|
||||
+113
@@ -0,0 +1,113 @@
|
||||
package flintstones.entity.sensitiveanalysismodel.ui.wpm.mcc;
|
||||
|
||||
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.mcc.chart.WPMRankingEvolutionChart;
|
||||
import flintstones.entity.sensitiveanalysismodel.wpm.mcc.WeightedProductModelMCC;
|
||||
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(),
|
||||
((WeightedProductModelMCC) 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 = getShortenedPairAlternativesNames();
|
||||
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 = i + 1; j < model.getDecisionMatrix().length; ++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(),
|
||||
((WeightedProductModelMCC) 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;
|
||||
}
|
||||
}
|
||||
+76
@@ -0,0 +1,76 @@
|
||||
package flintstones.entity.sensitiveanalysismodel.ui.wpm.mcc.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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user