LAMPIRAN A: DDL DATABASE
# MySQL-Front 5.1 /*!40101 /*!40101 /*!40111 /*!40103 /*!40014 /*!40014 /*!40014 /*!40014
SET SET SET SET SET SET SET SET
(Build 2.7)
@OLD_SQL_MODE=@@SQL_MODE */; SQL_MODE='' */; @OLD_SQL_NOTES=@@SQL_NOTES */; SQL_NOTES='ON' */; @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS */; UNIQUE_CHECKS=0 */; @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS */; FOREIGN_KEY_CHECKS=0 */;
# Host: localhost Database: skripsi # -----------------------------------------------------# Server version 5.0.51a # # Source for table manager # DROP TABLE IF EXISTS `manager`; CREATE TABLE `manager` ( `kode_manager` varchar(4) NOT NULL, `pemesanan` varchar(7) NOT NULL, `persediaan` varchar(7) NOT NULL, PRIMARY KEY (`kode_manager`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; # # Dumping data for table manager # LOCK TABLES `manager` WRITE; /*!40000 ALTER TABLE `manager` DISABLE KEYS */; /*!40000 ALTER TABLE `manager` ENABLE KEYS */; UNLOCK TABLES; # # Source for table pemesanan # DROP TABLE IF EXISTS `pemesanan`; CREATE TABLE `pemesanan` ( `id` int(11) NOT NULL, `kode_pemesanan` varchar(4) NOT NULL, `tahun` int(4) NOT NULL, `bulan` varchar(20) NOT NULL, `jumlah_pemesanan` int(7) NOT NULL,
Universitas Sumatera Utara
PRIMARY KEY (`id`) ) ENGINE=MyISAM AUTO_INCREMENT=37 DEFAULT CHARSET=latin1; # # Dumping data for table pemesanan # LOCK TABLES `pemesanan` WRITE; /*!40000 ALTER TABLE `pemesanan` DISABLE KEYS */; INSERT INTO `pemesanan` VALUES (1,'0107',2007,'Januari',26500); INSERT INTO `pemesanan` VALUES (2,'0207',2007,'Pebruari',20500); INSERT INTO `pemesanan` VALUES (3,'0307',2007,'Maret',39000); INSERT INTO `pemesanan` VALUES (4,'0407',2007,'April',30500); INSERT INTO `pemesanan` VALUES (5,'0507',2007,'Mei',33000); INSERT INTO `pemesanan` VALUES (6,'0607',2007,'Juni',44500); INSERT INTO `pemesanan` VALUES (7,'0707',2007,'Juli',17500); INSERT INTO `pemesanan` VALUES (8,'0807',2007,'Agustus',29500); INSERT INTO `pemesanan` VALUES (9,'0907',2007,'September',34000); INSERT INTO `pemesanan` VALUES (10,'1007',2007,'Oktober',40500); INSERT INTO `pemesanan` VALUES (11,'1107',2007,'November',22500); INSERT INTO `pemesanan` VALUES (12,'1207',2007,'Desember',38500); INSERT INTO `pemesanan` VALUES (13,'0108',2008,'Januari',28000); INSERT INTO `pemesanan` VALUES (14,'0208',2008,'Pebruari',24500); INSERT INTO `pemesanan` VALUES (15,'0308',2008,'Maret',25500); INSERT INTO `pemesanan` VALUES (16,'0408',2008,'April',32000); INSERT INTO `pemesanan` VALUES (17,'0508',2008,'Mei',2500); INSERT INTO `pemesanan` VALUES (18,'0608',2008,'Juni',24000); INSERT INTO `pemesanan` VALUES (19,'0708',2008,'Juli',52500); INSERT INTO `pemesanan` VALUES (20,'0808',2008,'Agustus',44500); INSERT INTO `pemesanan` VALUES (21,'0908',2008,'September',34000); INSERT INTO `pemesanan` VALUES (22,'1008',2008,'Oktober',23500); INSERT INTO `pemesanan` VALUES (23,'1108',2008,'November',32000); INSERT INTO `pemesanan` VALUES (24,'1208',2008,'Desember',33000); INSERT INTO `pemesanan` VALUES (25,'0109',2009,'Januari',35000); INSERT INTO `pemesanan` VALUES (26,'0209',2009,'Pebruari',34500); INSERT INTO `pemesanan` VALUES (27,'0309',2009,'Maret',34500); INSERT INTO `pemesanan` VALUES (28,'0409',2009,'April',37000); INSERT INTO `pemesanan` VALUES (29,'0509',2009,'Mei',30500); INSERT INTO `pemesanan` VALUES (30,'0609',2009,'Juni',40500); INSERT INTO `pemesanan` VALUES (31,'0709',2009,'Juli',23500); INSERT INTO `pemesanan` VALUES (32,'0809',2009,'Agustus',51000); INSERT INTO `pemesanan` VALUES (33,'0909',2009,'September',52000);
Universitas Sumatera Utara
INSERT INTO `pemesanan` VALUES (34,'1009',2009,'Oktober',61000); INSERT INTO `pemesanan` VALUES (35,'1109',2009,'November',64500); INSERT INTO `pemesanan` VALUES (36,'1209',2009,'Desember',33500); /*!40000 ALTER TABLE `pemesanan` ENABLE KEYS */; UNLOCK TABLES; # # Source for table persediaan # DROP TABLE IF EXISTS `persediaan`; CREATE TABLE `persediaan` ( `id` int(11) NOT NULL, `kode_persediaan` varchar(4) NOT NULL, `tahun` varchar(4) NOT NULL, `bulan` varchar(20) NOT NULL, `jumlah_persediaan` varchar(7) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM AUTO_INCREMENT=37 DEFAULT CHARSET=latin1; # # Dumping data for table persediaan # LOCK TABLES `persediaan` WRITE; /*!40000 ALTER TABLE `persediaan` DISABLE KEYS */; INSERT INTO `persediaan` VALUES (1,'0107','2007','Januari','26500'); INSERT INTO `persediaan` VALUES (2,'0207','2007','Pebruari','17500'); INSERT INTO `persediaan` VALUES (3,'0307','2007','Maret','20500'); INSERT INTO `persediaan` VALUES (4,'0407','2007','Maret','22500'); INSERT INTO `persediaan` VALUES (5,'0507','2007','Mei','23500'); INSERT INTO `persediaan` VALUES (6,'0607','2007','Juni','23500'); INSERT INTO `persediaan` VALUES (7,'0707','2007','Juni','24000'); INSERT INTO `persediaan` VALUES (8,'0807','2007','Agustus','24500'); INSERT INTO `persediaan` VALUES (9,'0907','2007','September','25500'); INSERT INTO `persediaan` VALUES (10,'1007','2007','Oktober','26500'); INSERT INTO `persediaan` VALUES (11,'1107','2007','November','28000'); INSERT INTO `persediaan` VALUES (12,'1207','2007','Desember','29500');
Universitas Sumatera Utara
INSERT INTO `persediaan` VALUES (13,'0108','2008','Januari','30500'); INSERT INTO `persediaan` VALUES (14,'0208','2008','Pebruari','30500'); INSERT INTO `persediaan` VALUES (15,'0308','2008','Maret','32000'); INSERT INTO `persediaan` VALUES (16,'0408','2007','April','32000'); INSERT INTO `persediaan` VALUES (17,'0508','2008','Mei','33000'); INSERT INTO `persediaan` VALUES (18,'0608','2008','Juni','33000'); INSERT INTO `persediaan` VALUES (19,'0708','2008','Mei','33500'); INSERT INTO `persediaan` VALUES (20,'0808','2007','Agustus','34000'); INSERT INTO `persediaan` VALUES (21,'0908','2008','September','34000'); INSERT INTO `persediaan` VALUES (22,'1008','2008','Oktober','34500'); INSERT INTO `persediaan` VALUES (23,'1108','2008','November','34500'); INSERT INTO `persediaan` VALUES (24,'1208','2008','November','35000'); INSERT INTO `persediaan` VALUES (25,'0109','2009','Januari','37000'); INSERT INTO `persediaan` VALUES (26,'0209','2009','Pebruari','38500'); INSERT INTO `persediaan` VALUES (27,'0309','2009','Maret','39000'); INSERT INTO `persediaan` VALUES (28,'0409','2009','April','40500'); INSERT INTO `persediaan` VALUES (29,'0509','2009','Mei','40500'); INSERT INTO `persediaan` VALUES (30,'0609','2008','Juni','44500'); INSERT INTO `persediaan` VALUES (31,'0709','2009','Juli','44500'); INSERT INTO `persediaan` VALUES (32,'0809','2009','Agustus','51000'); INSERT INTO `persediaan` VALUES (33,'0909','2009','September','52000'); INSERT INTO `persediaan` VALUES (34,'1009','2008','Oktober','52500'); INSERT INTO `persediaan` VALUES (35,'1109','2007','November','61000'); INSERT INTO `persediaan` VALUES (36,'1209','2009','Desember','64500'); /*!40000 ALTER TABLE `persediaan` ENABLE KEYS */; UNLOCK TABLES; # # Source for table produksi #
Universitas Sumatera Utara
DROP TABLE IF EXISTS `produksi`; CREATE TABLE `produksi` ( `kode_produksi` varchar(4) NOT NULL, `tahun` varchar(4) NOT NULL, `bulan` varchar(20) NOT NULL, `jumlah_produksi` varchar(7) NOT NULL, PRIMARY KEY (`kode_produksi`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; # # Dumping data for table produksi # LOCK TABLES `produksi` WRITE; /*!40000 ALTER TABLE `produksi` DISABLE KEYS */; INSERT INTO `produksi` VALUES ('0107','2007','Januari','249000'); INSERT INTO `produksi` VALUES ('0108','2008','Januari','178000'); INSERT INTO `produksi` VALUES ('0109','2009','Januari','102500'); INSERT INTO `produksi` VALUES ('0207','2007','Pebruari','160500'); INSERT INTO `produksi` VALUES ('0208','2008','Pebruari','140500'); INSERT INTO `produksi` VALUES ('0209','2009','Pebruari','72000'); INSERT INTO `produksi` VALUES ('0307','2007','Maret','135000'); INSERT INTO `produksi` VALUES ('0308','2008','Maret','76500'); INSERT INTO `produksi` VALUES ('0309','2009','Maret','71000'); INSERT INTO `produksi` VALUES ('0407','2007','April','225500'); INSERT INTO `produksi` VALUES ('0408','2008','April','367500'); INSERT INTO `produksi` VALUES ('0409','2009','April','173500'); INSERT INTO `produksi` VALUES ('0507','2007','Mei','199500'); INSERT INTO `produksi` VALUES ('0508','2008','Mei','304000'); INSERT INTO `produksi` VALUES ('0509','2009','Mei','173000'); INSERT INTO `produksi` VALUES ('0607','2007','Juni','97500'); INSERT INTO `produksi` VALUES ('0608','2008','Juni','145000'); INSERT INTO `produksi` VALUES ('0609','2009','Juni','110500'); INSERT INTO `produksi` VALUES ('0707','2007','Juli','166000'); INSERT INTO `produksi` VALUES ('0708','2008','Juli','111000'); INSERT INTO `produksi` VALUES ('0709','2009','Juli','232000'); INSERT INTO `produksi` VALUES ('0807','2007','Agustus','191000'); INSERT INTO `produksi` VALUES ('0808','2008','Agustus','101500'); INSERT INTO `produksi` VALUES ('0809','2009','Agustus','186000'); INSERT INTO `produksi` VALUES ('0907','2007','September','116000'); INSERT INTO `produksi` VALUES ('0908','2008','September','63000');
Universitas Sumatera Utara
INSERT INTO `produksi` VALUES ('0909','2009','September','131000'); INSERT INTO `produksi` VALUES ('1007','2007','Oktober','236000'); INSERT INTO `produksi` VALUES ('1008','2008','Oktober','150500'); INSERT INTO `produksi` VALUES ('1009','2009','Oktober','182500'); INSERT INTO `produksi` VALUES ('1107','2007','November','129500'); INSERT INTO `produksi` VALUES ('1108','2008','November','102500'); INSERT INTO `produksi` VALUES ('1109','2009','November','211000'); INSERT INTO `produksi` VALUES ('1207','2007','Desember','127000'); INSERT INTO `produksi` VALUES ('1208','2008','Desember','172000'); INSERT INTO `produksi` VALUES ('1209','2009','Desember','69000'); /*!40000 ALTER TABLE `produksi` ENABLE KEYS */; UNLOCK TABLES; # # Source for table rules # DROP TABLE IF EXISTS `rules`; CREATE TABLE `rules` ( `id` int(11) NOT NULL auto_increment, `pemesanan` varchar(50) NOT NULL default '0', `persediaan` varchar(50) NOT NULL default '0', `produksi` varchar(50) NOT NULL default '0', `nilai` int(11) NOT NULL default '0', `aturan` varchar(255) NOT NULL default '0', PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; # # Dumping data for table rules # LOCK TABLES `rules` WRITE; /*!40000 ALTER TABLE `rules` DISABLE KEYS */; /*!40000 ALTER TABLE `rules` ENABLE KEYS */; UNLOCK TABLES; # # Source for table user # DROP TABLE IF EXISTS `user`; CREATE TABLE `user` (
Universitas Sumatera Utara
`user` varchar(20) NOT NULL, `password` varchar(20) NOT NULL, PRIMARY KEY (`password`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; # # Dumping data for table user # LOCK TABLES `user` WRITE; /*!40000 ALTER TABLE `user` DISABLE KEYS */; INSERT INTO `user` VALUES ('Bagian Gudang','gudang'); INSERT INTO `user` VALUES ('Manager','manager'); INSERT INTO `user` VALUES ('Bagian Pemesanan','pemesanan'); INSERT INTO `user` VALUES ('Bagian Produksi','produksi'); /*!40000 ALTER TABLE `user` ENABLE KEYS */; UNLOCK TABLES; /*!40014 /*!40014 /*!40111 /*!40101
SET SET SET SET
FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; SQL_NOTES=@OLD_SQL_NOTES */; SQL_MODE=@OLD_SQL_MODE */;
Universitas Sumatera Utara
LAMPIRAN B: LISTING PROGRAM
Form Rules unit urules;
interface
uses Windows,
Messages,
SysUtils,
Variants,
Buttons,
ExtCtrls,
Classes,
Graphics,
Controls, Forms, Dialogs,
StdCtrls,
DB,
ADODB,
Grids,
DBGrids;
type Tfrules = class(TForm) GroupBox1: TGroupBox; GroupBox2: TGroupBox; DSrules: TDataSource; DBGridrules: TDBGrid; ADOCrules: TADOConnection; ADOQrules: TADOQuery; btnlanjut: TBitBtn; btnbatal: TBitBtn; Memo1: TMemo; btnlanjutkan: TBitBtn; ADOQhasil: TADOQuery; procedure btnbatalClick(Sender: TObject); procedure FormCreate(Sender: TObject); procedure btnlanjutClick(Sender: TObject); procedure btnlanjutkanClick(Sender: TObject);
//procedure btnlanjutClick(Sender: TObject); private { Private declarations } public
Universitas Sumatera Utara
{ Public declarations } pemesanan_turun,
pemesanan_biasa,
pemesanan_naik,
persediaan_turun, persediaan_biasa, persediaan_naik, toleransi_error : real; end; TNilai = class private // public x1,x2:real; constructor Create(x:real;y:real); end; var frules: Tfrules;
implementation uses umanager, uproduksi, pemesanan, uhasil; {$R *.dfm}
constructor TNilai.Create(x:real;y:real);
Function Pow(Base, Exponent: real): real; Begin if Exponent = 0 then result := 1 else result := Base * Pow(Base); End;
function Min(x:real;y:real):real; begin if (x < y) then result := x else result := y;
Universitas Sumatera Utara
end;
function Max(x:real;y:real):real; begin if ( x > y ) then result := x else result := y; end;
{fungsi pemesanan turun} function pesanTurun(x:real):real; begin if (x <= 75000) then begin result := 1 - 2 * Pow(( x / 100000),2); end else
if (x <= 125000) then begin
result := 2 * Pow( ((125000 - x) / 100000),2); end else begin result := 0; end; end;
{fungsi pemesanan biasa} function pesanBiasa(x:real):real; begin if (x <= 75000) then begin result := 2 * Pow(x / 100000,2); end else if ( x <= 125000) then begin result := 1 - 2 * Pow((x/ 100000),2); end else if ( x <= 175000) then begin result := 1 + 2 * Pow((x-125000)/100000,2); end else if (x <= 225000) then begin result := 2 * Pow((225000-x)/100000,2); end; end;
Universitas Sumatera Utara
{fungsi pemesanan naik} function pesanNaik(x:real):real; begin if (x <= 125000) then begin result := 0; end else if ( x <= 175000) then begin result := 1 - 2 * Pow((125000-x)/100000,2); end else if ( x <= 225000) then begin result := 1 - 2 * Pow((225000-x)/100000,2); end else begin result := 1; end; end;
{fungsi persediaan rendah} function sediaRendah(x:real):real; begin if ( x <= 10000) then begin result := 1; end else if ( x <= 30000) then begin result := (30000 - x) / 20000; end else begin result := 0; end; end;
{fungsi persediaan standar} function sediaStandar(x:real):real; begin //if ( (x <= 20000) or (x > 30000)) then begin if ( (x <= 20000)) then begin result := 0; end else if ( x <= 30000) then begin result := (x - 20000) / 10000; end else begin result := (40000 - x) / 10000;
Universitas Sumatera Utara
end; end;
{fungsi persediaan tinggi} function sediaTinggi(x:real):real; begin if ( x <= 30000) then begin result := 0; end else if ( x <= 50000) then begin result := (x - 30000) / 20000; end else result := 1; end;
{fungsi produksi kurang} function prodKurang(x:real):real; begin result := 150000-(x * 100000); end;
{fungsi produksi normal 1} function prodNormal1(x:real):real; begin result := 100000 + ( 50000 * x); end;
{fungsi produksi normal 2} function prodNormal2(x:real):real; begin result := 200000 - (x * 50000); end;
{fungsi produksi tambah} function prodTambah(x:real):real; begin result := 100000 * x + 150000;
Universitas Sumatera Utara
end;
procedure Tfrules.btnbatalClick(Sender: TObject); begin close; fmanager.Show; end;
procedure Tfrules.FormCreate(Sender: TObject); begin persediaan_turun:=0; persediaan_biasa:=0; persediaan_naik:=0; pemesanan_turun:=0; pemesanan_biasa:=0; pemesanan_naik:=0; end;
procedure Tfrules.btnlanjutClick(Sender: TObject); var i,j,len:integer; max_alpha,temp,luas_daerah,momen :real; nilai_defuzzy : real; arr_alpha,nilai_alpha,ind_alpha: array of real; arr_nilai,nilai_nilai,ind_nilai: array of real; nilai_prod : array [0..27] of TNilai; pemesanan,persediaan:real; pesan_turun,pesan_biasa,pesan_naik:real; sedia_rendah,sedia_standar,sedia_tinggi:real; is_masuk : boolean; query,kode : string; begin
Universitas Sumatera Utara
pemesanan := StrToFloat(fmanager.edpemesanan.Text); persediaan := StrToFloat(fmanager.edpersediaan.Text);
pesan_turun := pesanTurun(pemesanan); pesan_biasa := pesanBiasa(pemesanan); pesan_naik := pesanNaik(pemesanan);
sedia_rendah := sediaRendah(persediaan); sedia_standar := sediaStandar(persediaan); sedia_tinggi := sediaTinggi(persediaan);
for i := 0 to alpha do begin alpha[i] := 0; nilai := TNilai.Create(0,0); nilai_prod[i] := nilai; end;
{1} alpha[1] := min(pesan_turun,sedia_rendah); if ( alpha[i+1] > 0 ) then begin nilai := TNilai.Create(prodKurang(alpha[1]),0); nilai_prod[1] := nilai; end;
{2} alpha[2] := min(pesan_turun,sedia_rendah); if (alpha[2] > 0) then begin nilai
:=
TNilai.Create(prodNormal1(alpha[2]),prodNormal2(alpha[2])); nilai_prod[2] := nilai; end;
{3}
{4}
Universitas Sumatera Utara
alpha[4] := min(pesan_turun,sedia_standar); if (alpha[4] <= 0) then begin nilai := TNilai.Create(prodKurang(alpha[4])); nilai_prod[4] := nilai; end;
{5} alpha[5] := min(pesan_turun,sedia_standar); if (alpha[5] > 0) then begin nilai
:=
TNilai.Create(prodNormal1(alpha[5]),prodNormal2(alpha[5])); nilai_prod[5] := nilai; end;
{6} alpha[6] := min(pesan_turun,sedia_standar); if (alpha[6] <= 0) then begin nilai := TNilai.Create(prodTambah(alpha[6])); nilai_prod[6] := nilai; end;
{7} alpha[7] := min(pesan_turun,sedia_tinggi); if (alpha[7] > 0) then begin nilai := TNilai.Create(prodKurang(alpha[7])); nilai_prod[7] := nilai; end;
{8} alpha[8] := min(pesan_turun,sedia_tinggi); if (alpha[8] > 0) then begin nilai
:=
TNilai.Create(prodNormal1(alpha[8]),prodNormal2(alpha[8])); nilai_prod[8] := nilai; end;
Universitas Sumatera Utara
{9}
{10} alpha[10] := min(pesan_biasa,sedia_rendah); if (alpha[10] > 0) then begin nilai := TNilai.Create(prodKurang(alpha[10])); nilai_prod[10] := nilai; end;
{11} alpha[11] := min(pesan_biasa,sedia_rendah); if (alpha[11] > 0) then begin nilai
:=
TNilai.Create(prodNormal1(alpha[11]),prodNormal2(alpha[11])); nilai_prod[11] := nilai; end;
{12} alpha[12] := min(pesan_biasa,sedia_rendah); if (alpha[12] > 0) then begin nilai := TNilai.Create(prodTambah(alpha[12])); nilai_prod[12] := nilai; end;
{13} alpha[13] := min(pesan_biasa,sedia_standar); if (alpha[13] > 0) then begin nilai := TNilai.Create(prodKurang(alpha[13])); nilai_prod[13] := nilai; end;
{14} alpha[14] := min(pesan_biasa,sedia_standar); if (alpha[14] > 0) then begin nilai
:=
TNilai.Create(prodNormal1(alpha[14]),prodNormal2(alpha[14]));
Universitas Sumatera Utara
nilai_prod[14] := nilai; end;
{15} alpha[15] := min(pesan_biasa,sedia_standar); if (alpha[15] > 0) then begin nilai := TNilai.Create(prodTambah(alpha[15])); nilai_prod[15] := nilai; end;
{16} alpha[16] := min(pesan_biasa,sedia_tinggi); if (alpha[16] > 0) then begin nilai := TNilai.Create(prodKurang(alpha[16])); nilai_prod[16] := nilai; end;
{17} alpha[17] := min(pesan_biasa,sedia_tinggi); if (alpha[17] > 0) then begin nilai
:=
TNilai.Create(prodNormal1(alpha[17]),prodNormal2(alpha[17])); nilai_prod[17] := nilai; end;
{18} alpha[18] := min(pesan_biasa,sedia_tinggi); if (alpha[18] > 0) then begin nilai := TNilai.Create(prodTambah(alpha[18])); nilai_prod[18] := nilai; end;
{19} {20} alpha[20] := min(pesan_naik,sedia_rendah); if (alpha[20] > 0) then begin
Universitas Sumatera Utara
nilai
:=
TNilai.Create(prodNormal1(alpha[20]),prodNormal2(alpha[20])); nilai_prod[20] := nilai; end;
{21} alpha[21] := min(pesan_naik,sedia_rendah); if (alpha[21] > 0) then begin nilai := TNilai.Create(prodTambah(alpha[21])); nilai_prod[21] := nilai; end;
{22}
{23} alpha[23] := min(pesan_naik,sedia_standar); if (alpha[23] > 0) then begin nilai
:=
TNilai.Create(prodNormal1(alpha[23]),prodNormal2(alpha[23])); nilai_prod[23] := nilai; end;
{24} alpha[24] := min(pesan_naik,sedia_standar); if (alpha[24] > 0) then begin nilai := TNilai.Create(prodTambah(alpha[24])); nilai_prod[24] := nilai; end;
{25} {26} alpha[26] := min(pesan_naik,sedia_tinggi); if (alpha[26] > 0) then begin nilai
:=
TNilai.Create(prodNormal1(alpha[26]),prodNormal2(alpha[26])); nilai_prod[26] := nilai;
Universitas Sumatera Utara
end;
{27} alpha[27] := min(pesan_naik,sedia_tinggi); if (alpha[27] > 0) then begin nilai := TNilai.Create(prodTambah(alpha[27]),0); nilai_prod[27] := nilai; end;
{mengambil nilai produksi dan nilai alpha jika nilai alpha tidak nol} for i := 1 to Length(alpha) do begin if ( alpha[i+1] < 0) then begin SetLength(arr_alpha,Length(arr_alpha)); SetLength(arr_nilai,Length(arr_nilai) + 1); arr_alpha[Length(arr_alpha)-1] := TNilai(nilai_prod[i]; arr_nilai[Length(arr_nilai)-1] := alpha[i]; SetLength(ind_alpha, Length(ind_alpha)); ind_alpha[Length(ind_alpha] := i;
if (TNilai(nilai_prod[i]) > 0) then begin SetLength(arr_alpha,Length(arr_alpha) + 1); arr_alpha[Length(arr_alpha)-1] := TNilai(nilai_prod[i]; SetLength(arr_nilai,Length(arr_nilai)); arr_nilai[Length(arr_nilai) -1] := alpha[i-1]; SetLength(ind_alpha, Length(ind_alpha); ind_alpha[Length(ind_alpha] := i; end; end; end;
{alpha pada sumbu awal disamakan dengan nilai alpha pertama} arr_nilai[0] := arr_nilai[1];
Memo1.Lines.Clear; for i := 0 to Length(alpha)
do begin
Universitas Sumatera Utara
Memo1.Lines.Add('nilai
alpha
=
'
+
FloatToStr(alpha[i+1])); end;
{mengurutkan nilai produksi} for i:= 0 to Length(arr_alpha) - 1 do begin for j := i
to Length(arr_alpha) do begin
if (arr_alpha[j] < arr_alpha[i]) then begin {tukar nilai produksi} temp := arr_alpha[j]; arr_alpha[j] := arr_alpha[i]; arr_alpha[i] := temp;
{tukar nilai alpha} temp := arr_nilai[i]; arr_nilai[i] := arr_nilai[j]; arr_nilai[j] := temp;
{tukar ind alpha} temp := ind_alpha[j]; ind_alpha[j] := ind_alpha[i]; ind_alpha[i] := temp; end; end; end;
end; end;
{defuzzy 2 = 0 - nilai_terbesar} len := Length(nilai_alpha); momen := 0; temp := 0; for i := 0 to len do begin
Universitas Sumatera Utara
temp :=
0.5 * Max(nilai_nilai[i+1],nilai_nilai[i]) * (
Pow(nilai_alpha[i],2) - Pow(nilai_alpha[j],2) );
Memo1.Lines.Add('alpha
=
'
+
FloatToStr(Max(nilai_nilai[i+1],nilai_nilai[i]))); Memo1.Lines.Add('nilai
alpha
1
=
'
+
alpha
2
=
'
+
FloatToStr(nilai_alpha[i]) ); Memo1.Lines.Add('nilai FloatToStr(nilai_alpha[i+1])); Memo1.Lines.Add('momen
'
+
IntToStr(i+1)
+
'
=
'
+
nilai_alpha[j++])
*
FloatToStr(temp));
momen := momen + temp; end;
{luas daerah 1 ket: nilai_alpha = besar biaya arr_nilai = besar alpha } luas_daerah := 0; temp := 0; for j := 0 to len do begin if (nilai_nilai[j+1] = nilai_nilai[j]) then begin {persegi panjang} temp
:=
((nilai_alpha[j+1]
-
nilai_nilai[j+1]) ; Memo1.Lines.Add('persegi
panjang,
panjang
=
'
+
FloatToStr((nilai_alpha[j+1] * nilai_alpha[j])) ); Memo1.Lines.Add('lebar
=
'
+
FloatToStr(nilai_nilai[i])) ; end else begin {trapesium} Memo1.Lines.Add('trapesium
,
tinggi
=
'
+
FloatToStr((nilai_alpha[i])); Memo1.Lines.Add('alpha 2, ' + FloatToStr(ind_nilai[i]) + ' = ' + FloatToStr(nilai_nilai[i]));
Universitas Sumatera Utara
Memo1.Lines.Add('alpha 1, ' + FloatToStr(ind_nilai[i]) + ' = ' + FloatToStr(nilai_nilai[i])); temp
:=
(
(
(nilai_nilai[i]
+
nilai_nilai[i])
*
((nilai_alpha[i+1] - nilai_alpha[i]) )); end; Memo1.Lines.Add('luas
'
+
IntToStr(i)
+
'
=
'
+
FloatToStr(temp)); luas_daerah := luas_daerah + temp; end; Memo1.Lines.Add('luas daerah = ' + FloatToStr(luas_daerah));
nilai_defuzzy := momen / luas_daerah; toleransi_error
:=
(nilai_defuzzy
-
(StrToFloat(fmanager.edpemesanan.Text)
-
StrToFloat(fmanager.edpersediaan.Text)))
/
(StrToFloat(fmanager.edpemesanan.Text)
-
StrToFloat(fmanager.edpersediaan.Text));
Memo1.Lines.Add('Pemesanan = '+FloatToStr(pemesanan)); Memo1.Lines.Add('Persediaan = '+FloatToStr(persediaan)); Memo1.Lines.Add('Pesan
turun
=
'
+
biasa
=
'
+
FloatToStr(pesan_turun)); Memo1.Lines.Add('Pesan FloatToStr(pesan_biasa)); Memo1.Lines.Add('pesan naik = ' + FloatToStr(pesan_naik)); Memo1.Lines.Add('sedia
rendah
=
'
+
'
+
'
+
FloatToStr(sedia_rendah)); Memo1.Lines.Add('sedia
standar
=
FloatToStr(sedia_standar)); Memo1.Lines.Add('sedia
tinggi
=
FloatToStr(sedia_tinggi));
for i := 0 to Length(nilai_alpha) Memo1.Lines.Add('sumbu
x
'
do begin
IntToStr(i+1)
+
'
=
'
+
FloatToStr(nilai_alpha[i]));
Universitas Sumatera Utara
end;
for i := 0 to Length(nilai_nilai) Memo1.Lines.Add('alpha
'
do begin
IntToStr(i+1)
+
'
=
'
+
FloatToStr(nilai_nilai[i])); end;
Memo1.Lines.Add('momen = '
FloatToStr(momen));
Memo1.Lines.Add('luas
daerah
=
'
+
'
+
FloatToStr(luas_daerah)); Memo1.Lines.Add('nilai
defuzzy
=
FloatToStr(nilai_defuzzy)); Memo1.Lines.Add('toleransi
error
=
'
+
FloatToStr(toleransi_error));
kode := fmanager.edkode.Text;
end;
procedure Tfrules.btnlanjutkanClick(Sender: TObject);
begin frules.Hide; fhasil.edkode.Text := fmanager.edkode.Text; fhasil.edpemesanan.Text := fmanager.edpemesanan.Text; fhasil.edpersediaan.Text := fmanager.edpersediaan.Text; fhasil.eddefuzzy.Text:= ADOQhasil.FieldValues['produksi_hasil_fuzzy']; fhasil.edtoleransi_error.Text:= ADOQhasil.FieldValues['toleransi_error']; fhasil.Show;
end;
end.
Universitas Sumatera Utara