-
Notifications
You must be signed in to change notification settings - Fork 1
/
Base.php
63 lines (57 loc) · 1.93 KB
/
Base.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
namespace afrizalmy\FAHP;
class Base
{
private $kriteria = [];
private $nilai_pasti;
private $metrics = [];
private function create_matric(array $data){
// $this->nilai_pasti = json_encode([1,1,1]);
$pair_wise = array();
for ($i=0; $i <= count($this->kriteria)-1 ; $i++) {
$gate = 0;
$tmpgate = $i + 1;
for ($j=$i; $j <= count($this->kriteria)-1; $j++) {
// printf($j);
if ($gate == 0) {
$pair_wise[$i][$i] = $this->nilai_pasti;
} else {
if ($i > 0) {
// echo $i," | ",$tmpgate, " , ";
$pair_wise[$i][$tmpgate] = $data[$i][$tmpgate];
$tmpgate++;
} else {
$pair_wise[$i][$gate] = $data[$i][$gate];
}
}
$gate++;
}
// printf("\n");
}
$this->metrics = $pair_wise;
return $this->metrics;
}
/**
*
* Fungsi ini untuk membuat matriks yang nantinya akan di proses perhitungan fuzzy pair wise
*
* @param array $inputan adalah data kriteria
* @param array $data_array adalah data dari matriks
* @param int $nilai adalah nilai kepastian
*
* @return array berupa array object seperti kriteria, nilai_pasti dan matriks
*/
public function buat_metric(array $inputan, array $data_array, $nilai)
{
$this->kriteria = $inputan;
$this->sum_kriteria = count($inputan);
$this->nilai_pasti = $nilai;
$array_kosong = $this->create_matric($data_array);
$parsing = [];
$parsing["kriteria"] = $this->kriteria;
$parsing["nilai_pasti"] = $this->nilai_pasti;
$parsing["matriks"] = $this->metrics;
// var_dump($parsing);
return $parsing;
}
}