Script PHP Implementasi Metode Promethee 

Assalamu'alaikum,
Berikut akan saya posting sekilas tentang source code php untuk perhitungan Metode Promethee.
Namun saya tidak menjelaskan secara rinci penggunaan tersebut. dan jika anda mengalami kesulitan, anda dapat berkomentar.
<?php $qal=mysql_query("select alternatif.*,motor.* from alternatif,motor where alternatif.idmotor=motor.idmotor ORDER BY idalternatif ASC"); while($ral=mysql_fetch_array($qal)){ $alt[]=array($ral['idalternatif'],$ral['idmotor'],$ral['kode'],$ral['nama']); } $qkr=mysql_query("select * from kriteria ORDER BY idkriteria ASC"); while($rkr=mysql_fetch_array($qkr)){ $krt[]=array($rkr['idkriteria'],$rkr['kode'],$rkr['nama'],$rkr['kaidah'],$rkr['bobot'],$rkr['type_preferensi'],$rkr['p'],$rkr['q']); } for($pers1=0;$pers1$alt[$pers2][2]){ $persamaan[]=array($alt[$pers1][2],$alt[$pers2][2],$alt[$pers1][0],$alt[$pers2][0]); } } }
?>
<table width="100%" id="table-a">

  <tr>
    <th width="3%">No</th>
    <th width="7%">Kode</th>
<th width="20%">Kriteria</th>
<th width="7%">Bobot (%)</th>
 <th width="10%">Kaidah</th><?
for($i=0;$i<count($alt);$i++){

echo '<th>'.$alt[$i][2].'</th>';

}?>

    <th width="10%">Type Preferensi</th>
    <th width="10%">Parameter</th>
  </tr>
  <?
for($j=0;$j<count($krt);$j++){
?>
  <tr>
    <td><?=$j+1;?></td>
    <td><?=$krt[$j][1];?></td>
    <td><?=$krt[$j][2];?></td>
<td><?=$krt[$j][4];?></td>
<td><?=$krt[$j][3];?></td>
<?
for($ii=0;$ii<count($alt);$ii++){
$qn=mysql_query("select *from nilai_alternatif where idmotor='".$alt[$ii][1]."' and idkriteria='".$krt[$j][0]."'");

$rn=mysql_fetch_array($qn);
echo '<td>'.$rn['nilai'].'</td>';
}
?>
 
    <td><?=$krt[$j][5];?></td>
    <td width="10%"><? if($krt[$j][7]<>'0'){echo "q= ".$krt[$j][7];}?> <? if($krt[$j][6]<>'0'){echo "q= ".$krt[$j][6];}?></td>
  </tr>
  <?
  }
  ?>
</table>
</div>
<h4>Nilai Alternatif x Bobot</h4>
<div>
<table width="100%" id="table-a">

  <tr>
    <th width="3%">No</th>
    <th width="7%">Kode</th>
<th width="20%">Kriteria</th>
<th width="7%">Bobot (%)</th>
 <th width="10%">Kaidah</th><?
for($i=0;$i<count($alt);$i++){

echo '<th>'.$alt[$i][2].'</th>';

}?>

    <th width="10%">Type Preferensi</th>
    <th width="10%">Parameter</th>
  </tr>
  <?
for($j=0;$j<count($krt);$j++){

$nk=$krt[$j][0];
?>
  <tr>
    <td><?=$j+1;?></td>
    <td><?=$krt[$j][1];?></td>
    <td><?=$krt[$j][2];?></td>
<td><?=$krt[$j][4];?></td>
<td><?=$krt[$j][3];?></td>
<?
for($ii=0;$ii<count($alt);$ii++){
$nal=$alt[$ii][0];
$qn=mysql_query("select *from nilai_alternatif where idmotor='".$alt[$ii][1]."' and idkriteria='".$krt[$j][0]."'");

$rn=mysql_fetch_array($qn);

$selisih=$rn['nilai']* (($krt[$j][4])/100);
$selisih_persamaan[$nk][$nal]=$rn['nilai']* (($krt[$j][4])/100);
echo '<td>'.$selisih.'</td>';

}
?>
 
    <td><?=$krt[$j][5];?></td>
    <td width="10%"><? if($krt[$j][7]<>'0'){echo "q= ".$krt[$j][7];}?> <? if($krt[$j][6]<>'0'){echo "q= ".$krt[$j][6];}?></td>
  </tr>
  <?
  }
  ?>
</table>
</div>
<h4>Nilai Selisih Preferensi Index</h4>
<div>
<table width="100%" id="table-a">

  <tr>
    <th width="5%">No</th>
    <th width="43%">Persamaan</th>
<?
for($i=0;$i<count($krt);$i++){

echo '<th>'.$krt[$i][1].'</th>';

}?>
  </tr>
  <?
for($j=0;$j<count($persamaan);$j++){
$idper1=$persamaan[$j][2];
$idper2=$persamaan[$j][3];
?>
  <tr>
    <td><?=$j+1;?></td>
    <td><?=$persamaan[$j][0].",".$persamaan[$j][1];?></td>

<?
for($ii=0;$ii<count($krt);$ii++){
$idkrt=$krt[$ii][0];
$pref_index=(($selisih_persamaan[$idkrt][$idper1] - $selisih_persamaan[$idkrt][$idper2]));
//$pref_index=$selisih_persamaan[$idkrt][$idper1];

echo '<td>'.$pref_index.'</td>';
}
?>
 
  </tr>
  <?
  }
  ?>
</table>
</div>
<?   mysql_query("delete from persamaan ");
mysql_query("delete from hasil ");?>

<h4>Nilai Index Preferensi</h4>
<div>
<table width="100%" id="table-a">

  <tr>
    <th width="5%">No</th>
    <th width="43%">Persamaan</th>

<?
for($i=0;$i<count($krt);$i++){

echo '<th>'.$krt[$i][1].'</th>';

}?>
<th width="43%">Nilai</th>
  </tr>
  <?
for($j=0;$j<count($persamaan);$j++){
$idper1=$persamaan[$j][2];
$idper2=$persamaan[$j][3];
$tot=$j+1;
?>
  <tr>
    <td><?=$j+1;?></td>
    <td><?=$persamaan[$j][0].",".$persamaan[$j][1];?></td>

<?
for($ii=0;$ii<count($krt);$ii++){
$idkrt=$krt[$ii][0];
$type_preferensi=$krt[$ii][5];
$pp=$krt[$ii][6];
$pq=$krt[$ii][7];
$pref_index=(($selisih_persamaan[$idkrt][$idper1] - $selisih_persamaan[$idkrt][$idper2]));

if($type_preferensi=='I'){
if($pref_index<=0){
$index_preferensi=0;
}elseif($pref_index>0){
$index_preferensi=1;
}
}elseif($type_preferensi=='II'){
if($pref_index<=$pq){
$index_preferensi=0;
}elseif($pref_index >$pq){
$index_preferensi=1;
}
}
elseif($type_preferensi=='III'){
if($pref_index<=0){
$index_preferensi=$pref_index / $pq;
}elseif($pref_index >$pp){
$index_preferensi=1;
}
}
elseif($type_preferensi=='IV'){
if($pref_index<=0){
$index_preferensi=0;
}elseif(($pq< $pref_index)and ($pref_index <= $pp)){
$index_preferensi=0.5;
}elseif($pref_index> $pp){
$index_preferensi=1;
}
}
elseif($type_preferensi=='V'){
if($pref_index<=0){
$index_preferensi=0;
}elseif(($pq< $pref_index)and ($pref_index <= $pp)){
$index_preferensi=(($pref_index-$pq)/($pp-$pq));
}elseif($pref_index> $pp){
$index_preferensi=1;
}
}
$nilai[$tot][]=$index_preferensi;
echo '<td>'.$index_preferensi.'</td>';

}

?>
   <td><?php
   for($ll=0;$ll<count($krt);$ll++){
 
  $hasil_preferensi[$tot]+=$nilai[$tot][$ll];
}

$nilai_hasil_preferensi1=$hasil_preferensi[$tot]* (1/count($krt));

$nilai_hasil_preferensi[]=$hasil_preferensi[$tot]* (1/count($krt));
   echo $nilai_hasil_preferensi1;
 

  mysql_query("insert into persamaan set idalternatif1='$idper1', idalternatif2='$idper2',nilai='$nilai_hasil_preferensi1'");
 
   ?></td>
  </tr>
  <?
  }
  ?>
</table>
</div>
<h4>Nilai Index Preferensi</h4>
<div>
<table width="100%" id="table-a">

  <tr>
    <th width="5%">No</th>
    <th width="43%">Alternatif</th>
<?
for($i=0;$i<count($alt);$i++){
echo '<th>'.$alt[$i][2].'</th>';

}?>
  </tr>
  <?
for($ii=0;$ii<count($alt);$ii++){
$altbaris[]=$alt[$ii][0];
$nmr++;
?>
  <tr>
    <td><?=$nmr;?></td>
 
<td><?=$alt[$ii][2];?></td>
<?

for($z=0;$z<count($alt);$z++){
$altkolom[$ii][]=$alt[$z][0];
$idr1=$altkolom[$ii][$z];
$idr2=$altbaris[$ii];
if($altbaris[$ii]==$altkolom[$ii][$z]){
$setnilai='-';
}
elseif($altbaris[$ii]<>$altkolom[$ii][$z]){
$ql=mysql_query("select *from persamaan where idalternatif1='$idr2' and idalternatif2='$idr1'");
$rw=mysql_fetch_array($ql);

$setnilai=$rw['nilai'];

}
//echo '<td>'.$altkolom[$ii][$z].'</td>';
echo '<td>'.$setnilai.'</td>';
$nilef[$idr2][]=$setnilai;

}?>
  </tr>
<?
}?>

</table>
</div>
<h4>Perangkingan</h4>
<div>
<table width="100%" id="table-a">
  <tr>
    <th>No</th>
    <th>Kode</th>
    <th>Motor</th>
    <th>Leafing Flow </th>
    <th>&nbsp;</th>
    <th>Ethering Flow </th>
    <th>&nbsp;</th>
    <th>Net Flow </th>
    <th>&nbsp;</th>
    <th>&nbsp;</th>
  </tr>
   <?
 
for($i=0;$i<count($alt);$i++){
$nmrr++;
$idlf=$alt[$i][0];
$u=0;

?>
  <tr>
    <td><?=$nmrr;?></td>
    <td><?=$alt[$i][2];?></td>
    <td><?=$alt[$i][3];?></td>
    <td><?php $qlf=mysql_query("select sum(nilai)as nlf from persamaan where idalternatif1='$idlf'");
$hsl=mysql_fetch_array($qlf);
$LF=(1/(count($alt)-1)) * $hsl['nlf'];
echo number_format($LF,3);
?>
</td>
    <td></td>
    <td><? for($jj=0;$jj<count($alt);$jj++){
$nilaief+=$nilef[$idlf][$jj];
}
$EF=(1/(count($alt)-1)) *$nilaief;
echo number_format($EF,3);
$NF=$LF + $EF;
?></td>
    <td>&nbsp;</td>
    <td><?= number_format($NF,3);?></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <?
  mysql_query("insert into hasil set idalternatif='$idlf', LF='$LF',EF='$EF',NF='$NF'");

  }
  ?>
</table>

Untuk Script diatas, dapat dilihat hasil perhitungan seperti gambar dibawah ini.



Yang kurang dipahami silahkan berkomentar...

Subscribe to receive free email updates:

5 Responses to "Source Code PHP - Perhitungan Metode Promethee"

  1. pak, boleh mita source code nya? buat project tugas akhir di UNIMAL,.

    ReplyDelete
  2. Boleh minta source code lengkapnya?

    ReplyDelete
  3. Assalamu'alaikum pak
    boleh tau struktur database nya?

    ReplyDelete
  4. boleh minta databasenya saja pak atau program lengkapnya pak, mohon pak

    ReplyDelete