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.electre.phase.destillation.gathering</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<packaging>eclipse-plugin</packaging>
|
||||
<name>[bundle] Gathering</name>
|
||||
</project>
|
||||
@@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>flintstones.method.electre.phase.destillation.gathering</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>1779484362663</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,12 @@
|
||||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: Gathering
|
||||
Bundle-SymbolicName: flintstones.method.electre.phase.destillation.gathering;singleton:=true
|
||||
Bundle-Version: 1.0.0.qualifier
|
||||
Automatic-Module-Name: flintstones.method.electre.phase.destillation.gathering
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
|
||||
Export-Package: flintstones.method.electre.phase.destillation.gathering
|
||||
Require-Bundle: org.eclipse.e4.core.contexts,
|
||||
flintstones.entity.problemelement,
|
||||
javax.inject,
|
||||
flintstones.entity.method.phase
|
||||
@@ -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.electre.phase.destillation.gathering"
|
||||
implementation="flintstones.method.electre.phase.destillation.gathering.DestillationModel">
|
||||
</phase>
|
||||
</extension>
|
||||
|
||||
</plugin>
|
||||
+616
@@ -0,0 +1,616 @@
|
||||
package flintstones.method.electre.phase.destillation.gathering;
|
||||
|
||||
public class DestilationAlgorithm {
|
||||
|
||||
double cut_k;
|
||||
double alfa;
|
||||
double beta;
|
||||
|
||||
int[] A; //Set Ak={a1, a2, ..., am} Elements remain the credebility matrix.
|
||||
int[] D;
|
||||
int[] power;
|
||||
int[] weakness;
|
||||
int[] qualification;
|
||||
|
||||
int[] posDis_asc;
|
||||
int[] posDis_des;
|
||||
int[] posTem;
|
||||
int[] dif_des_asc;
|
||||
int[] sum_medianPreorder;
|
||||
int[] sum_incomparability;
|
||||
int[] sum_equivalent;
|
||||
int[] medianPreorder;
|
||||
|
||||
//Variables importantes.
|
||||
int elements_in_D;
|
||||
int cardA;
|
||||
|
||||
int nalternatives;
|
||||
double [][]sigma_matrix;
|
||||
int[][] crisp_OR; //crisp outranking relation aSb
|
||||
|
||||
int []rankingAsc;
|
||||
int []rankingDesc;
|
||||
|
||||
public DestilationAlgorithm(double[][] sigma_matrix, int numAleternativas, double alfa, double beta){
|
||||
//Problem
|
||||
this.sigma_matrix = sigma_matrix;
|
||||
this.nalternatives = numAleternativas;
|
||||
|
||||
this.alfa = alfa;
|
||||
this.beta = beta;
|
||||
}
|
||||
|
||||
void inicializar() {
|
||||
//initialize variables
|
||||
this.A = new int[nalternatives];
|
||||
this.D = new int[nalternatives];
|
||||
crisp_OR = new int[nalternatives][nalternatives];
|
||||
|
||||
this.power = new int[nalternatives];
|
||||
this.weakness= new int[nalternatives];
|
||||
this.qualification= new int[nalternatives];
|
||||
|
||||
// Initially every element belongs to credibility matrix
|
||||
for (int i=0; i < nalternatives; i++)
|
||||
A[i] = 1;
|
||||
}
|
||||
|
||||
//Descending Distillation
|
||||
//------------------------------------
|
||||
public void distillation_Des(double alpha, double betha) {
|
||||
|
||||
double s_cut_k;
|
||||
int i, posDistillation, count;
|
||||
int count_outrankings;
|
||||
|
||||
inicializar();
|
||||
|
||||
cardA = nalternatives;
|
||||
|
||||
posDistillation = 1;
|
||||
|
||||
while (cardA > 1) {
|
||||
|
||||
D_equal_to_A();
|
||||
|
||||
cut_k = find_highest(); // lambda_0
|
||||
|
||||
s_cut_k = alpha * cut_k + betha; // lambda_1
|
||||
|
||||
// Se busca la relación mayor debajo de un valor de corte //lambda_1
|
||||
// Este corresponde al siguiente nivel de corte
|
||||
// Max(aSb) < ( cut_k - s_cut_k )
|
||||
cut_k = find_distillation_threshold(cut_k - s_cut_k); // lambda_2
|
||||
|
||||
// Construye la matriz crisp con el nivel de corte cut_k
|
||||
// aSB > cut_k && ( aSB < bSa + (alpha * aSb + betha) )
|
||||
count_outrankings = crisp_outranking_relation(alpha, betha);
|
||||
if (count_outrankings > 0) {
|
||||
calculate_qualification();
|
||||
obtain_maximum_qualification();
|
||||
}
|
||||
|
||||
if (elements_in_D == 1 || cut_k == 0) {
|
||||
|
||||
// take of elements from A which are in D
|
||||
// A = A \ D
|
||||
A_minus_C();
|
||||
|
||||
count = 0;
|
||||
for (i = 0; i < nalternatives; i++) {
|
||||
|
||||
if (D[i] == 1) {
|
||||
posDis_des[i] = posDistillation;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
posDistillation += count;
|
||||
|
||||
} else {
|
||||
|
||||
while (elements_in_D > 1 && cut_k != 0) {
|
||||
s_cut_k = alpha * cut_k + betha;
|
||||
cut_k = find_distillation_threshold(cut_k - s_cut_k);
|
||||
|
||||
count_outrankings = crisp_outranking_relation(alpha, betha);
|
||||
|
||||
if (count_outrankings > 0) {
|
||||
calculate_qualification();
|
||||
obtain_maximum_qualification();
|
||||
}
|
||||
|
||||
if (elements_in_D == 1 || cut_k == 0) {
|
||||
// take of elements from A which are in D
|
||||
// A = A \ D
|
||||
A_minus_C();
|
||||
|
||||
count = 0;
|
||||
|
||||
for (i = 0; i < nalternatives; i++) {
|
||||
|
||||
if (D[i] == 1) {
|
||||
posDis_des[i] = posDistillation;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
posDistillation += count;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // end while
|
||||
|
||||
|
||||
if (cardA == 1) {
|
||||
for (i = 0; i < nalternatives; i++)
|
||||
if (A[i] == 1)
|
||||
posDis_des[i] = posDistillation;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Ascending Distillation
|
||||
//------------------------------------
|
||||
public void distillation_Asc(double alpha, double betha) {
|
||||
|
||||
double s_cut_k;
|
||||
int posOrd, posAsc, count;
|
||||
int count_outrankings;
|
||||
|
||||
inicializar();
|
||||
|
||||
cardA = nalternatives;
|
||||
|
||||
posOrd = 1;
|
||||
|
||||
while (cardA > 1) {
|
||||
|
||||
// Distilation 1
|
||||
// k=0
|
||||
D_equal_to_A();
|
||||
|
||||
cut_k = find_highest();
|
||||
|
||||
s_cut_k = alpha * cut_k + betha;
|
||||
|
||||
cut_k = find_distillation_threshold(cut_k - s_cut_k);
|
||||
|
||||
count_outrankings = crisp_outranking_relation(alpha, betha);
|
||||
if (count_outrankings > 0) {
|
||||
calculate_qualification();
|
||||
obtain_minimum_qualification();
|
||||
}
|
||||
|
||||
if (elements_in_D == 1 || cut_k == 0) {
|
||||
// take of elements from A which are in D
|
||||
// A = A \ D
|
||||
A_minus_C();
|
||||
|
||||
for (int i = 0; i < nalternatives; i++)
|
||||
if (D[i] == 1)
|
||||
posTem[i] = posOrd;
|
||||
|
||||
posOrd++;
|
||||
|
||||
} else {
|
||||
|
||||
while (elements_in_D > 1 && cut_k != 0) {
|
||||
s_cut_k = alpha * cut_k + betha;
|
||||
cut_k = find_distillation_threshold(cut_k - s_cut_k);
|
||||
|
||||
count_outrankings = crisp_outranking_relation(alpha, betha);
|
||||
|
||||
if (count_outrankings > 0) {
|
||||
calculate_qualification();
|
||||
obtain_minimum_qualification();
|
||||
}
|
||||
|
||||
if (elements_in_D == 1 || cut_k == 0) {
|
||||
// take of elements from A which are in D
|
||||
// A = A \ D
|
||||
A_minus_C();
|
||||
|
||||
for (int i = 0; i < nalternatives; i++)
|
||||
if (D[i] == 1)
|
||||
posTem[i] = posOrd;
|
||||
|
||||
posOrd++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // end while
|
||||
|
||||
if (cardA == 1) {
|
||||
// find the remaining alternative
|
||||
for (int i = 0; i < nalternatives; i++)
|
||||
if (A[i] == 1)
|
||||
// assign remaining alternative the position of the pre-order
|
||||
posTem[i] = posOrd;
|
||||
|
||||
posOrd++;
|
||||
|
||||
}
|
||||
|
||||
// convert the temporal position to the final position in ascending pre-order
|
||||
// as the ascending pre-order is in opposite side (down-up)
|
||||
// we change the side to up-down, then best alternatives will be in top position
|
||||
// on asc preorder
|
||||
posAsc = 1;
|
||||
for (; posOrd > 0; posOrd--) {
|
||||
count = 0;
|
||||
|
||||
for (int i = 0; i < nalternatives; i++) {
|
||||
if (posTem[i] == posOrd) {
|
||||
posDis_asc[i] = posAsc;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
posAsc += count;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Intersect des and asc pre-orders (distillation results)
|
||||
//count the strict preferences between alternatives from both pre-orders
|
||||
public int[] median_preOrder(){
|
||||
int[] tot_preOrder = new int[nalternatives];
|
||||
int bucket=0;
|
||||
int mayor, posMayor, vTemp, pTemp;
|
||||
|
||||
//arrays for positions of alternatives for asc and des pre-orders
|
||||
posDis_asc = new int[nalternatives];
|
||||
posDis_des = new int[nalternatives];
|
||||
posTem = new int[nalternatives];
|
||||
dif_des_asc = new int[nalternatives];
|
||||
|
||||
//array for counting the strict preferences between alternatives from both pre-orders
|
||||
sum_medianPreorder = new int[nalternatives];
|
||||
sum_incomparability = new int[nalternatives];
|
||||
sum_equivalent = new int[nalternatives];
|
||||
medianPreorder = new int[nalternatives];
|
||||
|
||||
for (int j=0; j<nalternatives; j++){
|
||||
sum_medianPreorder[j]=0;
|
||||
sum_incomparability[j]=0;
|
||||
sum_equivalent[j]=0;
|
||||
|
||||
medianPreorder[j]=j;
|
||||
}
|
||||
|
||||
distillation_Des(alfa, beta);
|
||||
|
||||
distillation_Asc(alfa, beta);
|
||||
|
||||
rankingAsc = posDis_asc;
|
||||
rankingDesc = posDis_des;
|
||||
|
||||
for (int j=0; j < nalternatives; j++){
|
||||
if( posDis_des[j] > posDis_asc[j] ) {
|
||||
dif_des_asc[j] = posDis_des[j] - posDis_asc[j];
|
||||
} else {
|
||||
dif_des_asc[j] = posDis_asc[j] - posDis_des[j];
|
||||
}
|
||||
}
|
||||
|
||||
//instersection between pre-orders
|
||||
for (int i=0; i<nalternatives; i++){
|
||||
for (int j=0; j<nalternatives; j++){
|
||||
if(i!=j){
|
||||
//find the strict preferences
|
||||
//a is better rank in one order and a is at least as good as b
|
||||
if( (posDis_des[i] < posDis_des[j] && posDis_asc[i] <= posDis_asc[j]) ||
|
||||
(posDis_des[i] <= posDis_des[j] && posDis_asc[i] < posDis_asc[j])) {
|
||||
sum_medianPreorder[i]++;
|
||||
}
|
||||
|
||||
//find incomparability
|
||||
if( (posDis_des[i] < posDis_des[j] && posDis_asc[i] > posDis_asc[j]) ||
|
||||
(posDis_des[i] > posDis_des[j] && posDis_asc[i] < posDis_asc[j]) ){
|
||||
sum_incomparability[i]++;
|
||||
}
|
||||
|
||||
//find equivalent
|
||||
if( posDis_des[i] == posDis_des[j] && posDis_asc[i] == posDis_asc[j] ){
|
||||
sum_equivalent[i]++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//ordering alternatives
|
||||
for (int i=0; i<nalternatives-1; i++){
|
||||
|
||||
mayor=sum_medianPreorder[i];
|
||||
posMayor=i;
|
||||
|
||||
for (int j=i+1; j<nalternatives; j++){
|
||||
if( sum_medianPreorder[j] > mayor){
|
||||
mayor= sum_medianPreorder[j];
|
||||
posMayor=j;
|
||||
}
|
||||
}
|
||||
|
||||
vTemp=sum_medianPreorder[i];
|
||||
|
||||
sum_medianPreorder[i]= mayor;
|
||||
sum_medianPreorder[posMayor]= vTemp;
|
||||
|
||||
|
||||
pTemp=medianPreorder[i];
|
||||
medianPreorder[i] = medianPreorder[posMayor];
|
||||
medianPreorder[posMayor]= pTemp;
|
||||
|
||||
}
|
||||
|
||||
//distinguishing according to their rank difference
|
||||
for (int j=0; j<nalternatives-1; j++){
|
||||
//they are not in the same bucket
|
||||
if( posDis_des[ medianPreorder[j] ] != posDis_des[ medianPreorder[j+1] ] ||
|
||||
posDis_asc[ medianPreorder[j] ] != posDis_asc[ medianPreorder[j+1] ] ) {
|
||||
|
||||
//if both orders have the same rank
|
||||
if( sum_medianPreorder[j] == sum_medianPreorder[j+1] ){
|
||||
if( dif_des_asc[ medianPreorder[j] ] > dif_des_asc[ medianPreorder[j+1] ] ){
|
||||
pTemp=medianPreorder[j];
|
||||
medianPreorder[j] = medianPreorder[j+1];
|
||||
medianPreorder[j+1] = pTemp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bucket = 0;
|
||||
for (int j=0; j<nalternatives; j++){
|
||||
tot_preOrder[ medianPreorder[j] ] = bucket;
|
||||
|
||||
if(j+1 < nalternatives ){
|
||||
//they are not in the same bucket
|
||||
if( posDis_des[ medianPreorder[j] ] != posDis_des[ medianPreorder[j+1] ] ||
|
||||
posDis_asc[ medianPreorder[j] ] != posDis_asc[ medianPreorder[j+1] ] ) {
|
||||
bucket++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return tot_preOrder;
|
||||
}
|
||||
|
||||
//Intersect des and asc pre-orders (distillation results)
|
||||
//count the strict preferences between alternatives from both pre-orders
|
||||
public void parcial_preOrder(int [][]pp_matrix){
|
||||
posDis_asc = new int[nalternatives];
|
||||
posDis_des = new int[nalternatives];
|
||||
posTem = new int[nalternatives];
|
||||
dif_des_asc = new int[nalternatives];
|
||||
|
||||
distillation_Des(alfa, beta);
|
||||
|
||||
distillation_Asc(alfa, beta);
|
||||
|
||||
|
||||
for (int j=0; j<nalternatives; j++){
|
||||
if( posDis_des[j] > posDis_asc[j] )
|
||||
dif_des_asc[j] = posDis_des[j] - posDis_asc[j];
|
||||
else
|
||||
dif_des_asc[j] = posDis_asc[j] - posDis_des[j];
|
||||
}
|
||||
|
||||
|
||||
//instersection between pre-orders
|
||||
for (int i=0; i<nalternatives; i++){
|
||||
for (int j=0; j<nalternatives; j++){
|
||||
if(i!=j){
|
||||
/*
|
||||
P -> 0
|
||||
P- -> 1
|
||||
R -> 2
|
||||
I -> 3
|
||||
*/
|
||||
|
||||
//find the strict preferences
|
||||
//a is better rank in one order and a is at least as good as b
|
||||
if( (posDis_des[i] < posDis_des[j] && posDis_asc[i] <= posDis_asc[j]) ||
|
||||
(posDis_des[i] <= posDis_des[j] && posDis_asc[i] < posDis_asc[j]) ){
|
||||
|
||||
//printf("P\t");
|
||||
pp_matrix[i][j] = 0;
|
||||
}
|
||||
|
||||
//a is worse ranked in one order and a is at least as good as b
|
||||
if( (posDis_des[i] > posDis_des[j] && posDis_asc[i] >= posDis_asc[j]) ||
|
||||
(posDis_des[i] >= posDis_des[j] && posDis_asc[i] > posDis_asc[j]) ){
|
||||
//printf("P-\t");
|
||||
pp_matrix[i][j] = 1;
|
||||
}
|
||||
|
||||
//find equivalent
|
||||
if( posDis_des[i] == posDis_des[j] && posDis_asc[i] == posDis_asc[j] )
|
||||
pp_matrix[i][j] = 2;
|
||||
|
||||
//find incomparability
|
||||
if( (posDis_des[i] < posDis_des[j] && posDis_asc[i] > posDis_asc[j]) ||
|
||||
(posDis_des[i] > posDis_des[j] && posDis_asc[i] < posDis_asc[j]) ){
|
||||
pp_matrix[i][j] = 3;
|
||||
}
|
||||
|
||||
} else {
|
||||
pp_matrix[i][j] = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public int[] getRankingAsc() {
|
||||
return this.rankingAsc;
|
||||
}
|
||||
|
||||
public int[] getRankingDes() {
|
||||
return this.rankingDesc;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//Funciones privadas
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
private double find_highest() {
|
||||
double highest = 0;
|
||||
|
||||
for (int i = 0; i < nalternatives; i++) {
|
||||
|
||||
for (int j = 0; j < nalternatives; j++) {
|
||||
|
||||
if (j != i)
|
||||
if (sigma_matrix[i][j] > highest)
|
||||
highest = sigma_matrix[i][j];
|
||||
}
|
||||
}
|
||||
|
||||
return highest;
|
||||
|
||||
}
|
||||
|
||||
private double find_distillation_threshold(double cut_level) {
|
||||
// find the richest credibility degree lower than cut_level
|
||||
double highest = 0;
|
||||
|
||||
for (int i = 0; i < nalternatives; i++) {
|
||||
|
||||
for (int j = 0; j < nalternatives; j++) {
|
||||
|
||||
if (j != i)
|
||||
if (sigma_matrix[i][j] < cut_level && sigma_matrix[i][j] > highest)
|
||||
highest = sigma_matrix[i][j];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return highest;
|
||||
}
|
||||
|
||||
private void D_equal_to_A() {
|
||||
elements_in_D = 0;
|
||||
|
||||
for (int i = 0; i < nalternatives; i++) {
|
||||
D[i] = A[i];
|
||||
elements_in_D++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void A_minus_C() {
|
||||
for (int i = 0; i < nalternatives; i++) {
|
||||
// take of element from A which are in D
|
||||
// A = A \ D
|
||||
if (D[i] == 1) {
|
||||
A[i] = 0;
|
||||
cardA--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void calculate_qualification() {
|
||||
for (int i = 0; i < nalternatives; i++) {
|
||||
power[i] = 0;
|
||||
weakness[i] = 0;
|
||||
qualification[i] = 0;
|
||||
}
|
||||
|
||||
for (int i = 0; i < nalternatives; i++) {
|
||||
|
||||
for (int j = 0; j < nalternatives; j++) {
|
||||
|
||||
if (j != i) {
|
||||
if (crisp_OR[i][j] == 1) {
|
||||
power[i]++;
|
||||
weakness[j]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < nalternatives; i++)
|
||||
qualification[i] = power[i] - weakness[i];
|
||||
|
||||
}
|
||||
|
||||
private int crisp_outranking_relation(double alpha, double betha) {
|
||||
int No_COR = 0;
|
||||
|
||||
// initialize the matrix
|
||||
for (int i = 0; i < nalternatives; i++)
|
||||
for (int j = 0; j < nalternatives; j++)
|
||||
crisp_OR[i][j] = 0;
|
||||
|
||||
// find crisp relation
|
||||
for (int i = 0; i < nalternatives; i++) {
|
||||
for (int j = 0; j < nalternatives; j++) {
|
||||
if (j != i) {
|
||||
if (sigma_matrix[i][j] > cut_k) {
|
||||
if (sigma_matrix[i][j] > sigma_matrix[j][i] + (alpha * sigma_matrix[i][j] + betha)) {
|
||||
crisp_OR[i][j] = 1;
|
||||
No_COR++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return No_COR;
|
||||
}
|
||||
|
||||
void obtain_maximum_qualification() {
|
||||
int maximum = qualification[0];
|
||||
|
||||
for (int i = 1; i < nalternatives; i++)
|
||||
if (D[i] == 1)
|
||||
if (qualification[i] > maximum)
|
||||
maximum = qualification[i];
|
||||
|
||||
// initialize D to be obtained again
|
||||
for (int i = 0; i < nalternatives; i++)
|
||||
D[i] = 0;
|
||||
|
||||
elements_in_D = 0;
|
||||
// find the bests qualifications, Next D
|
||||
for (int i = 0; i < nalternatives; i++) {
|
||||
if (qualification[i] == maximum) {
|
||||
D[i] = 1;
|
||||
elements_in_D++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void obtain_minimum_qualification() {
|
||||
int minimum = qualification[0];
|
||||
|
||||
for (int i = 1; i < nalternatives; i++)
|
||||
if (D[i] == 1)
|
||||
if (qualification[i] < minimum)
|
||||
minimum = qualification[i];
|
||||
|
||||
// initialize D to be obtained again
|
||||
for (int i = 0; i < nalternatives; i++)
|
||||
D[i] = 0;
|
||||
|
||||
elements_in_D = 0;
|
||||
// find the bests qualifications, Next D
|
||||
for (int i = 0; i < nalternatives; i++) {
|
||||
if (qualification[i] == minimum) {
|
||||
D[i] = 1;
|
||||
elements_in_D++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
package flintstones.method.electre.phase.destillation.gathering;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.eclipse.e4.core.contexts.IEclipseContext;
|
||||
import flintstones.entity.method.phase.PhaseMethod;
|
||||
import flintstones.entity.problemelement.entities.Alternative;
|
||||
|
||||
public class DestillationModel extends PhaseMethod {
|
||||
|
||||
@Inject
|
||||
IEclipseContext context;
|
||||
|
||||
int []rankingAsc;
|
||||
int []rankingDesc;
|
||||
int []rankingFinalRanking;
|
||||
|
||||
Alternative[] allAlternativas;
|
||||
double[][] fuzzyRelation; // Alternativas frente alternativas
|
||||
|
||||
public DestillationModel() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Electre 3: Destillation Result";
|
||||
}
|
||||
|
||||
public void importarDatos() {
|
||||
allAlternativas = (Alternative[]) this.importData("alternativas");
|
||||
fuzzyRelation = (double[][]) this.importData("fuzzyRelation");
|
||||
}
|
||||
|
||||
public void executeDestillation(double alfa, double beta) {
|
||||
DestilationAlgorithm dA = new DestilationAlgorithm(fuzzyRelation, allAlternativas.length, alfa, beta);
|
||||
|
||||
rankingFinalRanking = dA.median_preOrder();
|
||||
rankingAsc = dA.getRankingAsc();
|
||||
rankingDesc = dA.getRankingDes();
|
||||
}
|
||||
|
||||
public int[] getRankingAsc() {
|
||||
return this.rankingAsc;
|
||||
}
|
||||
|
||||
public int[] getRankingDes() {
|
||||
return this.rankingDesc;
|
||||
}
|
||||
|
||||
public int[] getFinalRanking() {
|
||||
return this.rankingFinalRanking;
|
||||
}
|
||||
|
||||
public Alternative[] getAlternativas() {
|
||||
return allAlternativas;
|
||||
}
|
||||
|
||||
public String[] getAlternativasNames() {
|
||||
String[] str = new String[allAlternativas.length];
|
||||
|
||||
for(int i = 0; i < allAlternativas.length; i++)
|
||||
str[i] = allAlternativas[i].getCanonicalName();
|
||||
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user