LAMPIRAN A
LISTING PROGRAM
Function.php require_once("settings.php"); function query($q){ return mysql_query($q); } function fetch($q){ return mysql_fetch_object($q); } function num_rows($q){ return mysql_num_rows($q); } function loadMHS($id=NULL, $start=NULL, $limit=NULL){ $id = ($id==NULL) ? '' : "WHERE NIM = '$id'"; $num = ($start==NULL or $start==0) ? '' : "LIMIT $start, $limit"; $q = query("SELECT * FROM tbl_mhs $id ORDER BY ID ASC $num"); return $q; } function getMhs($id=1){ $k = 1; $criteria = array("", "IPK", "KT", "Keg", "English"); $query = query("SELECT Id, Nama, ".$criteria[$id]." FROM tbl_mhs ORDER BY ID ASC"); while($q = mysql_fetch_array($query)): $mhs[$k][1] = $q[$criteria[$id]]; $mhs[$k][2] = $q['Nama']; $k++; endwhile; return $mhs; } function inputMatriks($id){
Universitas Sumatera Utara
102
$b = getNumRows(); if($id==1) $range = array(1, 2, 2, 3, 4, 4, 5, 6, 6, 7, 8, 8, 9); else $range = array(0=>1, 5=>2, 10=>3, 15=>4, 20=>5, 25=>6, 30=>7, 35=>8, 40=>9); $mhs = getMhs($id); for($i=1; $i<=$tmp; $i++): $col[$i] = 0; endfor; for($i=0; $i<$b; $i++): $data[$i+1][0] = $mhs[$i+1][2]; for($j=0; $j<$b; $j++): $data[0][$j+1] = $mhs[$j+1][2]; if($id==1) $tmp = abs(($mhs[$i+1][1]*10) ($mhs[$j+1][1]*10)); else $tmp = abs($mhs[$i+1][1]-$mhs[$j+1][1]); if(($mhs[$i+1][1]) < ($mhs[$j+1][1])) $data[$i+1][$j+1] = round(1/($range[$tmp]), 4); else $data[$i+1][$j+1] = round($range[$tmp], 4); $col[$j+1] += $data[$i+1][$j+1]; endfor; endfor; for($i=1; $i<=sizeof($col); $i++): $data[sizeof($col)+1][$i] = $col[$i]; endfor; $data[sizeof($col)+1][0] = "Jumlah Kolom"; return $data; } function getNormal($id=1){ // fungsi untuk mendapatkan prioritas kriteria $tmp = getNumRows(); $x = inputMatriks($id); for($i=0; $i<$tmp; $i++): $row[$i+1] = 0; $tbl310[$i+1][0] = $x[$i+1][0]; for($j=0; $j<$tmp; $j++): $tbl310[0][$j+1] = $x[$j+1][0];
Universitas Sumatera Utara
103
$tbl310[$i+1][$j+1] = round($x[$i+1][$j+1] / $x[$tmp+1][$j+1], 4); $row[$i+1] += $tbl310[$i+1][$j+1]; $tbl310[$i+1][$tmp+1] = $row[$i+1]; endfor; endfor; $tbl310[0][$tmp+1] = "Jumlah Baris";; //$tbl312 = cross($tbl311, $x); /*for($i=1; $i<=sizeof($tbl311); $i++): $tbl313[$i][1] = round($tbl312[$i][1] / $tbl311[$i][1], 4); endfor;*/ return $tbl310; } function getCriteria($id=1){ $tmp = getNumRows(); $x = getNormal($id); for($i=1; $i<=$tmp; $i++): $data[$i][1] = $x[0][$i]; $data[$i][2] = round($x[$i][$tmp+1] / $tmp, 4); endfor; return $data; } function param1($id=1){ $tmp = getNumRows(); $x = getNormal($id); for($i=1; $i<=1; $i++): for($j=1; $j<=$tmp; $j++): //$data[$i][1] = $x[0][$i]; $data[$i][$j] = round($x[$i][$tmp+1] / $tmp, 4); endfor; endfor; return $data; } function getPriority(){ $BO = array(0, 0.0788, 0.5193, 0.2008, 0.2008);
// persetanse
bobot prioritas $tmp = getNumRows(); for($i=1; $i<=4; $i++): $x = getCriteria($i);
Universitas Sumatera Utara
104
for($j=1; $j<=$tmp; $j++): $data[$j][0] = $x[$j][1]; $data[$j][$i] = round($x[$j][2] * $BO[$i], 4); // prioritas setelah dikalikan bobot $x[$j][2]; endfor; endfor; return $data; } function getGlobal(){ // fungsi nilai prioritas global $x = getPriority(); $tmp = getNumRows(); for($i=1; $i<=$tmp; $i++): $data[$i][1] = 0; $data[$i][0] = $x[$i][0]; for($j=1; $j<=4; $j++): $data[$i][1] += $x[$i][$j]; endfor; endfor; return $data; } function bubbleSort($x){ for($i=1; $i<=sizeof($x)-1; $i++): for($j=$i+1; $j<=sizeof($x); $j++): if($x[$i][1] < $x[$j][1]): $tmp[0] = $x[$i][0]; $tmp[1] = $x[$i][1]; $x[$i][0] = $x[$j][0]; $x[$i][1] = $x[$j][1]; $x[$j][0] = $tmp[0]; $x[$j][1] = $tmp[1]; endif; endfor; endfor; return $x; } function uMaks($a){ // fungsi untuk memperoleh rataan $total = 0; for($i=1; $i<=sizeof($a); $i++): $total += round($a[$i][1], 4); endfor;
Universitas Sumatera Utara
105
return round($total / sizeof($a), 4); } function cross2($a, $b){ // fungsi untuk mengalikan matriks $c = getNumRows(); for($i=1; $i<=$c; $i++): for($j=1; $j<=1; $j++): $tmp[$i][$j] = 0; for($k=1; $k<=$c; $k++): $tmp[$i][$j] += round($a[$i][$k] * $b[$k][2], 4); endfor; endfor; endfor; return $tmp; } function consistent($id){ $tmp = getNumRows(); $RI = array(0, 0.0, 0.0, 0.58, 0.90, 0.12, 1.24, 1.32, 1.41, 1.45, 1.49, 1.51, 1.48, 1.56, 1.57, 1.59); // Random Indeks $q = cross2(inputMatriks($id), getCriteria($id)); $r = getCriteria($id); $jlh = 0; for($i=1; $i<=$tmp; $i++): $p[$i] = round($q[$i][1] / $r[$i][2], 4); $jlh += $p[$i]; endfor; print_r($p); echo "Jumlah = ".$jlh."
"; $a = $jlh/$tmp; echo "A = ".$jlh." / ".$tmp." = ".$a."
"; $b = ($a-13)/($tmp-1); echo "B = (".$a." - ".$tmp.") / ".($tmp-1)." = ".$b."
"; echo "C = ".$b." / ".$RI[$tmp]." = ".$b/$RI[$tmp]."
"; } function getNumRows($id=NULL){ $q = num_rows(query("SELECT * FROM tbl_mhs")); return $q; }
Universitas Sumatera Utara
106
LoadContents.php require_once("functions.php"); $a = ($_REQUEST['a'] != 'null' AND $_REQUEST['a'] != 'undefined') ? $_REQUEST['a'] : '1'; $b = ($_REQUEST['b']) ? $_REQUEST['b'] : '0'; $c = ($_REQUEST['c']) ? $_REQUEST['c'] : LIMIT; if($a==1): $query = loadMHS(NULL, $b, $c);
| IPK | Karya Tulis | Kegiatan | Bahasa Inggris / Asing |
IPK | 1 | 1/5 | 1/3 | 1/3 |
Karya Tulis | 5 | 1 | 3 | 3 |
Kegiatan |
Universitas Sumatera Utara
108
3 | 1/3 | 1 | 1 |
Bahasa Inggris / Asing | 3 | 1/3 | 1 | 1 |
Jumlah Kolom | 12 | 1.8666 | 5.3333 | 5.3333 |
| IPK | Karya Tulis | Kegiatan | Bahasa Inggris / Asing | Jumlah Baris |
IPK | 0.0833 | 0.1071 | 0.0624 | 0.0624 | 0.3152 |
Karya Tulis | 0.4166 |
Universitas Sumatera Utara
109
0.5357 | 0.5625 | 0.5625 | 2.0773 |
Kegiatan | 0.25 | 0.1785 | 0.1875 | 0.1875 | 0.8035 |
Bahasa Inggris / Asing | 0.25 | 0.1785 | 0.1875 | 0.1875 | 0.8035 |
Kriteria | Bobot Prioritas |
IPK | 0.0788 |
Karya Tulis | 0.5193 |
Kegiatan | 0.2008 |
Universitas Sumatera Utara
110
Bahasa Inggris/Asing | 0.2008 |
1, 2, 3, 4); $cr = array("", "IPK", "Karya Tulis", "Kegiatan", "B. Inggris / Asing"); $tmp = getNumRows(); $x = inputMatriks($p[$a]); $y = getNormal($p[$a]); $z = getCriteria($p[$a]); ?>
Table Perbandingan Kriteria |
| 0) OR ($i>0 AND $j==0)) ? 'class=data' : ''; ?> align="center">'.$x[$i][$j].'' : $x[$i][$j]; ?> |
Universitas Sumatera Utara
111
Table Normalisasi Perbandingan Kriteria |
| 0) OR ($i>0 AND $j==0)) ? 'class=data' : ''; ?> align="center">'.$y[$i][$j].'' : $y[$i][$j]; ?> |
Table Prioritas Kriteria |
No. | Calon Mahasiswa Berprestasi | Prioritas Kriteria |
. | | |
Universitas Sumatera Utara
112
No. | Nama Mahasiswa | IPK | Karya Tulis | Kegiatan | B. Inggris / Asing |
. | | |
Prioritas Global |
width="5%">No. width="">Nama Mahasiswa
Prioritas Global |
Universitas Sumatera Utara
113
. | | |
Hasil Akhir No. | Nama Mahasiswa | Prioritas Global |
. | | |
Universitas Sumatera Utara
114