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>
|
||||
+14
@@ -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.calculatesolutions</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<packaging>eclipse-plugin</packaging>
|
||||
<name>[bundle] Calculatesolutions</name>
|
||||
</project>
|
||||
@@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>flintstones.method.decision.common.phase.calculatesolutions</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>1779484362656</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
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: Calculatesolutions
|
||||
Bundle-SymbolicName: flintstones.method.decision.common.phase.calculatesolutions;singleton:=true
|
||||
Bundle-Version: 1.0.0.qualifier
|
||||
Automatic-Module-Name: flintstones.method.decision.common.phase.calculatesolutions
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-11
|
||||
Require-Bundle: flintstones.entity.ahp.decisionmatrix,
|
||||
flintstones.entity.problemelement,
|
||||
flintstones.entity.wvaluation,
|
||||
flintstones.valuation.numeric.real,
|
||||
flintstones.entity.valuation,
|
||||
flintstones.model.valuation.service,
|
||||
flintstones.operator,
|
||||
javax.inject,
|
||||
flintstones.operator.aggregation.min,
|
||||
flintstones.operator.aggregation.max,
|
||||
flintstones.entity.method.phase,
|
||||
flintstones.entity.operator
|
||||
Export-Package: flintstones.method.decision.common.phase.calculatesolutions
|
||||
@@ -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.calculatesolutions"
|
||||
implementation="flintstones.method.decision.common.phase.calculatesolutions.CalculateSolutionsModel">
|
||||
</phase>
|
||||
</extension>
|
||||
|
||||
</plugin>
|
||||
+147
@@ -0,0 +1,147 @@
|
||||
package flintstones.method.decision.common.phase.calculatesolutions;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.TreeMap;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import flintstones.entity.ahp.decisionmatrix.DecisionMatrix;
|
||||
import flintstones.entity.method.phase.PhaseMethod;
|
||||
import flintstones.entity.operator.AggregationOperator;
|
||||
import flintstones.entity.problemelement.entities.Criterion;
|
||||
import flintstones.entity.problemelement.entities.ProblemElement;
|
||||
import flintstones.entity.valuation.Valuation;
|
||||
import flintstones.entity.wvaluation.WValuation;
|
||||
import flintstones.operator.aggregation.max.Max;
|
||||
import flintstones.operator.aggregation.min.Min;
|
||||
import flintstones.operator.service.IOperatorService;
|
||||
import flintstones.valuation.numeric.real.RealValuation;
|
||||
|
||||
@SuppressWarnings({ "unchecked", "javadoc" })
|
||||
public class CalculateSolutionsModel extends PhaseMethod {
|
||||
|
||||
@Inject
|
||||
IOperatorService operatorService;
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Calculate Solutions";
|
||||
}
|
||||
|
||||
DecisionMatrix weightedDm = null;
|
||||
|
||||
public DecisionMatrix getDecisionMatrix() {
|
||||
|
||||
if (weightedDm != null)
|
||||
return weightedDm;
|
||||
|
||||
DecisionMatrix dm = (DecisionMatrix) importData("decisionMatrix");
|
||||
HashMap<Criterion, Double> weights = (HashMap<Criterion, Double>) importData("criterionWeights");
|
||||
weightedDm = applyWeights(dm, weights);
|
||||
|
||||
this.exportData("weightedDecisionMatrix", weightedDm);
|
||||
|
||||
return weightedDm;
|
||||
}
|
||||
|
||||
private DecisionMatrix applyWeights(DecisionMatrix dm, HashMap<Criterion, Double> weights) {
|
||||
|
||||
DecisionMatrix weightedDm = (DecisionMatrix) dm.clone();
|
||||
|
||||
for (Criterion columnPE : weightedDm.getCriterions()) {
|
||||
TreeMap<ProblemElement, WValuation> waluations = weightedDm.getColumn(columnPE);
|
||||
double weight = weights.get(columnPE);
|
||||
|
||||
for (WValuation w : waluations.values()) {
|
||||
RealValuation v = (RealValuation) w.getValuation();
|
||||
double value = v.getValue() * weight;
|
||||
v.setValue(value);
|
||||
weightedDm.set(w.getPEK().getCriterion(),w.getPEK().getAlternative(),v);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return weightedDm;
|
||||
|
||||
}
|
||||
|
||||
public ArrayList<WValuation> getPositiveIdealSolution() {
|
||||
|
||||
ArrayList<WValuation> rows = new ArrayList<>();
|
||||
|
||||
for (Criterion columnPE : weightedDm.getCriterions()) {
|
||||
TreeMap<ProblemElement, WValuation> waluations = weightedDm.getColumn(columnPE);
|
||||
ArrayList<Valuation> columnValuations = (ArrayList<Valuation>) waluations.values()
|
||||
.stream()
|
||||
.map(k -> k.getValuation())
|
||||
.collect(Collectors.toList());
|
||||
|
||||
WValuation anyW = waluations.values()
|
||||
.iterator()
|
||||
.next();
|
||||
|
||||
boolean isCost = anyW.getPEK()
|
||||
.getCriterion()
|
||||
.isCost();
|
||||
|
||||
Valuation finalValuation;
|
||||
|
||||
if (isCost) {
|
||||
AggregationOperator min = operatorService.getAggregationOperator(Min.class.getPackage().getName().toString(), columnValuations.get(0).getId());
|
||||
finalValuation = min.computeAggregation(columnValuations, null);
|
||||
} else {
|
||||
AggregationOperator max = operatorService.getAggregationOperator(Max.class.getPackage().getName().toString(), columnValuations.get(0).getId());
|
||||
finalValuation = max.computeAggregation(columnValuations, null);
|
||||
}
|
||||
|
||||
WValuation w = new WValuation(anyW.getPEK(), finalValuation);
|
||||
rows.add(w);
|
||||
|
||||
}
|
||||
|
||||
this.exportData("positiveIdealSolutions", rows);
|
||||
return rows;
|
||||
|
||||
}
|
||||
|
||||
public ArrayList<WValuation> getNegativeIdealSolution() {
|
||||
ArrayList<WValuation> rows = new ArrayList<>();
|
||||
|
||||
for (Criterion columnPE : weightedDm.getCriterions()) {
|
||||
TreeMap<ProblemElement, WValuation> waluations = weightedDm.getColumn(columnPE);
|
||||
|
||||
ArrayList<Valuation> columnValuations = (ArrayList<Valuation>) waluations.values()
|
||||
.stream()
|
||||
.map(k -> k.getValuation())
|
||||
.collect(Collectors.toList());
|
||||
|
||||
WValuation anyW = waluations.values()
|
||||
.iterator()
|
||||
.next();
|
||||
|
||||
boolean isCost = anyW.getPEK()
|
||||
.getCriterion()
|
||||
.isCost();
|
||||
|
||||
Valuation finalValuation;
|
||||
if (isCost) {
|
||||
AggregationOperator max = operatorService.getAggregationOperator(Max.class.getPackage().getName().toString(), columnValuations.get(0).getId());
|
||||
finalValuation = max.computeAggregation(columnValuations, null);
|
||||
|
||||
} else {
|
||||
AggregationOperator min = operatorService.getAggregationOperator(Min.class.getPackage().getName().toString(), columnValuations.get(0).getId());
|
||||
finalValuation = min.computeAggregation(columnValuations, null);
|
||||
}
|
||||
|
||||
WValuation w = new WValuation(anyW.getPEK(), finalValuation);
|
||||
rows.add(w);
|
||||
|
||||
}
|
||||
|
||||
this.exportData("negativeIdealSolutions", rows);
|
||||
return rows;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user