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.ahp.phase.ranking</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<packaging>eclipse-plugin</packaging>
|
||||
<name>[bundle] Ranking</name>
|
||||
</project>
|
||||
@@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>flintstones.method.ahp.phase.ranking</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>1779484362619</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,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,27 @@
|
||||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: Ranking
|
||||
Bundle-SymbolicName: flintstones.method.ahp.phase.ranking;singleton:=true
|
||||
Bundle-Version: 1.0.0.qualifier
|
||||
Automatic-Module-Name: flintstones.method.ahp.phase.ranking
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-11
|
||||
Require-Bundle: flintstones.operator,
|
||||
javax.inject,
|
||||
flintstones.entity.problemelement,
|
||||
flintstones.entity.valuation,
|
||||
flintstones.model.valuation.service,
|
||||
flintstones.valuation.numeric.real,
|
||||
flintstones.operator.aggregation.geometricMean,
|
||||
org.apache.commons.math3,
|
||||
org.eclipse.e4.core.contexts,
|
||||
flintstones.entity.ahp,
|
||||
flintstones.model.ahppreferences.service,
|
||||
flintstones.entity.ahppreferences,
|
||||
flintstones.model.problemelement.service,
|
||||
flintstones.entity.preferences.preferencecollection,
|
||||
org.eclipse.e4.core.di,
|
||||
flintstones.model.domain.service,
|
||||
flintstones.helper.data,
|
||||
flintstones.entity.domain,
|
||||
flintstones.entity.method.phase
|
||||
Export-Package: flintstones.method.ahp.phase.ranking
|
||||
@@ -0,0 +1,47 @@
|
||||
<p align="center">
|
||||
<img src="https://cdn.jsdelivr.net/emojione/assets/svg/1f63c.svg" width="256" height="256" alt="Snarkdown">
|
||||
<br>
|
||||
<a href="https://www.npmjs.org/package/snarkdown"><img src="https://img.shields.io/npm/v/snarkdown.svg?style=flat" alt="npm"></a> <a href="https://travis-ci.org/developit/snarkdown"><img src="https://travis-ci.org/developit/snarkdown.svg?branch=master" alt="travis"></a>
|
||||
</p>
|
||||
|
||||
|
||||
Snarkdown is a dead simple **1kb** [Markdown] parser.
|
||||
|
||||
It's designed to be as minimal as possible, for constrained use-cases where a full Markdown parser would be inappropriate.
|
||||
|
||||
|
||||
## Features
|
||||
|
||||
- **Fast:** since it's basically one regex and a huge if statement
|
||||
- **Tiny:** it's 1kb of gzipped ES3
|
||||
- **Simple:** pass a Markdown string, get back an HTML string
|
||||
|
||||
> **Note:** Tables are not yet supported. If you love impossible to read regular expressions, submit a PR!
|
||||
|
||||
## Demos & Examples
|
||||
|
||||
- ⚛️ [**Snarky**](https://snarky.surge.sh) - markdown editor built with Preact & Snarkdown
|
||||
- ✏️ [**Simple Markdown Editor**](http://jsfiddle.net/developit/828w6t1x/)
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
Snarkdown exports a single function, which parses a string of Markdown and returns a String of HTML. Couldn't be simpler.
|
||||
|
||||
The snarkdown module is available in [every module format](https://unpkg.com/snarkdown/dist/) you'd ever need: ES Modules, CommonJS, UMD...
|
||||
|
||||
```js
|
||||
import snarkdown from 'snarkdown';
|
||||
|
||||
let md = '_this_ is **easy** to `use`.';
|
||||
let html = snarkdown(md);
|
||||
console.log(html);
|
||||
// <em>this</em> is <strong>easy</strong> to <code>use</code>.
|
||||
```
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
|
||||
[Markdown]: http://daringfireball.net/projects/markdown/
|
||||
@@ -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.ahp.phase.ranking"
|
||||
implementation="flintstones.method.ahp.phase.ranking.AHPRankingModel">
|
||||
</phase>
|
||||
</extension>
|
||||
|
||||
</plugin>
|
||||
+233
@@ -0,0 +1,233 @@
|
||||
package flintstones.method.ahp.phase.ranking;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.commons.math3.linear.EigenDecomposition;
|
||||
import org.apache.commons.math3.linear.MatrixUtils;
|
||||
import org.apache.commons.math3.linear.RealMatrix;
|
||||
import org.apache.commons.math3.linear.RealVector;
|
||||
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
|
||||
import org.eclipse.e4.core.contexts.IEclipseContext;
|
||||
|
||||
import flintstones.entity.ahp.AHPAggregatedMatrix;
|
||||
import flintstones.entity.ahp.AHPMatrix;
|
||||
import flintstones.entity.method.phase.PhaseMethod;
|
||||
import flintstones.entity.preferences.preferencecollection.PreferenceCollection;
|
||||
import flintstones.entity.problemelement.entities.Alternative;
|
||||
import flintstones.entity.problemelement.entities.Criterion;
|
||||
import flintstones.entity.problemelement.entities.Expert;
|
||||
import flintstones.entity.problemelement.entities.ProblemElement;
|
||||
import flintstones.helper.DoubleHelper;
|
||||
import flintstones.helper.MatrixHelper;
|
||||
import flintstones.model.ahppreferences.service.IProblemPreferencesService;
|
||||
import flintstones.model.domain.service.IDomainService;
|
||||
import flintstones.model.problemelement.service.IProblemElementService;
|
||||
import flintstones.model.valuation.service.IValuationService;
|
||||
import flintstones.operator.service.IOperatorService;
|
||||
|
||||
/**
|
||||
* The Class AHPRankingModel.
|
||||
*/
|
||||
public class AHPRankingModel extends PhaseMethod {
|
||||
|
||||
/** The op service. */
|
||||
@Inject
|
||||
IOperatorService opService;
|
||||
|
||||
/** The pref service. */
|
||||
@Inject
|
||||
IProblemPreferencesService prefService;
|
||||
|
||||
/** The problem service. */
|
||||
@Inject
|
||||
IProblemElementService problemService;
|
||||
|
||||
/** The valuation service. */
|
||||
@Inject
|
||||
IValuationService valuationService;
|
||||
|
||||
/** The domain service. */
|
||||
@Inject
|
||||
IDomainService domainService;
|
||||
|
||||
/** The context. */
|
||||
@Inject
|
||||
IEclipseContext context;
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see flintstones.phasemethod.PhaseMethod#getName()
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return "AHP Ranking";
|
||||
}
|
||||
|
||||
/** The eigen vector criterion. */
|
||||
// Cache
|
||||
double[] eigenVectorCriterion;
|
||||
|
||||
/** The eigen matrix alternative. */
|
||||
double[][] eigenMatrixAlternative;
|
||||
|
||||
/** The final eigen vector. */
|
||||
double[] finalEigenVector;
|
||||
|
||||
/** The eigen vector criterions. */
|
||||
ProblemElement[] eigenVectorCriterions;
|
||||
|
||||
/** The eigen matrix alternatives. */
|
||||
ProblemElement[] eigenMatrixAlternatives;
|
||||
|
||||
/**
|
||||
* Execute the model.
|
||||
*/
|
||||
public void execute() {
|
||||
|
||||
eigenVectorCriterion = getCriterionEigenVector();
|
||||
eigenMatrixAlternative = getAlternativesEigenMatrix();
|
||||
|
||||
finalEigenVector = new double[eigenMatrixAlternative.length];
|
||||
|
||||
for (int i = 0; i < eigenMatrixAlternative.length; i++) {
|
||||
|
||||
double[] sumVector = new double[eigenVectorCriterion.length];
|
||||
for (int j = 0; j < eigenVectorCriterion.length; j++) {
|
||||
double a = eigenVectorCriterion[j];
|
||||
double b = eigenMatrixAlternative[i][j];
|
||||
double r = a * b;
|
||||
sumVector[j] = r;
|
||||
}
|
||||
double sum = Arrays.stream(sumVector).sum();
|
||||
finalEigenVector[i] = sum;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the criterion eigen vector.
|
||||
*
|
||||
* @return the criterion eigen vector
|
||||
*/
|
||||
private double[] getCriterionEigenVector() {
|
||||
double[] eigenVectorCriterion = new double[problemService.getAll(Criterion.Type).length];
|
||||
|
||||
// NEW
|
||||
PreferenceCollection col = prefService.get(null, Expert.Type, Criterion.Type, Criterion.Type);
|
||||
AHPAggregatedMatrix aggMatrix = aggregatedMatrix(col.getEveryAHPMatrix());
|
||||
//
|
||||
|
||||
double[][] resultMatrix = aggMatrix.getResultMatrix();
|
||||
eigenVectorCriterions = aggMatrix.getRow();
|
||||
|
||||
RealMatrix realMatrix = MatrixUtils.createRealMatrix(resultMatrix);
|
||||
EigenDecomposition descomposition = new EigenDecomposition(realMatrix);
|
||||
|
||||
// Obtenemos el autovector (sin normalizar) del autovalor que le indiquemos
|
||||
int pos = DoubleHelper.FindMaxIndex(descomposition.getRealEigenvalues());
|
||||
RealVector eigenVector = descomposition.getEigenvector(pos);
|
||||
|
||||
eigenVectorCriterion = eigenVector.toArray();
|
||||
eigenVectorCriterion = DoubleHelper.Normalize(eigenVectorCriterion);
|
||||
|
||||
return eigenVectorCriterion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the alternatives eigen matrix.
|
||||
*
|
||||
* @return the alternatives eigen matrix
|
||||
*/
|
||||
private double[][] getAlternativesEigenMatrix() {
|
||||
|
||||
double[][] eigenMatrixAlternativeMatrix = new double[problemService.getAll(Criterion.Type).length][problemService.getAll(Alternative.Type).length];
|
||||
PreferenceCollection col = prefService.get(Expert.Type, Criterion.Type, Alternative.Type, Alternative.Type);
|
||||
|
||||
// Foreach criterion
|
||||
ProblemElement[] criterions = eigenVectorCriterions;
|
||||
for (int i = 0; i < criterions.length; i++) {
|
||||
|
||||
ProblemElement c = criterions[i];
|
||||
|
||||
AHPAggregatedMatrix aggMatrix = aggregatedMatrix(col.getEveryAHPMatrixOther(c));
|
||||
// AHPAggregatedMatrix aggMatrix = getAggregatedMatrix(ahpService.getAllAlternativesPreferencesFor((Criterion)c));
|
||||
double[][] resultMatrix = aggMatrix.getResultMatrix();
|
||||
eigenMatrixAlternatives = aggMatrix.getRow();
|
||||
|
||||
RealMatrix realMatrix = MatrixUtils.createRealMatrix(resultMatrix);
|
||||
EigenDecomposition descomposition = new EigenDecomposition(realMatrix);
|
||||
|
||||
// Obtenemos el autovector (sin normalizar) del autovalor que le indiquemos
|
||||
int pos = DoubleHelper.FindMaxIndex(descomposition.getRealEigenvalues());
|
||||
RealVector eigenVector = descomposition.getEigenvector(pos);
|
||||
double[] eigenVectorArr = eigenVector.toArray();
|
||||
|
||||
eigenVectorArr = DoubleHelper.Normalize(eigenVectorArr);
|
||||
eigenMatrixAlternativeMatrix[i] = eigenVectorArr;
|
||||
}
|
||||
|
||||
double[][] transposed = MatrixHelper.transpose(eigenMatrixAlternativeMatrix);
|
||||
return transposed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Aggregates AHPMatrix into one matrix using geometric mean.
|
||||
*
|
||||
* @param preferences the preferences
|
||||
* @return the AHP aggregated matrix
|
||||
*/
|
||||
private AHPAggregatedMatrix aggregatedMatrix(AHPMatrix[] preferences) {
|
||||
AHPAggregatedMatrix aggregatedMatrix = ContextInjectionFactory.make(AHPAggregatedMatrix.class, context);
|
||||
aggregatedMatrix.aggregate(preferences);
|
||||
return aggregatedMatrix;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the criteria priorities.
|
||||
*
|
||||
* @return the criteria priorities
|
||||
*/
|
||||
public double[] getCriteriaPriorities() {
|
||||
return eigenVectorCriterion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the criteria priorities names.
|
||||
*
|
||||
* @return the criteria priorities names
|
||||
*/
|
||||
public String[] getCriteriaPrioritiesNames() {
|
||||
return Arrays.stream(eigenVectorCriterions).map(k -> k.getName()).sorted().toArray(String[]::new);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the alternatives priorities.
|
||||
*
|
||||
* @return the alternatives priorities
|
||||
*/
|
||||
public double[][] getAlternativesPriorities() {
|
||||
return eigenMatrixAlternative;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the alternative names.
|
||||
*
|
||||
* @return the alternative names
|
||||
*/
|
||||
public String[] getAlternativeNames() {
|
||||
return Arrays.stream(problemService.getAll(Alternative.Type)).map(k -> k.getName()).sorted().toArray(String[]::new);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the result.
|
||||
*
|
||||
* @return the result
|
||||
*/
|
||||
public double[] getResult() {
|
||||
return finalEigenVector;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user