Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- -- ----------------------------
- -- DSS SAW METHOD
- -- CREATED BY : CAHYA DSN
- -- CREATED ON : 2014-12-01
- -- UPDATED ON : 2016-05-18
- -- ----------------------------
- /*
- Metode Simple Additive Weighting (SAW)
- 1 Pengertian Metode Simple Additive Weighting (SAW)
- Metode Simple Additive Weighting (SAW) sering juga dikenal istilah metode penjum
- lahan terbobot. Konsep dasar metode SAW adalah mencari penjumlahan terbobot dari
- rating kinerja pada setiap alternatif pada semua atribut (Fishburn, 1967) (Mac
- Crimmon, 1968). Metode SAW membutuhkan proses normalisasi matriks keputusan (X)
- ke suatu skala yang dapat diperbandingkan dengan semua rating alternatif yang a
- da.Metode ini merupakan metode yang paling terkenal dan paling banyak digunakan
- dalam menghadapi situasi Multiple Attribute Decision Making (MADM). MADM itu sen
- diri merupakan suatu metode yang digunakan untuk mencari alternatif optimal dari
- sejumlah alternatif dengan kriteria tertentu. Metode SAW ini mengharuskan pembuat
- keputusan menentukan bobot bagi setiap atribut. Skor total untuk alternatif dipe
- roleh dengan menjumlahkan seluruh hasil perkalian antara rating (yang dapat diban
- dingkan lintas atribut) dan bobot tiap atribut. Rating tiap atribut haruslah be
- bas dimensi dalam arti telah melewati proses normalisasi matriks sebelumnya.
- 2 Langkah Penyelesaian Simple Additive Weighting (SAW)
- Langkah Penyelesaian SAW sebagai berikut :
- [1] Menentukan kriteria-kriteria yang akan dijadikan acuan dalam pengambilan
- keputusan, yaitu Ci.
- [2] Menentukan rating kecocokan setiap alternatif pada setiap kriteria.
- [3] Membuat matriks keputusan berdasarkan kriteria(Ci), kemudian melakukan norma
- lisasi matriks berdasarkan persamaan yang disesuaikan dengan jenis atribut (atri
- but keuntungan ataupun atribut biaya) sehingga diperoleh matriks ternormalisasi R.
- [4] Hasil akhir diperoleh dari proses perankingan yaitu penjumlahan dari perkalian
- matriks ternormalisasi R dengan vektor bobot sehingga diperoleh nilai terbesar
- yang dipilih sebagai alternatif terbaik (Ai)sebagai solusi.
- Formula untuk melakukan normalisasi tersebut adalah:
- x
- ij
- ------ ; jika j adalah atribut keuntungan
- max x
- ij
- r = {
- ij min x
- ij
- ------ ; jika j adalah atribut biaya
- x
- ij
- Dimana :
- r-ij = rating kinerja ternormalisasi
- Max x-ij = nilai maksimum dari setiap baris dan kolom
- Min x-ij = nilai minimum dari setiap baris dan kolom
- X-ij = baris dan kolom dari matriks
- Dengan r-ij adalah rating kinerja ternormalisasi dari alternatif Ai pada atribut
- Cj; dengan i = 1,2,...,m dan j = 1,2,...,n.
- Nilai preferensi untuk setiap alternatif (Vi) diberikan sebagai :
- V = sigma w r
- i j=1 n j ij
- Dimana :
- V-i = Nilai akhir dari alternatif
- w-j = Bobot yang telah ditentukan
- r-ij = Normalisasi matriks
- Nilai V-i yang lebih besar mengindikasikan bahwa alternatif Ai lebih terpilih
- ================================================================================
- CREATE DATABASE IF NOT EXISTS db_saw;
- USE db_saw;
- DROP TABLE IF EXISTS saw_criterias;
- CREATE TABLE IF NOT EXISTS saw_criterias(
- id_criteria TINYINT(3) UNSIGNED NOT NULL,
- criteria VARCHAR(100) NOT NULL,
- weight FLOAT NOT NULL,
- attribute SET('benefit','cost'),
- PRIMARY KEY(id_criteria)
- )ENGINE=MyISAM;
- INSERT INTO saw_criterias(id_criteria,criteria,weight,attribute)
- VALUES
- (1,'Absen',10,'benefit'),
- (2,'Kerajinan',20,'benefit'),
- (3,'Keahlian',20,'benefit'),
- (4,'Kedisiplinan',20,'benefit'),
- (5,'Kualitas Kerja',20,'benefit'),
- (6,'Penampilan',10,'benefit');
- SELECT * FROM saw_criterias;
- +-------------+----------------+--------+-----------+
- | id_criteria | criteria | weight | attribute |
- +-------------+----------------+--------+-----------+
- | 1 | Absen | 10 | benefit |
- | 2 | Kerajinan | 20 | benefit |
- | 3 | Keahlian | 20 | benefit |
- | 4 | Kedisiplinan | 20 | benefit |
- | 5 | Kualitas Kerja | 20 | benefit |
- | 6 | Penampilan | 10 | benefit |
- +-------------+----------------+--------+-----------+
- 6 rows in set (0.01 sec)
- DROP TABLE IF EXISTS saw_alternatives;
- CREATE TABLE IF NOT EXISTS saw_alternatives(
- id_alternative SMALLINT(5) UNSIGNED NOT NULL AUTO_INCREMENT,
- name VARCHAR(30) NOT NULL,
- PRIMARY KEY(id_alternative)
- ) ENGINE=MyISAM;
- INSERT INTO saw_alternatives(name)
- VALUES
- ('Jono'),
- ('Rika'),
- ('Samuel'),
- ('Lono');
- SELECT * FROM saw_alternatives;
- +----------------+--------+
- | id_alternative | name |
- +----------------+--------+
- | 1 | Jono |
- | 2 | Rika |
- | 3 | Samuel |
- | 4 | Lono |
- +----------------+--------+
- 4 rows in set (0.00 sec)
- DROP TABLE IF EXISTS saw_evaluations;
- CREATE TABLE IF NOT EXISTS saw_evaluations(
- id_alternative SMALLINT(5) UNSIGNED NOT NULL,
- id_criteria TINYINT(3) UNSIGNED NOT NULL,
- value FLOAT NOT NULL,
- PRIMARY KEY (id_alternative,id_criteria)
- )ENGINE=MyISAM;
- INSERT INTO saw_evaluations(id_alternative,id_criteria,value)
- VALUES
- (1,1,70),
- (1,2,80),
- (1,3,70),
- (1,4,60),
- (1,5,80),
- (1,6,70),
- (2,1,70),
- (2,2,80),
- (2,3,85),
- (2,4,78),
- (2,5,80),
- (2,6,70),
- (3,1,70),
- (3,2,70),
- (3,3,85),
- (3,4,60),
- (3,5,70),
- (3,6,80),
- (4,1,65),
- (4,2,70),
- (4,3,70),
- (4,4,60),
- (4,5,70),
- (4,6,100);
- -- perangkingan:
- SELECT
- b.name,
- SUM(
- IF(c.attribute='benefit',
- a.value/c.normalization,
- c.normalization/a.value)
- * c.weight
- ) AS value
- FROM
- saw_evaluations a
- JOIN saw_alternatives b USING(id_alternative)
- JOIN
- (
- SELECT
- a.id_criteria,
- ROUND(IF(b.attribute='benefit',MAX(a.value),MIN(a.value)),1) AS normalization,
- b.attribute,
- b.weight
- FROM
- saw_evaluations a
- JOIN saw_criterias b USING(id_criteria)
- GROUP BY a.id_criteria
- ) c USING(id_criteria)
- GROUP BY a.id_alternative
- ORDER BY value DESC;
- +--------+-------------------+
- | name | value |
- +--------+-------------------+
- | Rika | 97 |
- | Jono | 88.8552036199095 |
- | Samuel | 88.38461538461539 |
- | Lono | 86.14091790562378 |
- +--------+-------------------+
- 4 rows in set (0.05 sec)
- */
- //-- database configuration
- $dbhost='localhost';
- $dbuser='root';
- $dbpass='';
- $dbname='db_dss';
- //-- database connection
- $db=mysqli_connect($dbhost,$dbuser,$dbpass,$dbname);
- ?>
- <!doctype html>
- <html>
- <head>
- <title>DSS SAW Method</title>
- <style>
- * {font-family:verdana,arial,sans-serif;font-size:1em;padding:2px;}
- h1 {font-size:1.5em}
- h2 {font-size:1.2em}
- td,th {min-width:100px;border:solid 1px #999;}
- th {background-color:#99f;}
- table {min-width:600px;}
- .center {text-align:center}
- </style>
- </head>
- <body>
- <h1>DSS SAW Method</h1>
- <h2>
- [1] Menentukan kriteria-kriteria yang akan dijadikan acuan dalam
- pengambilan keputusan, yaitu C<sub>i</sub>
- </h2>
- <p>
- <table>
- <caption>
- Tabel Kriteria C<sub>i</sub>
- </caption>
- <tr>
- <th>No</th>
- <th>Symbol</th>
- <th>Criteria</th>
- <th>Attribute</th>
- </tr>
- <?php
- $sql='SELECT criteria,weight,attribute FROM saw_criterias';
- $result=mysqli_query($db,$sql);
- $i=0;
- while($row=mysqli_fetch_assoc($result)){
- echo "<tr>
- <td class='right'>".(++$i)."</td>
- <td class='center'>C{$i}</td>
- <td>{$row['criteria']}</td>
- <td>{$row['attribute']}</td>
- </tr>\n";
- }
- mysqli_free_result($result);
- ?>
- </table>
- </p>
- <h2>[2] Menentukan rating kecocokan setiap alternatif pada setiap kriteria.</h2>
- <p>
- Teknik pembobotan pada criteria dapat dilakukan dengan beragai macam cara
- dan metode. Fase ini dikenal dengan istilah pra-proses. Namun bisa juga
- dengan cara secara sederhana dengan memberikan nilai pada masing-masing
- secara langsung berdasarkan persentasi nilai bobotnya. Sedangkan untuk yang
- lebih lebih baik bisa digunakan fuzzy logic. Penggunaan Fuzzy logic, sangat
- dianjurkan bila kritieria yang dipilih mempunyai sifat yang relative, misal
- Umur, Panas, Tinggi, Baik atau sifat lainnya
- </p>
- <p>
- <table>
- <caption>
- Rating Kecocokan Alternatif utk setiap Kriteria
- </caption>
- <tr>
- <th rowspan='2'>Alternative</th>
- <th colspan='5'>Criteria</th>
- </tr>
- <tr>
- <th>C1</th>
- <th>C2</th>
- <th>C3</th>
- <th>C4</th>
- <th>C5</th>
- </tr>
- <?php
- $sql="SELECT
- id_alternative,
- SUM(IF(id_criteria=1,value,0)) AS C1,
- SUM(IF(id_criteria=2,value,0)) AS C2,
- SUM(IF(id_criteria=3,value,0)) AS C3,
- SUM(IF(id_criteria=4,value,0)) AS C4,
- SUM(IF(id_criteria=5,value,0)) AS C5
- FROM
- saw_evaluations
- GROUP BY id_alternative
- ORDER BY id_alternative
- ";
- $result=mysqli_query($db,$sql);
- while($row=mysqli_fetch_assoc($result)){
- echo "<tr class='center'>
- <th>A{$row['id_alternative']}</th>
- <td>".round($row['C1'],1)."</td>
- <td>".round($row['C2'],1)."</td>
- <td>".round($row['C3'],1)."</td>
- <td>".round($row['C4'],1)."</td>
- <td>".round($row['C5'],1)."</td>
- </tr>\n";
- }
- mysql_free_result($result);
- ?>
- </table>
- </p>
- <h2>[3] Membuat matrik keputusan berdasarkan Kriteria C<sub>i</sub></h2>
- <p>
- <table>
- <caption>
- Pembobotan Kriteria (w)
- </caption>
- <tr>
- <th>No</th>
- <th>Alternative</th>
- <th>Weight</th>
- </tr>
- <?php
- $sql="SELECT weight FROM saw_criterias ORDER BY id_criteria";
- $result=mysqli_query($db,$sql);
- $i=0;
- $W=array();
- while($row=mysqli_fetch_assoc($result)){
- $W[]=$row['weight'];
- echo "<tr class='center'>
- <td>".(++$i)."</td>
- <td>C{$i}</td>
- <td>{$row['weight']}</td>
- </tr>";
- }
- ?>
- </table>
- </p>
- <p>
- <table>
- <caption>
- Matrik Keputusan(X)
- </caption>
- <tr>
- <th rowspan='2'>Alternative</th>
- <th colspan='5'>Criteria</th>
- </tr>
- <tr>
- <th>C1</th>
- <th>C2</th>
- <th>C3</th>
- <th>C4</th>
- <th>C5</th>
- </tr>
- <?php
- $sql="SELECT
- a.id_alternative,
- SUM(IF(a.id_criteria=1,a.value,0)) AS C1,
- SUM(IF(a.id_criteria=2,a.value,0)) AS C2,
- SUM(IF(a.id_criteria=3,a.value,0)) AS C3,
- SUM(IF(a.id_criteria=4,a.value,0)) AS C4,
- SUM(IF(a.id_criteria=5,a.value,0)) AS C5
- FROM
- saw_evaluations a
- JOIN saw_criterias b USING(id_criteria)
- GROUP BY a.id_alternative
- ORDER BY a.id_alternative
- ";
- $result=mysqli_query($db,$sql);
- $X=array(1=>array(),2=>array(),3=>array(),4=>array(),5=>array());
- while($row=mysqli_fetch_assoc($result)){
- array_push($X[1],round($row['C1'],2));
- array_push($X[2],round($row['C2'],2));
- array_push($X[3],round($row['C3'],2));
- array_push($X[4],round($row['C4'],2));
- array_push($X[5],round($row['C5'],2));
- echo "<tr class='center'>
- <th>A{$row['id_alternative']}</th>
- <td>".round($row['C1'],2)."</td>
- <td>".round($row['C2'],2)."</td>
- <td>".round($row['C3'],2)."</td>
- <td>".round($row['C4'],2)."</td>
- <td>".round($row['C5'],2)."</td>
- </tr>\n";
- }
- mysqli_free_result($result);
- ?>
- </table>
- </p>
- <h3>Penghitungan Normalisasi</h3>
- <p>
- Untuk normalisai nilai, jika faktor/attribute kriteria <em>cost</em>
- digunakan rumusan:
- </p>
- <p>
- R<sub>ij</sub> = ( min{X<sub>ij</sub>} / X<sub>ij</sub>)
- </p>
- <p>
- sedangkan jika faktor/attribute kriteria <em>benefit</em> digunakan rumusan:
- </p>
- <p>
- R<sub>ij</sub> = ( X<sub>ij</sub>/max{X<sub>ij</sub>} )
- </p>
- <p>
- Maka nilai-nilai ternormalisasi-nya menjadi:
- </p>
- <p>
- <table>
- <caption>
- Matrik Ternormalisasi (R)
- </caption>
- <tr>
- <th rowspan='2'>Alternative</th>
- <th colspan='5'>Criteria</th>
- </tr>
- <tr>
- <th>C1</th>
- <th>C2</th>
- <th>C3</th>
- <th>C4</th>
- <th>C5</th>
- </tr>
- <?php
- $sql="SELECT
- a.id_alternative,
- SUM(
- IF(
- a.id_criteria=1,
- IF(
- b.attribute='benefit',
- a.value/".max($X[1]).",
- ".min($X[1])."/a.value)
- ,0)
- ) AS C1,
- SUM(
- IF(
- a.id_criteria=2,
- IF(
- b.attribute='benefit',
- a.value/".max($X[2]).",
- ".min($X[2])."/a.value)
- ,0)
- ) AS C2,
- SUM(
- IF(
- a.id_criteria=3,
- IF(
- b.attribute='benefit',
- a.value/".max($X[3]).",
- ".min($X[3])."/a.value)
- ,0)
- ) AS C3,
- SUM(
- IF(
- a.id_criteria=4,
- IF(
- b.attribute='benefit',
- a.value/".max($X[4]).",
- ".min($X[4])."/a.value)
- ,0)
- ) AS C4,
- SUM(
- IF(
- a.id_criteria=5,
- IF(
- b.attribute='benefit',
- a.value/".max($X[5]).",
- ".min($X[5])."/a.value)
- ,0)
- ) AS C5
- FROM
- saw_evaluations a
- JOIN saw_criterias b USING(id_criteria)
- GROUP BY a.id_alternative
- ORDER BY a.id_alternative
- ";
- $result=mysqli_query($db,$sql);
- $R=array();
- while($row=mysqli_fetch_assoc($result)){
- $R[$row['id_alternative']]=array($row['C1'],$row['C2'],$row['C3'],$row['C4'],$row['C5']);
- echo "<tr class='center'>
- <th>A{$row['id_alternative']}</th>
- <td>".round($row['C1'],2)."</td>
- <td>".round($row['C2'],2)."</td>
- <td>".round($row['C3'],2)."</td>
- <td>".round($row['C4'],2)."</td>
- <td>".round($row['C5'],2)."</td>
- </tr>\n";
- }
- ?>
- </table>
- </p>
- <h2>[4] Perangkingan</h2>
- <p>
- Hasil akhir diperoleh dari proses perankingan yaitu penjumlahan dari perkalian
- matriks ternormalisasi R dengan vektor bobot W sehingga diperoleh nilai terbesar
- yang dipilih sebagai alternatif terbaik (Ai) sebagai solusi
- </p>
- <p>
- <table>
- <caption>
- Hasil Perangkingan
- </caption>
- <tr>
- <th>No</th>
- <th>Alternative</th>
- <th>Result</th>
- </tr>
- <?php
- $V=array();
- $m=count($W);
- foreach($R as $i=>$r){
- for($j=0;$j<$m;$j++){
- $V[$i]=(isset($V[$i])?$V[$i]:0)+$r[$j]*$W[$j];
- }
- }
- arsort($V);
- $no=0;
- foreach($V as $i=>$v){
- echo "<tr class='center'>
- <td>".(++$no)."</td>
- <td>A{$i}</td>
- <td>{$v}</td>
- </tr>";
- }
- ?>
- </table>
- </p>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement