Skip to content

Commit

Permalink
Few modifications to the Java files
Browse files Browse the repository at this point in the history
  • Loading branch information
dawand committed Jun 6, 2019
1 parent a732c0b commit 02d747e
Show file tree
Hide file tree
Showing 14 changed files with 37 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 9 additions & 13 deletions AHP_Fuzzy_TOPSIS.iml
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://$USER_HOME$/Downloads/commons-math3-3.6.1 2/commons-math3-3.6.1.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="library" name="Maven: org.apache.commons:commons-math3:3.6.1" level="project" />
</component>
</module>
13 changes: 7 additions & 6 deletions src/AHP.java → src/main/java/AHP.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
}
Expand Down Expand Up @@ -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++) {
Expand Down Expand Up @@ -126,6 +126,7 @@ int[] getIndicesForPairwiseComparison(int arrayIdx) {
* @return resulting weights for alternatives
*/
double[] getWeights() {
final double[] weights = this.weights;
return weights;
}

Expand Down
4 changes: 2 additions & 2 deletions src/Config.java → src/main/java/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
File renamed without changes.
6 changes: 1 addition & 5 deletions src/Test.java → src/main/java/Test.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
12 changes: 6 additions & 6 deletions src/Topsis.java → src/main/java/Topsis.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@
import java.util.Map;
import java.util.TreeMap;

public class Topsis {
class Topsis {

private HashMap<String, ArrayList<Double>> sitesMatrix;
private HashMap<String, ArrayList<Fuzzy>> availableSites;
private ArrayList<Fuzzy> 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);
Expand Down Expand Up @@ -47,7 +47,7 @@ private HashMap<String, ArrayList<Double>> calculateFuzzyTopsis(HashMap<String,

System.out.println(entry);

ArrayList<Double> weightedMatrix = new ArrayList<>();
ArrayList<Double> weightedMatrix = new ArrayList<Double>();

for (int k = 0; k < entry.getValue().size(); k++) {
for (double fuzzyValue:entry.getValue().get(k).getValue()) {
Expand Down Expand Up @@ -112,7 +112,7 @@ else if (node.equalsIgnoreCase(Config.alternatives[1])) { // Edge
private HashMap<String, Double> calculateDistance(HashMap<String, ArrayList<Double>> 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<String, Double> results = new HashMap<>();

for (Map.Entry<String,ArrayList<Double>> entry: sitesMatrix.entrySet()) {
Expand Down
Binary file added target/classes/AHP.class
Binary file not shown.
Binary file added target/classes/Config.class
Binary file not shown.
Binary file added target/classes/Fuzzy.class
Binary file not shown.
Binary file added target/classes/Test.class
Binary file not shown.
Binary file added target/classes/Topsis.class
Binary file not shown.

0 comments on commit 02d747e

Please sign in to comment.