From 02d747e8090ba079daa911fa255285e047f47151 Mon Sep 17 00:00:00 2001 From: Dawand Sulaiman Date: Thu, 6 Jun 2019 15:30:28 +0100 Subject: [PATCH] Few modifications to the Java files --- .idea/compiler.xml | 2 +- .idea/encodings.xml | 4 ++++ .idea/misc.xml | 7 +++++++ AHP_Fuzzy_TOPSIS.iml | 22 +++++++++------------- src/{ => main/java}/AHP.java | 13 +++++++------ src/{ => main/java}/Config.java | 4 ++-- src/{ => main/java}/Fuzzy.java | 0 src/{ => main/java}/Test.java | 6 +----- src/{ => main/java}/Topsis.java | 12 ++++++------ target/classes/AHP.class | Bin 0 -> 3535 bytes target/classes/Config.class | Bin 0 -> 2403 bytes target/classes/Fuzzy.class | Bin 0 -> 1295 bytes target/classes/Test.class | Bin 0 -> 2767 bytes target/classes/Topsis.class | Bin 0 -> 7248 bytes 14 files changed, 37 insertions(+), 33 deletions(-) create mode 100644 .idea/encodings.xml rename src/{ => main/java}/AHP.java (93%) rename src/{ => main/java}/Config.java (94%) rename src/{ => main/java}/Fuzzy.java (100%) rename src/{ => main/java}/Test.java (93%) rename src/{ => main/java}/Topsis.java (96%) create mode 100644 target/classes/AHP.class create mode 100644 target/classes/Config.class create mode 100644 target/classes/Fuzzy.class create mode 100644 target/classes/Test.class create mode 100644 target/classes/Topsis.class diff --git a/.idea/compiler.xml b/.idea/compiler.xml index fe4c5cf..7cd87f8 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -10,7 +10,7 @@ - + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..15a15b2 --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 0548357..5755a99 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,5 +1,12 @@ + + + diff --git a/AHP_Fuzzy_TOPSIS.iml b/AHP_Fuzzy_TOPSIS.iml index 6603c53..33e33e9 100644 --- a/AHP_Fuzzy_TOPSIS.iml +++ b/AHP_Fuzzy_TOPSIS.iml @@ -1,20 +1,16 @@ - - - + + + + - + + + + - - - - - - - - - + \ No newline at end of file diff --git a/src/AHP.java b/src/main/java/AHP.java similarity index 93% rename from src/AHP.java rename to src/main/java/AHP.java index 01776d1..14db341 100644 --- a/src/AHP.java +++ b/src/main/java/AHP.java @@ -5,22 +5,22 @@ public class AHP { // Random Consistency Index - private static double RI[] = {0.0, 0.0, 0.58, 0.9, 1.12, 1.24, 1.32, 1.41, 1.45, 1.49}; + private static double[] RI = {0.0, 0.0, 0.58, 0.9, 1.12, 1.24, 1.32, 1.41, 1.45, 1.49}; // The matrix private Array2DRowRealMatrix mtx; // Pairwise Comparison Array of criteria - private double pairwiseComparisonArray[]; + private double[] pairwiseComparisonArray; // Number of alternatives private int nrAlternatives; // The resulting weights/priorities - private double weights[]; + private double[] weights; // Corresponds to the weights - private String labels[] = null; + private String[] labels = null; private EigenDecomposition evd; @@ -35,7 +35,7 @@ public class AHP { */ private int evIdx = 0; // index of actual eigenvalue/-vector - AHP(String labels[]) { + AHP(String[] labels) { this(labels.length); this.labels = labels; } @@ -79,7 +79,7 @@ int getNrOfPairwiseComparisons() { * Set the pairwise comparison scores and calculate all relevant numbers * @param a */ - void setPairwiseComparisonArray(double a[]) { + void setPairwiseComparisonArray(double[] a) { int i = 0; for (int row = 0; row < nrAlternatives; row++) { for (int col = row + 1; col < nrAlternatives; col++) { @@ -126,6 +126,7 @@ int[] getIndicesForPairwiseComparison(int arrayIdx) { * @return resulting weights for alternatives */ double[] getWeights() { + final double[] weights = this.weights; return weights; } diff --git a/src/Config.java b/src/main/java/Config.java similarity index 94% rename from src/Config.java rename to src/main/java/Config.java index adfcfde..4b48cfa 100644 --- a/src/Config.java +++ b/src/main/java/Config.java @@ -3,10 +3,10 @@ class Config { // Set your alternatives here - static String alternatives[] = new String[]{"Mobile", "Edge", "Public"}; + static String[] alternatives = new String[]{"Mobile", "Edge", "Public"}; // Set your criteria here - static String criteria[] = new String[]{"Bandwidth", "Speed", "Availability", "Security", "Price"}; + static String[] criteria = new String[]{"Bandwidth", "Speed", "Availability", "Security", "Price"}; // Set true for benefir criterion, false for cost criterion static boolean[] costCriteria = new boolean[]{false, false, false, false, true}; // price is cost diff --git a/src/Fuzzy.java b/src/main/java/Fuzzy.java similarity index 100% rename from src/Fuzzy.java rename to src/main/java/Fuzzy.java diff --git a/src/Test.java b/src/main/java/Test.java similarity index 93% rename from src/Test.java rename to src/main/java/Test.java index 6f8456f..337cd0f 100644 --- a/src/Test.java +++ b/src/main/java/Test.java @@ -1,14 +1,10 @@ -import java.util.HashMap; -import java.util.Map; -import java.util.TreeMap; - public class Test { private void calculateAHP(){ AHP ahp = new AHP(Config.criteria); - double compArray[] = ahp.getPairwiseComparisonArray(); + double[] compArray = ahp.getPairwiseComparisonArray(); // Set the pairwise comparison values compArray[0] = Config.BANDWIDTH_SPEED; diff --git a/src/Topsis.java b/src/main/java/Topsis.java similarity index 96% rename from src/Topsis.java rename to src/main/java/Topsis.java index 5e0266c..84b94bf 100644 --- a/src/Topsis.java +++ b/src/main/java/Topsis.java @@ -5,19 +5,19 @@ import java.util.Map; import java.util.TreeMap; -public class Topsis { +class Topsis { private HashMap> sitesMatrix; private HashMap> availableSites; private ArrayList criteriaImportance; - public Topsis(){ + Topsis(){ criteriaImportance = new ArrayList<>(); - sitesMatrix =new HashMap<>(); + sitesMatrix = new HashMap<>(); availableSites = new HashMap<>(); } - public void start(){ + void start(){ for (String alternative : Config.alternatives) { criteriaImportance = profileNode(alternative); availableSites.put(alternative, criteriaImportance); @@ -47,7 +47,7 @@ private HashMap> calculateFuzzyTopsis(HashMap weightedMatrix = new ArrayList<>(); + ArrayList weightedMatrix = new ArrayList(); for (int k = 0; k < entry.getValue().size(); k++) { for (double fuzzyValue:entry.getValue().get(k).getValue()) { @@ -112,7 +112,7 @@ else if (node.equalsIgnoreCase(Config.alternatives[1])) { // Edge private HashMap calculateDistance(HashMap> sitesMatrix, boolean ideal) { EuclideanDistance distance = new EuclideanDistance(); // The normalized values for the ideal solution and negative ideal solution on criteria are always (1,1,1) and (0,0,0) respectively - Double dValue = 0.0; + double dValue = 0.0; HashMap results = new HashMap<>(); for (Map.Entry> entry: sitesMatrix.entrySet()) { diff --git a/target/classes/AHP.class b/target/classes/AHP.class new file mode 100644 index 0000000000000000000000000000000000000000..a848a71e4b5cff63070bdffc7a76c48632709fda GIT binary patch literal 3535 zcmbVOTX0j?6O~>^>dD zXM}!M1U@Ir=Yx1Ej7ppl_7`OLMOkKLIUB~8a88yl%ks3Cc}C=()gMYR2!4WiE{ta6 z#ne}1_tg;23;mib&+FZPJ%2R%-tW)r-BCOnYzAnNC_}X1`g;*{3=c)=ijpZraXUJqRT*>n=<+x5sn2B1X~ zVnf;Vn|3l>bI!Cv`9Q%;pWJUwxLT}*Lc^$4IFRckMLB5Z_eTz_?23-RtC5 zN62(A4U+YcDd2GvAEwfg8yKkJp@&Gb^93uLo}n>|wc)E7;EKB>QRL84!SNuXP#bNz z6>xm{VTJltH@he8%!nnyKSwKFX`_oTh zvIct5WuOyX1m^$KE@I^c0}tRq13R$IKoSE6wqu*LV#2^~^cc8+iw0iAw-nlM=VLYY z#lyD^JcL~azJtRCzKib}cnL4FU5k?7t zL_GSDU|O0@QrBu45r=N3rp(NwOoFOaOs`?-p+cO>M457-E-n)-AIWK{H#p%6PN_8w z8tb*kE#lkBD#(%3(-Y)F&4~#sJECxJ^d_)+Y3y8$>>K!9Azzx8|6Lw;@@wXPe!-L> zEXC%|CkS*Yq32RU+NA`gONn@w5=Sm2FkMRgldj?a9_)p}!`wYWdp=Sl)_P?DD%Ls= z-_LpW@dl`XpX)vRQj1cr1qq(&JbCQHqdZYlI*itQwA$xcRc#1BUj0`T43TitS+MF${aSucw60EM6FQ%YusLZ3Bl&q5R@YoTvLCp*taYZ z*&e756j8Tbuh*}11pOVMNGKAVL!@4hgxVe~Ygu2G-ZvX!9DnzB=n-9n*Uh1x7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(CSin07GY9Gn8Xn#eS}FOVG>A~G!iD6gh?r35=)r$BGybe>R^U_B0!tydCo9}47YI82+9g-AzJ56AqT!~Y((t&3%a~t+ ze&sS6%kcRwqN$AL0Q_PE0%#RuVE~K7SW=z3E`X&HSr))@F;)h!N{rQ2V@&{SCDK+x zdl~CWSYO755;m66A=p_$R~egRcC$pb2;LyLwS;YD+$eaHhKyi7OuxlnTU_GX%B^+_LBrMh@?T|iq)=I18p7wV$FOP}jvlK@5XDI!@F zk=%+%hKU*C-hlRQ?ww2IxxY2)4Tl znFc`esgd3z=&8{+&|cBrHxMBd=pf@!wBn@DiWA0md@cUsamctVswQDz3e$nLU(_l; zUq3*xqlT<~)NMJkZY%VvF|@27q4f}^Ku;)jlo7@wKHe_y4pra+Qy61L)Mvy5I3Y?~1MM_Ekv+Kv)3TKs+AUkHA!gZH4ROoXYv{BNA@NlFYwV_Z d@U{0-oP~}@)bn%d^abIeU=CMsl{g_>`vbGg<8S}~ literal 0 HcmV?d00001 diff --git a/target/classes/Test.class b/target/classes/Test.class new file mode 100644 index 0000000000000000000000000000000000000000..4dd63a23e72982f5281c2419ca45b76aebea9bc2 GIT binary patch literal 2767 zcmai0`BxiN6#gCrW(ZS?p{2G;8*5ubpA-@Wg?d*9@@zfb)FU3JhWswOY3r9yTh&z#&ML~xvC`B zDrOE@`7!fQnvzi5Nt)?#GjGefA`G}Qc7Yi2F{|M2RxoIiET&D@>f1M>pltqP{2eB| zIg?Xph*Lqsrlga}_2u*CoI>41zru=yYbFoxH*+2`ORs@a!*y~6yRhGKXPgw{_)7&n zKISQi6v&u%R-rvI5uY`Wn7wH;JKdXb^LBQ6x3?iPKg|@|&Z4HX%e)nW38$D(T7$N1 zv`O~TBUlD5!{yAJDQkGrz*86!QQW}Oc*el9cuvFf2427k125t^11|}AS;#9wUKR41 zkk^I0A>>UVZ{ckN@8Dex?-_U>Cl%J5nfu z#1aCsPe59$1sy&#YbBXOBlkaLPqTZHmEZ)Lw%ifZ&L6c4R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