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,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.aggregation</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<packaging>eclipse-plugin</packaging>
|
||||
<name>[bundle] Aggregation</name>
|
||||
</project>
|
||||
@@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>flintstones.method.common.phase.aggregation</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>1779484362635</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,36 @@
|
||||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: Aggregation
|
||||
Bundle-SymbolicName: flintstones.method.common.phase.aggregation;singleton:=true
|
||||
Bundle-Version: 1.0.0.qualifier
|
||||
Automatic-Module-Name: flintstones.method.common.phase.aggregation
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
|
||||
Require-Bundle: flintstones.operator,
|
||||
flintstones.helper.wtable;visibility:=reexport,
|
||||
flintstones.entity.valuation,
|
||||
flintstones.model.valuation.service,
|
||||
flintstones.operator,
|
||||
flintstones.valuation.twoTuple,
|
||||
flintstones.valuation.linguistic,
|
||||
org.eclipse.jface,
|
||||
org.eclipse.wb.swt,
|
||||
flintstones.domain.fuzzyset.unbalanced,
|
||||
flintstones.entity.problemelement,
|
||||
javax.inject,
|
||||
org.eclipse.e4.core.contexts,
|
||||
org.eclipse.e4.core.di,
|
||||
flintstones.helper.data,
|
||||
flintstones.model.problemelement.service,
|
||||
org.eclipse.e4.core.services,
|
||||
flintstones.entity.domain,
|
||||
javax.annotation,
|
||||
flintstones.entity.operator,
|
||||
flintstones.entity.method.phase,
|
||||
flintstones.model.method.phase.service,
|
||||
flintstones.model.domain.service,
|
||||
flintstones.entity.aggregation,
|
||||
flintstones.method.common.model.retranslation
|
||||
Export-Package: flintstones.method.common.phase.aggregation,
|
||||
flintstones.method.common.phase.aggregation.exception,
|
||||
flintstones.method.common.phase.aggregation.provider
|
||||
Import-Package: flintstones.domain.fuzzyset.unbalanced
|
||||
@@ -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.common.phase.aggregation"
|
||||
implementation="flintstones.method.common.phase.aggregation.AggregationModel">
|
||||
</phase>
|
||||
</extension>
|
||||
|
||||
</plugin>
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
package flintstones.method.common.phase.aggregation;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.eclipse.e4.core.services.nls.Translation;
|
||||
|
||||
import flintstones.entity.method.phase.PhaseMethod;
|
||||
import flintstones.method.common.phase.aggregation.messages.Messages;
|
||||
|
||||
/**
|
||||
* The Class Aggregation.
|
||||
*/
|
||||
public class AggregationModel extends PhaseMethod {
|
||||
|
||||
/** The messages. */
|
||||
@Inject
|
||||
@Translation
|
||||
private Messages messages;
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see flintstones.phasemethod.PhaseMethod#getName()
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return messages.Aggregation_phase;
|
||||
}
|
||||
|
||||
|
||||
public void export(String k, Object v) {
|
||||
this.exportData(k, v, true);
|
||||
}
|
||||
|
||||
}
|
||||
+271
@@ -0,0 +1,271 @@
|
||||
package flintstones.method.common.phase.aggregation;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
|
||||
import org.eclipse.e4.core.contexts.IEclipseContext;
|
||||
|
||||
import flintstones.domain.fuzzyset.FuzzySet;
|
||||
import flintstones.entity.aggregation.AggregationItem;
|
||||
import flintstones.entity.domain.Domain;
|
||||
import flintstones.entity.method.phase.ImportedDataNotFoundException;
|
||||
import flintstones.entity.method.phase.PhaseMethod;
|
||||
import flintstones.entity.problemelement.ProblemElementKey;
|
||||
import flintstones.entity.problemelement.entities.Alternative;
|
||||
import flintstones.entity.problemelement.entities.Criterion;
|
||||
import flintstones.entity.problemelement.entities.Expert;
|
||||
import flintstones.entity.problemelement.entities.ProblemElementHelper;
|
||||
import flintstones.entity.valuation.Valuation;
|
||||
import flintstones.helper.MapHelper;
|
||||
import flintstones.helper.data.HashMatrix;
|
||||
import flintstones.method.common.model.retranslation.RetranslationModel;
|
||||
import flintstones.model.domain.service.IDomainService;
|
||||
import flintstones.model.problemelement.service.IProblemElementService;
|
||||
import flintstones.model.valuation.service.IValuationService;
|
||||
|
||||
public class AggregationResultModel extends PhaseMethod {
|
||||
|
||||
@Inject
|
||||
IProblemElementService problemService;
|
||||
|
||||
@Inject
|
||||
IValuationService valuationService;
|
||||
|
||||
@Inject
|
||||
IDomainService domainService;
|
||||
|
||||
@Inject
|
||||
IEclipseContext context;
|
||||
|
||||
// Model
|
||||
private RetranslationModel retranslationModel;
|
||||
private AggregationModel baseModel;
|
||||
|
||||
private Map<Alternative, Integer> cacheRankingPosition = new LinkedHashMap<>();
|
||||
|
||||
// Data
|
||||
private Map<Alternative, Valuation> aggregationResults = new LinkedHashMap<>();
|
||||
private Map<Alternative, Valuation> retranslatedResults = new HashMap<>();
|
||||
|
||||
// Options
|
||||
private String firstToAggregate = Expert.Type;
|
||||
|
||||
public AggregationResultModel() {
|
||||
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
private void init() {
|
||||
retranslationModel = ContextInjectionFactory.make(RetranslationModel.class, context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Aggregation Result Model";
|
||||
}
|
||||
|
||||
public void setAggregationModel(AggregationModel baseModel) {
|
||||
this.baseModel = baseModel;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Map<Alternative, Valuation> aggregate(Alternative[] alternatives) {
|
||||
|
||||
// 1. Aggregation
|
||||
String importItem = firstToAggregate.equals(Expert.Type) ? "expertCriterionWeightsMainTtem"
|
||||
: "criterionExpertWeightsMainItem";
|
||||
|
||||
AggregationItem item = (AggregationItem) importData(importItem);
|
||||
|
||||
Aggregator aggregator = new Aggregator(getValuations());
|
||||
ContextInjectionFactory.inject(aggregator, context);
|
||||
|
||||
HashMap<Alternative, Valuation> result = aggregator.aggregateAll(alternatives, item);
|
||||
|
||||
LinkedHashMap<Alternative, Valuation> sortedResult = (LinkedHashMap<Alternative, Valuation>) MapHelper
|
||||
.sortByValue(result, true);
|
||||
|
||||
// 2. Decision Matrix
|
||||
ArrayList<AggregationItem> subCriteriaItems = (ArrayList<AggregationItem>) importData("criterionExpertSubItems");
|
||||
|
||||
HashMap<Criterion, Double> criteriaWeights = (HashMap<Criterion, Double>) importData("criterionWeights");
|
||||
|
||||
HashMatrix<Alternative, Criterion, Valuation> decisionResult = aggregator
|
||||
.aggregateAndGetDecisionMatrix(alternatives, subCriteriaItems.toArray(new AggregationItem[0]));
|
||||
|
||||
// 3. Export the results
|
||||
|
||||
String[] exported = getExportedKeys(false);
|
||||
for(String ex : exported)
|
||||
baseModel.export(ex, this.importData(ex));
|
||||
|
||||
baseModel.export("aggregationresults", sortedResult);
|
||||
baseModel.export("decisionmatrix", decisionResult);
|
||||
baseModel.export("aggregatedWeights", criteriaWeights);
|
||||
|
||||
// Retro
|
||||
aggregationResults = sortedResult;
|
||||
return sortedResult;
|
||||
|
||||
}
|
||||
|
||||
public Map<Alternative, Valuation> getAggregationResults() {
|
||||
return this.aggregationResults;
|
||||
}
|
||||
|
||||
public void setFirstToAggregate(String firstToAggregate) {
|
||||
this.firstToAggregate = firstToAggregate;
|
||||
}
|
||||
|
||||
public String getFirstToAggregate() {
|
||||
return firstToAggregate;
|
||||
}
|
||||
|
||||
public Map<Alternative, Valuation> retranslateAggregationResults(FuzzySet retranslationDomain) {
|
||||
Map<Alternative, Valuation> result = retranslationModel.retranslate(getAggregationResults(),
|
||||
(FuzzySet) retranslationDomain);
|
||||
return (LinkedHashMap<Alternative, Valuation>) MapHelper.sortByValue(result, true);
|
||||
}
|
||||
|
||||
public Map<Alternative, Valuation> getRetranslationResult() {
|
||||
return retranslatedResults;
|
||||
}
|
||||
|
||||
public Domain getUnifiedDomain() {
|
||||
Domain d = null;
|
||||
try {
|
||||
d = (Domain) importData("unifiedDomain");
|
||||
|
||||
} catch (ImportedDataNotFoundException e) {
|
||||
|
||||
}
|
||||
|
||||
if (d == null)
|
||||
d = valuationService.getAll()[0].getDomain();
|
||||
|
||||
return d;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private Map<ProblemElementKey, Valuation> getValuations() {
|
||||
Map<ProblemElementKey, Valuation> valuations;
|
||||
|
||||
try {
|
||||
valuations = (Map<ProblemElementKey, Valuation>) importData("twoTupleUnifiedValuations");
|
||||
} catch(ImportedDataNotFoundException e) {
|
||||
valuations = valuationService.getAllKV();
|
||||
}
|
||||
|
||||
return valuations;
|
||||
|
||||
}
|
||||
|
||||
public void computeRankingAlternatives(Map<Alternative, Valuation> result) {
|
||||
cacheRankingPosition.clear();
|
||||
|
||||
int pos = 1;
|
||||
|
||||
List<Entry<Alternative, Valuation>> results = result.entrySet().stream().collect(Collectors.toList());
|
||||
for (int i = 0; i < results.size() - 1; i++) {
|
||||
Entry<Alternative, Valuation> entry1 = results.get(i);
|
||||
Entry<Alternative, Valuation> entry2 = results.get(i + 1);
|
||||
|
||||
Alternative a = entry1.getKey();
|
||||
Valuation v1 = entry1.getValue();
|
||||
Valuation v2 = entry2.getValue();
|
||||
|
||||
cacheRankingPosition.put(a, pos);
|
||||
|
||||
if (v1.compareTo(v2) != 0)
|
||||
pos++;
|
||||
}
|
||||
|
||||
if (results.size() != 0)
|
||||
cacheRankingPosition.put(results.get(results.size() - 1).getKey(), pos);
|
||||
|
||||
}
|
||||
|
||||
public int getRankingAlternative(Alternative alternative) {
|
||||
Integer pos = cacheRankingPosition.get(alternative);
|
||||
return pos != null ? pos : 1;
|
||||
}
|
||||
|
||||
public String[] getRetranslationDomainsIds() {
|
||||
if (retranslationModel.getRetranslationDomains().isEmpty()) {
|
||||
try {
|
||||
retranslationModel.setRetranslationDomains(importLinguisticHierarchiesDomains());
|
||||
} catch (ImportedDataNotFoundException e) {
|
||||
retranslationModel.setRetranslationDomains(importGeneralRetranslationDomains());
|
||||
}
|
||||
}
|
||||
return retranslationModel.getRetranslationDomainsIds();
|
||||
}
|
||||
|
||||
public void computeRetranslationResults(String id) {
|
||||
Domain domain = getRetranslationDomain(id);
|
||||
|
||||
if (domain.getName().equals(this.getUnifiedDomain().getName()))
|
||||
retranslatedResults = aggregationResults;
|
||||
else
|
||||
retranslatedResults = retranslateAggregationResults((FuzzySet) domain);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get retranslation domain id retranslation domain id
|
||||
*
|
||||
* @return the retranslation domain
|
||||
*/
|
||||
public Domain getRetranslationDomain(String id) {
|
||||
if (id.equals(this.getUnifiedDomain().getName())) {
|
||||
return this.getUnifiedDomain();
|
||||
} else {
|
||||
Domain retranslationDomain = retranslationModel.getRetranslationDomain(id);
|
||||
return retranslationDomain;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the linguistic hierarchies domains except unification domain
|
||||
*
|
||||
* @return lh domains
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private List<Object[]> importLinguisticHierarchiesDomains() {
|
||||
List<Object[]> elhDomains = (List<Object[]>) this.importData("elhDomains");
|
||||
elhDomains.remove(elhDomains.size() - 1);
|
||||
return elhDomains;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the domains except unification domain
|
||||
*
|
||||
* @return retranslation domains
|
||||
*/
|
||||
private List<Object[]> importGeneralRetranslationDomains() {
|
||||
Domain unifiedDomain = getUnifiedDomain();
|
||||
List<Object[]> domainsStructured = new LinkedList<Object[]>();
|
||||
List<Domain> domains = Arrays.asList(domainService.getAll());
|
||||
for (Domain domain : domains)
|
||||
if (!domain.equals(unifiedDomain) && domain instanceof FuzzySet)
|
||||
domainsStructured.add(
|
||||
new Object[] { ((FuzzySet) domain).getLabelSet().getCardinality(), domain.getName(), domain });
|
||||
|
||||
return domainsStructured;
|
||||
}
|
||||
|
||||
public Alternative[] getAlternatives() {
|
||||
return ProblemElementHelper.asAlternatives(problemService.getAll(Alternative.Type));
|
||||
}
|
||||
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
package flintstones.method.common.phase.aggregation;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import flintstones.entity.problemelement.entities.Criterion;
|
||||
import flintstones.entity.problemelement.entities.Expert;
|
||||
import flintstones.entity.problemelement.entities.ProblemElement;
|
||||
import flintstones.helper.data.HashMatrix;
|
||||
|
||||
public class AggregationWeights {
|
||||
|
||||
HashMatrix<Expert, Criterion, Double> expertCriterionWeights;
|
||||
HashMatrix<Criterion, Expert, Double> criterionExpertWeights;
|
||||
HashMap<Expert, Double> expertWeights;
|
||||
HashMap<Criterion, Double> criterionWeights;
|
||||
|
||||
public AggregationWeights(HashMatrix<Expert, Criterion, Double> expertCriterionWeights, //
|
||||
HashMatrix<Criterion, Expert, Double> criterionExpertWeights, //
|
||||
HashMap<Expert, Double> expertWeights, //
|
||||
HashMap<Criterion, Double> criterionWeights //
|
||||
) {
|
||||
// super();
|
||||
this.expertCriterionWeights = expertCriterionWeights;
|
||||
this.criterionExpertWeights = criterionExpertWeights;
|
||||
this.expertWeights = expertWeights;
|
||||
this.criterionWeights = criterionWeights;
|
||||
}
|
||||
|
||||
public Double get(ProblemElement first) {
|
||||
return get(first,null);
|
||||
}
|
||||
|
||||
public Double get(ProblemElement first, ProblemElement second) {
|
||||
|
||||
// Only one element
|
||||
if (second == null) {
|
||||
Double val = expertWeights.get(first);
|
||||
if (val == null)
|
||||
criterionWeights.get(first);
|
||||
return val;
|
||||
}
|
||||
|
||||
if (first.getType().equals(Expert.Type))
|
||||
return expertCriterionWeights.get((Expert) first, (Criterion) second);
|
||||
return criterionExpertWeights.get((Criterion) first, (Expert) second);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+129
@@ -0,0 +1,129 @@
|
||||
package flintstones.method.common.phase.aggregation;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import flintstones.entity.aggregation.AggregationItem;
|
||||
import flintstones.entity.operator.AggregationOperator;
|
||||
import flintstones.entity.operator.interfaces.IParameterizedOperator;
|
||||
import flintstones.entity.problemelement.ProblemElementKey;
|
||||
import flintstones.entity.problemelement.entities.Alternative;
|
||||
import flintstones.entity.problemelement.entities.Criterion;
|
||||
import flintstones.entity.problemelement.entities.ProblemElement;
|
||||
import flintstones.entity.valuation.Valuation;
|
||||
import flintstones.helper.data.HashMatrix;
|
||||
import flintstones.operator.service.IOperatorService;
|
||||
|
||||
class Aggregator {
|
||||
|
||||
@Inject
|
||||
IOperatorService operatorService;
|
||||
|
||||
Map<ProblemElementKey, Valuation> uvaluations;
|
||||
|
||||
public Aggregator(Map<ProblemElementKey, Valuation> unifiedValuations) {
|
||||
this.uvaluations = unifiedValuations;
|
||||
}
|
||||
|
||||
public HashMap<Alternative, Valuation> aggregateAll(Alternative[] alternatives, AggregationItem root) {
|
||||
HashMap<Alternative, Valuation> result = aggregateAlternatives(alternatives, root);
|
||||
return result;
|
||||
}
|
||||
|
||||
private HashMap<Alternative, Valuation> aggregateAlternatives(Alternative[] alternatives, AggregationItem root){
|
||||
|
||||
HashMap<Alternative, Valuation> result = new HashMap<>();
|
||||
for(Alternative a : alternatives) {
|
||||
Valuation v = aggregateAlternative(a,root);
|
||||
result.put(a, v);
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
private Valuation aggregateAlternative(Alternative a, AggregationItem root) {
|
||||
|
||||
try {
|
||||
AggregationItem rootAux = (AggregationItem) root.clone();
|
||||
rootAux.setAlternative(a, true);
|
||||
return aggregateItem(rootAux);
|
||||
} catch (CloneNotSupportedException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private Valuation aggregateItem(AggregationItem parentItem) {
|
||||
|
||||
AggregationItem[] children = parentItem.getChildren();
|
||||
|
||||
// Bottom element -- Return the valuation
|
||||
if(children.length == 0) {
|
||||
ProblemElementKey pek = new ProblemElementKey() //
|
||||
.assign(parentItem.getAlternative()) //
|
||||
.assign(parentItem.getElement2()) //
|
||||
.assign(parentItem.getElement3());
|
||||
|
||||
Valuation v = uvaluations.get(pek);
|
||||
return v;
|
||||
}
|
||||
|
||||
// Middle element, aggregate its children and return the result
|
||||
List<Valuation> valuations = new ArrayList<>();
|
||||
List<ProblemElement> items = new ArrayList<>();
|
||||
|
||||
for(AggregationItem item : children) {
|
||||
|
||||
if(!item.isEnabled())
|
||||
continue;
|
||||
|
||||
items.add(item.getElement2());
|
||||
|
||||
Valuation v = aggregateItem(item);
|
||||
valuations.add(v);
|
||||
}
|
||||
|
||||
String operatorId = parentItem.getOperatorId();
|
||||
|
||||
List<Double> weights = Arrays.stream(children).map(k -> k.getWeight()).collect(Collectors.toList());
|
||||
|
||||
if(valuations.size() == 1)
|
||||
return valuations.get(0);
|
||||
|
||||
if(operatorId.isEmpty())
|
||||
return null;
|
||||
|
||||
AggregationOperator operator = operatorService.getAggregationOperator(operatorId, valuations.get(0).getId());
|
||||
|
||||
Valuation v = null;
|
||||
if(operator instanceof IParameterizedOperator)//To visualize the dialog
|
||||
v = operator.computeParameterizedAggregation(items.toArray(new ProblemElement[0]), valuations, weights);
|
||||
else
|
||||
v = operator.computeAggregation(valuations, weights);
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
public HashMatrix<Alternative, Criterion, Valuation> aggregateAndGetDecisionMatrix(Alternative[] alternatives, AggregationItem[] subCriteria) {
|
||||
|
||||
HashMatrix<Alternative, Criterion, Valuation> dMatrix = new HashMatrix<>();
|
||||
for(Alternative a : alternatives) {
|
||||
for(AggregationItem critItem : subCriteria ) {
|
||||
// Prepare things
|
||||
critItem.setAlternative(a, true);
|
||||
Valuation v = aggregateItem(critItem);
|
||||
dMatrix.put(a, (Criterion)critItem.getElement2(), v);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return dMatrix;
|
||||
}
|
||||
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package flintstones.method.common.phase.aggregation.exception;
|
||||
|
||||
import flintstones.entity.problemelement.entities.ProblemElement;
|
||||
|
||||
/**
|
||||
* The Class AtLeastOneTopLevelElementEnabled.
|
||||
*/
|
||||
public class AtLeastOneTopLevelElementEnabled extends Exception {
|
||||
|
||||
/** The Constant serialVersionUID. */
|
||||
private static final long serialVersionUID = -3604211158243889353L;
|
||||
|
||||
/**
|
||||
* Instantiates a new at least one top level element enabled.
|
||||
*
|
||||
* @param pe the pe
|
||||
*/
|
||||
public AtLeastOneTopLevelElementEnabled(ProblemElement pe) {
|
||||
super("You mast enable at least one top-level element with at least one enabled final children. Error found when aggregating " + pe.getName() + " (" + pe.getType()+ ")" );
|
||||
}
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package flintstones.method.common.phase.aggregation.exception;
|
||||
|
||||
import flintstones.entity.problemelement.entities.ProblemElement;
|
||||
|
||||
/**
|
||||
* The Class OperatorNotAssignedException.
|
||||
*/
|
||||
public class OperatorNotAssignedException extends Exception {
|
||||
|
||||
/** The Constant serialVersionUID. */
|
||||
private static final long serialVersionUID = 968207884931855311L;
|
||||
|
||||
/**
|
||||
* Instantiates a new operator not assigned exception.
|
||||
*
|
||||
* @param pe the pe
|
||||
*/
|
||||
public OperatorNotAssignedException(ProblemElement pe) {
|
||||
super("El elemento no tiene un operador asignado: " + pe.getName() + " ("+pe.getType()+")" );
|
||||
}
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
package flintstones.method.common.phase.aggregation.listener;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.eclipse.jface.viewers.CheckStateChangedEvent;
|
||||
import org.eclipse.jface.viewers.ICheckStateListener;
|
||||
|
||||
import flintstones.entity.problemelement.entities.ProblemElement;
|
||||
|
||||
/**
|
||||
* The listener interface for receiving problemElementAggregationCheckState events.
|
||||
* The class that is interested in processing a problemElementAggregationCheckState
|
||||
* event implements this interface, and the object created
|
||||
* with that class is registered with a component using the
|
||||
* component's <code>addProblemElementAggregationCheckStateListener<code> method. When
|
||||
* the problemElementAggregationCheckState event occurs, that object's appropriate
|
||||
* method is invoked.
|
||||
*
|
||||
* @see ProblemElementAggregationCheckStateEvent
|
||||
*/
|
||||
public class ProblemElementAggregationCheckStateListener implements ICheckStateListener {
|
||||
|
||||
/** The enabled PE. */
|
||||
HashMap<ProblemElement, Boolean> enabledPE;
|
||||
|
||||
/**
|
||||
* Instantiates a new problem element aggregation check state listener.
|
||||
*
|
||||
* @param enabledPE the enabled PE
|
||||
*/
|
||||
public ProblemElementAggregationCheckStateListener(HashMap<ProblemElement, Boolean> enabledPE){
|
||||
this.enabledPE = enabledPE;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.ICheckStateListener#checkStateChanged(org.eclipse.jface.viewers.CheckStateChangedEvent)
|
||||
*/
|
||||
@Override
|
||||
public void checkStateChanged(CheckStateChangedEvent event) {
|
||||
boolean status = event.getChecked();
|
||||
ProblemElement pe = (ProblemElement) event.getElement();
|
||||
enabledPE.put(pe, status);
|
||||
}
|
||||
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package flintstones.method.common.phase.aggregation.messages;
|
||||
|
||||
import org.eclipse.e4.core.services.nls.Message;
|
||||
|
||||
@Message
|
||||
@SuppressWarnings("javadoc")
|
||||
public class Messages {
|
||||
|
||||
public String WeightsDialog_0;
|
||||
public String WeightsDialog_Invalid_range;
|
||||
public String WeightsDialog_Invalid_value;
|
||||
public String WeightsDialog_Values_for;
|
||||
public String WeightsDialog_Simple_aggregation;
|
||||
public Object WeightsDialog_All;
|
||||
public String WeightsDialog_Cancel_all;
|
||||
public String WeightsDialog_Cancel;
|
||||
public String WeightsDialog_Save;
|
||||
public String Aggregation_phase;
|
||||
|
||||
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
AggregationProcess_Aggregation_process=Aggregation process
|
||||
AggregationProcess_Criterion=Criterion
|
||||
AggregationProcess_Expert=Expert
|
||||
AggregationProcess_GRP=GRP
|
||||
AggregationProcess_Weight=Weight
|
||||
Aggregation_phase=Aggregation
|
||||
WeightsDialog_0=Invalid_range
|
||||
WeightsDialog_All=All
|
||||
WeightsDialog_Cancel=Cancel
|
||||
WeightsDialog_Cancel_all=Cancel all
|
||||
WeightsDialog_Invalid_range=Invalid range
|
||||
WeightsDialog_Invalid_value=Invalid value
|
||||
WeightsDialog_Save=Save
|
||||
WeightsDialog_Simple_aggregation=Simple aggregation
|
||||
WeightsDialog_Values_for=Values for
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
AggregationProcess_Aggregation_process=Proceso de agregacin
|
||||
AggregationProcess_Criterion=Criterio
|
||||
AggregationProcess_Expert=Experto
|
||||
AggregationProcess_GRP=GRP
|
||||
AggregationProcess_Weight=Peso
|
||||
Aggregation_phase=Agregación
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
package flintstones.method.common.phase.aggregation.provider;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.eclipse.jface.viewers.ICheckStateProvider;
|
||||
|
||||
import flintstones.entity.problemelement.entities.ProblemElement;
|
||||
|
||||
/**
|
||||
* The Class ProblemElementAggregationCheckStateProvider.
|
||||
*/
|
||||
public class ProblemElementAggregationCheckStateProvider implements ICheckStateProvider {
|
||||
|
||||
/** The enabled PE. */
|
||||
HashMap<ProblemElement, Boolean> enabledPE;
|
||||
|
||||
/**
|
||||
* Instantiates a new problem element aggregation check state provider.
|
||||
*
|
||||
* @param enabledPE the enabled PE
|
||||
*/
|
||||
public ProblemElementAggregationCheckStateProvider(HashMap<ProblemElement, Boolean> enabledPE) {
|
||||
this.enabledPE = enabledPE;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.ICheckStateProvider#isChecked(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public boolean isChecked(Object element) {
|
||||
ProblemElement pe = (ProblemElement) element;
|
||||
Boolean status = enabledPE.get(pe);
|
||||
if(status != null && status.booleanValue())
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.ICheckStateProvider#isGrayed(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public boolean isGrayed(Object element) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user