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-11"/>
|
||||
<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.waspasFuzzy.results</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<packaging>eclipse-plugin</packaging>
|
||||
<name>[bundle] Bundle-Name</name>
|
||||
</project>
|
||||
@@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>flintstones.method.waspasFuzzy.results</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>1779484362713</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
|
||||
@@ -0,0 +1,9 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
|
||||
org.eclipse.jdt.core.compiler.compliance=11
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
|
||||
org.eclipse.jdt.core.compiler.release=enabled
|
||||
org.eclipse.jdt.core.compiler.source=11
|
||||
@@ -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: %Bundle-Name
|
||||
Bundle-SymbolicName: flintstones.method.waspasFuzzy.results;singleton:=true
|
||||
Bundle-Version: 1.0.0.qualifier
|
||||
Automatic-Module-Name: flintstones.method.waspasFuzzy.results
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-11
|
||||
Require-Bundle: org.eclipse.e4.core.services,
|
||||
javax.inject,
|
||||
flintstones.entity.method.phase,
|
||||
flintstones.model.problemelement.service,
|
||||
flintstones.engine.R,
|
||||
flintstones.domain.fuzzyset,
|
||||
flintstones.helper.data
|
||||
Export-Package: flintstones.method.waspasFuzzy.results
|
||||
@@ -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
|
||||
implementation="flintstones.method.waspasFuzzy.results.WASPASFuzzyResults"
|
||||
uid="flintstones.method.waspasFuzzy.results">
|
||||
</phase>
|
||||
</extension>
|
||||
|
||||
</plugin>
|
||||
+150
@@ -0,0 +1,150 @@
|
||||
package flintstones.method.waspasFuzzy.results;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.eclipse.e4.core.services.nls.Translation;
|
||||
import org.rosuda.JRI.REXP;
|
||||
import org.rosuda.JRI.Rengine;
|
||||
|
||||
import flintstones.domain.fuzzyset.function.types.TrapezoidalFunction;
|
||||
import flintstones.entity.method.phase.PhaseMethod;
|
||||
import flintstones.entity.problemelement.entities.Alternative;
|
||||
import flintstones.entity.problemelement.entities.Criterion;
|
||||
import flintstones.entity.problemelement.entities.ProblemElement;
|
||||
import flintstones.entity.problemelement.entities.ProblemElementHelper;
|
||||
import flintstones.helper.data.HashMatrix;
|
||||
import flintstones.method.waspasFuzzy.results.messages.Messages;
|
||||
import flintstones.model.problemelement.service.IProblemElementService;
|
||||
|
||||
public class WASPASFuzzyResults extends PhaseMethod{
|
||||
|
||||
@Inject
|
||||
IProblemElementService problemService;
|
||||
|
||||
@Inject
|
||||
@Translation
|
||||
Messages msg;
|
||||
|
||||
/**
|
||||
* Problem criteria
|
||||
*/
|
||||
Criterion[] allCriteria;
|
||||
|
||||
/**
|
||||
* Problem alternatives
|
||||
*/
|
||||
Alternative[] allAlternatives;
|
||||
|
||||
/**
|
||||
* R execution engine
|
||||
*/
|
||||
Rengine eng;
|
||||
|
||||
/**
|
||||
* Criteria weights
|
||||
*/
|
||||
ArrayList<TrapezoidalFunction> aggCriWeights;
|
||||
|
||||
/**
|
||||
* Aggregated valuations
|
||||
*/
|
||||
HashMatrix<ProblemElement, ProblemElement, TrapezoidalFunction> aggregatedValues;
|
||||
|
||||
/**
|
||||
* @return Problem criteria
|
||||
*/
|
||||
public Criterion[] allCriteria() {
|
||||
return allCriteria;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Problem alternatives
|
||||
*/
|
||||
public Alternative[] allAlternatives() {
|
||||
return allAlternatives;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Phase name
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return msg.phase_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads problem data from previous phases and creates R engine
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public void loadData() {
|
||||
eng = Rengine.getMainEngine();
|
||||
if(eng == null)
|
||||
eng = new Rengine(new String[] { "--no-save" }, false, null);
|
||||
|
||||
allCriteria = ProblemElementHelper.asCriterions(problemService.getAll(Criterion.Type));
|
||||
allAlternatives = ProblemElementHelper.asAlternatives(problemService.getAll(Alternative.Type));
|
||||
|
||||
aggCriWeights = (ArrayList<TrapezoidalFunction>) importData("aggregatedWeights");
|
||||
aggregatedValues = (HashMatrix<ProblemElement, ProblemElement, TrapezoidalFunction>) importData(
|
||||
"aggregatedValues");
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes FuzzyMMOORA function from R engine
|
||||
* @return R expression with results
|
||||
*/
|
||||
public REXP executeR(double lambda) {
|
||||
//Start library
|
||||
eng.eval("library(FuzzyMCDM)");
|
||||
|
||||
//Valuation matrix: decision <- matrix(c(...), nrow, ncol)
|
||||
StringBuilder sb = new StringBuilder("decision <- matrix(c(");
|
||||
TrapezoidalFunction temp;
|
||||
for(int c = 0; c < allCriteria.length; c++) {
|
||||
for(int v = 0; v < 3; v++) {
|
||||
for(int a = 0; a < allAlternatives.length; a++) {
|
||||
temp = aggregatedValues.get(allAlternatives[a], allCriteria[c]);
|
||||
if(v==0) {
|
||||
sb.append(temp.getA() + ",");
|
||||
}else if(v==1) {
|
||||
sb.append(temp.getB() + ",");
|
||||
}else {
|
||||
sb.append(temp.getD() + ",");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
sb.deleteCharAt(sb.length()-1);
|
||||
sb.append("),nrow = " + allAlternatives.length + ",ncol = " + allCriteria.length*3 + ")");
|
||||
eng.eval(sb.toString());
|
||||
|
||||
//Criterion weights: we <- c(...)
|
||||
sb = new StringBuilder("we <- c(");
|
||||
for(int c = 0; c < allCriteria.length; c++) {
|
||||
temp = aggCriWeights.get(c);
|
||||
sb.append(temp.getA() + "," + temp.getB() + "," + temp.getD() + ",");
|
||||
}
|
||||
sb.deleteCharAt(sb.length()-1);
|
||||
sb.append(")");
|
||||
eng.eval(sb.toString());
|
||||
|
||||
//Type of criteria (cost/benefit)
|
||||
sb = new StringBuilder("cb <- c(");
|
||||
for(int c = 0; c < allCriteria.length; c++) {
|
||||
if(allCriteria[c].isCost()) {
|
||||
sb.append("\"min\",");
|
||||
}else {
|
||||
sb.append("\"max\",");
|
||||
}
|
||||
}
|
||||
sb.deleteCharAt(sb.length()-1);
|
||||
sb.append(")");
|
||||
eng.eval(sb.toString());
|
||||
|
||||
return eng.eval("FuzzyMCDM::FuzzyWASPAS(decision, we, cb," + Double.toString(lambda) + ")");
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package flintstones.method.waspasFuzzy.results.messages;
|
||||
|
||||
import org.eclipse.e4.core.services.nls.Message;
|
||||
|
||||
@Message
|
||||
public class Messages {
|
||||
public String phase_name;
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
phase_name=Results
|
||||
+1
@@ -0,0 +1 @@
|
||||
phase_name=Resultados
|
||||
Reference in New Issue
Block a user