L 1 Lampiran 1. Kode Program Aplikasi Proyek_skripsi.dpr program proyek_skripsi; uses Forms, skrp in 'skrp.pas' {FormTampil}, Unit2 in 'Unit2.pas' {FormUtama}, Unit3 in 'Unit3.pas' {FormInput}; {$R *.res} Application.Initialize; Application.CreateForm(TFormUtama, FormUtama); Application.CreateForm(TFormTampil, FormTampil); Application.CreateForm(TFormInput, FormInput); Application.Run;. skrp.pas unit skrp; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Math, ExtCtrls, ComCtrls; type TFormTampil = class(tform) Memo1: TMemo; cmdexit: TButton; cmdinisial: TButton; cmdfull: TButton; Label1: TLabel; txtalpha: TEdit; txtbeta: TEdit; txtw: TEdit; txtc1: TEdit; Label3: TLabel; Label4: TLabel; txtc2: TEdit;
Label5: TLabel; Label6: TLabel; txtjum: TEdit; txtkaraan: TEdit; Label7: TLabel; txtiterasi: TEdit; Label8: TLabel; Image1: TImage; cmdimage: TButton; Label2: TLabel; txtkap: TEdit; ProgressBar1: TProgressBar; Label9: TLabel; txtjarak: TEdit; procedure FormCreate(Ser: TObject); procedure cmdexitclick(ser: TObject); procedure cmdinisialclick(ser: TObject); procedure storebest(i: integer); procedure moveparticle(i: integer); procedure cek_fitness(i: integer); procedure cek_partikel(i: integer); procedure tukar(i: integer); procedure cmdfullclick(ser: TObject); procedure inisialisasi(); function jarak(i,j: integer) : real; procedure cmdimageclick(ser: TObject); private { Private declarations } public { Public declarations } Partikel = class rute : array of integer; urutan : array of integer; fit : real; biaya : array of real; velocity : array of real; lbest : array of integer; urutan_lbest : array of integer; biaya_lbest : array of real; kapasitas : array of real; kapasitas_lbest : array of real; fit_lbest : real; procedure inisial; procedure hitung_biaya; L 2
L 3 FormTampil: TFormTampil; waktu : array of array of real; obyek: array of Partikel; c1,c2,w,alpha,beta: real; max_demand : real; max_jarak : real; karaan : integer; jmlnode : integer; gbest : array of integer; urutan_gbest : array of integer; biaya_gbest : array of real; kapasitas_gbest : array of real; fit_gbest : real; jmlpartikel : integer; cek : integer; max_iterasi : integer; jmldemand : real; nosol : boolean; implementation uses unit2,unit3; {$R *.dfm} function TFormTampil.jarak(i,j: integer) : real; x1,x2,y1,y2 : real; x1 := unit3.area[unit3.ptr[i]].x; x2 := unit3.area[unit3.ptr[j]].x; y1 := unit3.area[unit3.ptr[i]].y; y2 := unit3.area[unit3.ptr[j]].y; jarak := sqrt(power(x1-x2,2)+power(y1-y2,2)); procedure Partikel.inisial; i : integer; acak : real; panjang : integer; panjang := length(rute); randomize;
L 4 //inisialisasi urutan, velocity dan posisi partikel for i := 0 to panjang-1 do urutan[i] := i + 1; velocity[i] := (random(1001))/1000; acak := (random(1001))/1000; if acak > velocity[i] then rute[i] := 1 else rute[i] := 0; fit_lbest := high(integer); procedure Partikel.hitung_biaya; i,j,k,l : integer; fit := 0; for i:=0 to karaan-1 do biaya[i]:=0; kapasitas[i]:=0; k:=0; for j:=i*jmlnode to ((i*jmlnode)+jmlnode-1) do if rute[j] = 1 then l:=urutan[j]-jmlnode*i; kapasitas[i]:=kapasitas[i]+unit3.area[unit3.ptr[l]].demand; biaya[i]:=biaya[i]+formtampil.jarak(k,l); k:=l; biaya[i]:=biaya[i]+formtampil.jarak(k,0); fit := fit + biaya[i]; procedure TFormTampil.inisialisasi(); i : integer; //inisialisasi iabel alpha := strtofloat(txtalpha.text); beta := strtofloat(txtbeta.text);
L 5 w := strtofloat(txtw.text); c1 := strtofloat(txtc1.text); c2 := strtofloat(txtc2.text); jmlpartikel := strtoint(txtjum.text); karaan := strtoint(txtkaraan.text); max_iterasi := strtoint(txtiterasi.text); setlength(obyek,jmlpartikel); setlength(waktu,jmlnode+1,jmlnode+1); //inisialisasi maksimum demand dan waktu yang diperbolehkan tiap rute max_demand := strtofloat(txtkap.text); max_jarak := strtofloat(txtjarak.text); //inisialisasi obyek for i := 0 to jmlpartikel-1 do obyek[i] := Partikel.Create; setlength(obyek[i].rute,jmlnode*karaan); setlength(obyek[i].urutan,jmlnode*karaan); setlength(obyek[i].biaya,karaan); setlength(obyek[i].velocity,jmlnode*karaan); setlength(obyek[i].urutan_lbest,jmlnode*karaan); setlength(obyek[i].lbest,jmlnode*karaan); setlength(obyek[i].biaya_lbest,karaan); setlength(obyek[i].kapasitas,karaan); setlength(obyek[i].kapasitas_lbest,karaan); //inisialisasi gbest setlength(gbest,jmlnode*karaan); setlength(urutan_gbest,jmlnode*karaan); setlength(biaya_gbest,karaan); setlength(kapasitas_gbest,karaan); fit_gbest := high(integer); procedure TFormTampil.FormCreate(Ser: TObject); memo1.lines.clear; //inisialisasi iabel txtalpha.text := '0.3'; txtbeta.text := '0.7'; txtw.text := '0.2'; txtc1.text := '0.3'; txtc2.text := '0.5';
L 6 txtjum.text := '30'; txtkap.text := '7'; txtjarak.text := '999'; txtkaraan.text := '2'; txtiterasi.text := '100'; cek := 0; cmdfull.enabled := false; cmdimage.enabled := false; procedure TFormTampil.cmdExitClick(Ser: TObject); unit2.formutama.show; formtampil.hide; procedure TFormTampil.cmdInisialClick(Ser: TObject); i : integer; k1,k2 : real; x,y : integer; panjang : integer; rg : TRect; memo1.lines.clear; progressbar1.smooth := true; //bersihkan kanvas rg.top := 0; rg.bottom := Image1.Height; rg.left := 0; rg.right := Image1.Width; Image1.Canvas.Brush.Color := clwhite; Image1.Canvas.FillRect(rg); Image1.Canvas.Brush.Color := clblack; image1.canvas.font.color := clblack; inisialisasi(); k1 := alpha+beta; k2 := w+c1+c2; if (k1 = 1.0) and (k2 = 1.0) then for i:=0 to jmlnode do x := 370;
y := 70; x := x+round(unit3.area[unit3.ptr[i]].x*25); y := y-round(unit3.area[unit3.ptr[i]].y*25); if i = 0 then image1.canvas.brush.color := clred; image1.canvas.ellipse(x-5,y-5,x+5,y+5); image1.canvas.brush.color := clwhite; panjang := length(unit3.area[unit3.ptr[i]].nama); image1.canvas.textout(x-panjang*3,y+6,unit3.area[unit3.ptr[i]].nama); else image1.canvas.brush.color := clblack; image1.canvas.ellipse(x-4,y-4,x+4,y+4); image1.canvas.brush.color := clwhite; panjang := length(unit3.area[unit3.ptr[i]].nama); if unit3.ptr[i] = 7 then x := x-30-panjang; y := y-5; else if (unit3.ptr[i] = 8) then x := x+1; y := y+3; else if (unit3.ptr[i] = 3) or (unit3.ptr[i] = 4) or (unit3.ptr[i] = 16) or (unit3.ptr[i] = 20) or (unit3.ptr[i] = 25) then x := x-panjang*3; y := y-20; else if unit3.ptr[i] = 10 then x := x-panjang*2; y := y+5; else if unit3.ptr[i] = 6 then x := x-panjang; y := y+5; else x := x-panjang*3; L 7
L 8 y := y+5; image1.canvas.textout(x,y,unit3.area[unit3.ptr[i]].nama); cmdfull.enabled := true; else MessageDlg('Alpha + Beta tidak sama dengan 1 atau W + C1 + C2 tidak sama dengan 1',mtWarning,[mbOK],0); procedure TFormTampil.storebest(i: integer); j : integer; panjang : integer; panjang := length(obyek[i].rute); if obyek[i].fit < obyek[i].fit_lbest then //simpan nilai lbest obyek[i].fit_lbest := obyek[i].fit; for j:= 0 to panjang - 1 do obyek[i].lbest[j] := obyek[i].rute[j]; obyek[i].urutan_lbest[j] := obyek[i].urutan[j]; for j:=0 to karaan-1 do obyek[i].kapasitas_lbest[j] := obyek[i].kapasitas[j]; obyek[i].biaya_lbest[j] := obyek[i].biaya[j]; //jika nilai lbest lebih kecil dari gbest maka update nilai gbest if obyek[i].fit_lbest < fit_gbest then fit_gbest := obyek[i].fit_lbest; for j:= 0 to panjang - 1 do gbest[j] := obyek[i].lbest[j]; urutan_gbest[j] := obyek[i].urutan_lbest[j]; for j := 0 to karaan-1 do
L 9 biaya_gbest[j] := obyek[i].biaya_lbest[j]; kapasitas_gbest[j] := obyek[i].kapasitas_lbest[j]; procedure TFormTampil.moveParticle(i: integer); j : integer; panjang : integer; acak : real; vel_l : array of real; vel_g : array of real; randomize; setlength(vel_l,jmlnode*karaan); setlength(vel_g,jmlnode*karaan); panjang := length(obyek[i].velocity); for j := 0 to panjang-1 do //update velocity vel_l[j] := (alpha * obyek[i].lbest[j]) + (beta * (1-obyek[i].lbest[j])); vel_g[j] := (alpha * gbest[j]) + (beta * (1-gbest[j])); obyek[i].velocity[j] := (w * obyek[i].velocity[j]) + (c1 * vel_l[j]) + (c2 * vel_g[j]); //update posisi acak := (random(101))/100; if acak > obyek[i].velocity[j] then obyek[i].rute[j] := 1 else obyek[i].rute[j] := 0; cek_partikel(i); procedure TFormTampil.cek_fitness(i: integer); j : integer; check : boolean; count : integer; randomize; count := 1; repeat cek_partikel(i); check:=true; obyek[i].hitung_biaya;
L 10 for j := 0 to karaan-1 do if obyek[i].biaya[j] > max_jarak then check := false; if obyek[i].kapasitas[j] > max_demand then check := false; if check = false then moveparticle(i); count := count + 1; if count > 1000 then nosol := true; Exit; until check = true; obyek[i].hitung_biaya; storebest(i); procedure TFormTampil.cmdFullClick(Ser: TObject); i,j,k : integer; total,total1,total2 : real; route : string; counter : integer; temp : real; nosol := false; randomize(); memo1.lines.clear; //inisialisasi partikel inisialisasi(); total1 := alpha+beta; total2 := w+c1+c2; if (total1 = 1) and (total2 = 1) then for i := 0 to jmlpartikel-1 do obyek[i].inisial; obyek[i].hitung_biaya;
L 11 cek_fitness(i); if nosol = true then MessageDlg('Tidak ada solusi yang mungkin.'+#13+'rubah nilai jumlah karaan atau maksimum kapasitas atau jarak maksimum',mtwarning,[mbok],0); Exit; storebest(i); //jalankan iterasi i := 1; counter := 0; temp := 0; progressbar1.position := 0; progressbar1.max := max_iterasi; progressbar1.step := 1; repeat for j := 0 to jmlpartikel-1 do moveparticle(j); obyek[j].hitung_biaya; nosol := false; cek_fitness(j); if nosol = true then obyek[i].inisial; obyek[j].hitung_biaya; cek_fitness(j); storebest(j); tukar(j); if temp = 0 then temp := fit_gbest; else if temp > 0 then if fit_gbest < temp then temp := fit_gbest; counter := 0; else counter := counter + 1;
L 12 i := i+1; progressbar1.stepit; until (counter > 30) or (i > max_iterasi); progressbar1.position := max_iterasi; //cetak biaya total:=0; for j := 0 to karaan-1 do total := total + biaya_gbest[j]; memo1.lines.add(format('jarak gbest karaan ke-%d adalah %0.2f',[j+1,biaya_gbest[j]])); memo1.lines.add(format('kapasitas gbest rute ke-%d adalah %0.2f',[j+1,kapasitas_gbest[j]])); memo1.lines.add(''); memo1.lines.add(format('jarak gbest adalah %0.2f',[total])); memo1.lines.add(''); for i:=0 to karaan-1 do if biaya_gbest[i] <> 0 then route := unit3.area[0].nama + ' - '; memo1.lines.add(format('rute ke-%d :',[i+1])); for j := i*jmlnode to ((i+1)*jmlnode)-1 do if gbest[j] = 1 then k := urutan_gbest[j] - i*jmlnode; route := route + unit3.area[unit3.ptr[k]].nama + ' - '; route := route + unit3.area[0].nama; memo1.lines.add(route); memo1.lines.add(''); else memo1.lines.add(format('karaan ke-%d tidak diperlukan',[i+1])); memo1.lines.add(''); cmdimage.enabled := true;
L 13 else MessageDlg('Alpha + Beta tidak sama dengan 1 atau W + C1 + C2 tidak sama dengan 1',mtWarning,[mbOK],0); procedure TFormTampil.cek_partikel(i: integer); j,k : integer; acak : integer; check,check2 : boolean; randomize(); if karaan = 1 then for j := 0 to jmlnode -1 do obyek[i].rute[j] := 1; else for j:=0 to jmlnode-1 do check := false; check2 := false; if obyek[i].rute[j] = 0 then for k:=1 to karaan-1 do if obyek[i].rute[j+k*jmlnode] = 0 then check := true; if obyek[i].rute[j+k*jmlnode] = 1 then check := false; check2 := true; if check = true then acak := random(karaan); obyek[i].rute[j+acak*jmlnode] := 1; if check2 = true then acak:=random(karaan); for k:=0 to karaan-1 do
L 14 obyek[i].rute[j+k*jmlnode] := 0; obyek[i].rute[j+acak*jmlnode] := 1; if obyek[i].rute[j] = 1 then for k:=0 to karaan-1 do if obyek[i].rute[j+k*jmlnode] = 1 then check := true; if check = true then acak:=random(karaan); for k:=0 to karaan-1 do obyek[i].rute[j+k*jmlnode] := 0; obyek[i].rute[j+acak*jmlnode] := 1; procedure TFormTampil.tukar(i: integer); j,k,l,m,n : integer; temp : integer; panjang : integer; urut,rute : array of integer; v : array of real; a : array of integer; tem : real; cost : array of real; cap : array of real; total1 : real; r : integer; del : real; check : boolean; panjang := length(obyek[i].urutan); setlength(rute,panjang); setlength(urut,panjang); setlength(v,panjang);
L 15 setlength(a,jmlnode); for j:=0 to panjang-1 do rute[j] := obyek[i].rute[j]; urut[j] := obyek[i].urutan[j]; v[j] := obyek[i].velocity[j]; r := 0; repeat for j:=0 to jmlnode-1 do repeat check := true; a[j] := random(jmlnode)+1; if j>0 then for k:=0 to j-1 do if a[j] = a[k] then check := false; until check = true; for j:=0 to karaan-1 do k := j*jmlnode; while k < (j+1)*jmlnode - 1 do if k = (j+1)*jmlnode then k := j*jmlnode; l := k-j*jmlnode; m := (j*jmlnode)+a[l]-1; n := (j*jmlnode)+a[l+1]-1; temp := urut[m]; urut[m] := urut[n]; urut[n] := temp; temp := rute[m]; rute[m] := rute[n]; rute[n] := temp; tem := v[m]; v[m] := v[n]; v[n] := tem; k := k + 2;
L 16 //hitung biaya temp setlength(cost,karaan); setlength(cap,karaan); check := true; total1 := 0; for j:=0 to karaan-1 do cost[j] := 0; cap[j] := 0; l:=0; for k:=j*jmlnode to ((j*jmlnode)+jmlnode-1) do if rute[k] = 1 then m:=urut[k]-jmlnode*j; cap[j]:=cap[j]+unit3.area[unit3.ptr[m]].demand; cost[j]:=cost[j]+jarak(l,m); l:=m; cost[j]:=cost[j]+jarak(l,0); if cap[j] > max_demand then check := false; if cost[j] > max_jarak then check := false; total1 := total1 + cost[j]; if check = true then del := total1 - obyek[i].fit; if del < 0 then for j:=0 to panjang-1 do obyek[i].rute[j] := rute[j]; obyek[i].urutan[j] := urut[j]; obyek[i].hitung_biaya; cek_fitness(i); storebest(i); r := r + 1; until r > 50;//jmlNode*5; procedure TFormTampil.cmdImageClick(Ser: TObject);
L 17 i,j,k : integer; x,y,x1,y1 : integer; rg : TRect; panjang : integer; rg.top := 0; rg.bottom := Image1.Height; rg.left := 0; rg.right := Image1.Width; Image1.Canvas.Brush.Color := clwhite; Image1.Canvas.FillRect(rg); Image1.Canvas.Brush.Color := clblack; for i:=0 to jmlnode do x := 370; y := 70; x := x+round(unit3.area[unit3.ptr[i]].x*25); y := y-round(unit3.area[unit3.ptr[i]].y*25); if i = 0 then image1.canvas.brush.color := clred; image1.canvas.ellipse(x-5,y-5,x+5,y+5); image1.canvas.brush.color := clwhite; panjang := length(unit3.area[unit3.ptr[i]].nama); image1.canvas.textout(x-panjang*3,y+6,unit3.area[unit3.ptr[i]].nama); else image1.canvas.brush.color := clblack; image1.canvas.ellipse(x-4,y-4,x+4,y+4); image1.canvas.brush.color := clwhite; panjang := length(unit3.area[unit3.ptr[i]].nama); if unit3.ptr[i] = 7 then x := x-30-panjang; y := y-5; else if (unit3.ptr[i] = 8) then x := x+1; y := y+3; else if (unit3.ptr[i] = 3) or (unit3.ptr[i] = 4) or (unit3.ptr[i] = 16) or (unit3.ptr[i] = 20) or (unit3.ptr[i] = 25) then
x := x-panjang*3; y := y-20; else if unit3.ptr[i] = 10 then x := x-panjang*2; y := y+5; else if unit3.ptr[i] = 6 then x := x-panjang; y := y+5; else x := x-panjang*3; y := y+5; image1.canvas.textout(x,y,unit3.area[unit3.ptr[i]].nama); for i:=0 to karaan-1 do image1.canvas.pen.color := RGB(random(256),random(256),random(256)); x := 370; y := 70; image1.canvas.moveto(x,y); for j := i*jmlnode to ((i+1)*jmlnode)-1 do if gbest[j] = 1 then x1 := 370; y1 := 70; k := urutan_gbest[j]-i*jmlnode; x1 := x1+round(unit3.area[unit3.ptr[k]].x*25); k := urutan_gbest[j]-i*jmlnode; y1 := y1-round(unit3.area[unit3.ptr[k]].y*25); image1.canvas.lineto(x1,y1); image1.canvas.moveto(x1,y1); image1.canvas.lineto(x,y); MessageDlg(format('rute ke%d',[i+1]),mtinformation,[mbok],0); image1.canvas.pen.color := clblack; L 18
L 19. Unit2.pas unit Unit2; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Menus, StdCtrls, ExtCtrls; type TFormUtama = class(tform) MainMenu1: TMainMenu; mmpso: TMenuItem; mmpsocalculate: TMenuItem; mmpsoquit: TMenuItem; mmabout: TMenuItem; Label1: TLabel; Label2: TLabel; Label3: TLabel; pabout: TPanel; paboutok: TButton; Memo1: TMemo; mmpsoinput: TMenuItem; procedure mmpsocalculateclick(ser: TObject); procedure mmpsoquitclick(ser: TObject); procedure paboutokclick(ser: TObject); procedure mmaboutclick(ser: TObject); procedure FormCreate(Ser: TObject); procedure mmpsoinputclick(ser: TObject); private { Private declarations } public { Public declarations } FormUtama: TFormUtama; implementation uses skrp,unit3;
L 20 {$R *.dfm} procedure TFormUtama.mmPSOCalculateClick(Ser: TObject); skrp.formtampil.show; formutama.hide; procedure TFormUtama.mmPSOQuitClick(Ser: TObject); if messagedlg('anda yakin mau keluar?',mtconfirmation,[mbyes,mbno],0) = mryes then application.terminate; procedure TFormUtama.pAboutOKClick(Ser: TObject); pabout.hide; procedure TFormUtama.mmAboutClick(Ser: TObject); pabout.show; pabout.bringtofront; pabout.align := alclient; paboutok.setfocus; procedure TFormUtama.FormCreate(Ser: TObject); pabout.hide; mmpsocalculate.enabled := false; procedure TFormUtama.mmPSOInputClick(Ser: TObject); skrp.formtampil.cmdfull.enabled := false; skrp.formtampil.cmdimage.enabled := false; unit3.forminput.show; formutama.hide;. Unit3.pas
L 21 unit Unit3; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, Math; type Node = class nama : string; x : real; y : real; demand : real; TFormInput = class(tform) cmdexit: TButton; Button1: TButton; CheckBox1: TCheckBox; Label1: TLabel; CheckBox2: TCheckBox; CheckBox3: TCheckBox; CheckBox4: TCheckBox; CheckBox5: TCheckBox; CheckBox6: TCheckBox; CheckBox7: TCheckBox; CheckBox8: TCheckBox; CheckBox9: TCheckBox; CheckBox10: TCheckBox; CheckBox11: TCheckBox; CheckBox12: TCheckBox; CheckBox13: TCheckBox; CheckBox14: TCheckBox; CheckBox15: TCheckBox; CheckBox16: TCheckBox; CheckBox17: TCheckBox; CheckBox18: TCheckBox; CheckBox19: TCheckBox; CheckBox20: TCheckBox; CheckBox21: TCheckBox; CheckBox22: TCheckBox; CheckBox23: TCheckBox; CheckBox24: TCheckBox; CheckBox25: TCheckBox; CheckBox26: TCheckBox; CheckBox27: TCheckBox;
CheckBox28: TCheckBox; CheckBox29: TCheckBox; CheckBox30: TCheckBox; CheckBox31: TCheckBox; Edit1: TEdit; Edit2: TEdit; Edit3: TEdit; Edit4: TEdit; Edit5: TEdit; Edit6: TEdit; Edit7: TEdit; Edit8: TEdit; Edit9: TEdit; Edit10: TEdit; Edit11: TEdit; Edit12: TEdit; Edit13: TEdit; Edit14: TEdit; Edit15: TEdit; Edit16: TEdit; Edit17: TEdit; Edit18: TEdit; Edit19: TEdit; Edit20: TEdit; Edit21: TEdit; Edit22: TEdit; Edit23: TEdit; Edit24: TEdit; Edit25: TEdit; Edit26: TEdit; Edit27: TEdit; Edit28: TEdit; Edit29: TEdit; Edit30: TEdit; Edit31: TEdit; Label2: TLabel; Label3: TLabel; Label4: TLabel; Button2: TButton; procedure cmdexitclick(ser: TObject); procedure FormCreate(Ser: TObject); procedure Button1Click(Ser: TObject); procedure Button2Click(Ser: TObject); private { Private declarations } public L 22
L 23 { Public declarations } FormInput: TFormInput; counter : integer; area : array of node; ptr : array of integer; implementation uses unit2,skrp; {$R *.dfm} procedure TFormInput.cmdExitClick(Ser: TObject); unit2.formutama.show; forminput.hide; procedure TFormInput.FormCreate(Ser: TObject); i : integer; skrp.jmlnode := 31; for i := 1 to 31 do TCheckBox(FindComponent('checkbox' + inttostr(i))).checked := false; setlength(area,jmlnode+1); for i:=0 to jmlnode do area[i] := Node.Create; area[i].demand := 0; area[0].nama := 'Depot'; area[1].nama := 'Penjaringan'; area[2].nama := 'Tanjung Priok'; area[3].nama := 'Pademangan'; area[4].nama := 'Tambora'; area[5].nama := 'Kelapa Gading'; area[6].nama := 'Cempaka Putih'; area[7].nama := 'Senen'; area[8].nama := 'Sawah Besar'; area[9].nama := 'Taman Sari'; area[10].nama := 'Kemayoran';
area[11].nama := 'Kota'; area[12].nama := 'Tanah Abang'; area[13].nama := 'Johar Baru'; area[14].nama := 'Pulogadung'; area[15].nama := 'Duren Sawit'; area[16].nama := 'Jatinegara'; area[17].nama := 'Otista'; area[18].nama := 'Kramat Jati'; area[19].nama := 'Pasar Rebo'; area[20].nama := 'Tebet'; area[21].nama := 'Mampang'; area[22].nama := 'Pasar Minggu'; area[23].nama := 'Cilandak'; area[24].nama := 'Kebayoran Lama'; area[25].nama := 'Kebayoran Baru'; area[26].nama := 'Ciputat'; area[27].nama := 'Cengkareng'; area[28].nama := 'Kalideres'; area[29].nama := 'Grogol'; area[30].nama := 'Kebon Jeruk'; area[31].nama := 'Palmerah'; area[0].x := 0; area[0].y := 0; area[1].x := -6; area[1].y := 1; area[2].x := 0; area[2].y := 2; area[3].x := -3; area[3].y := 0; area[4].x := -6; area[4].y := -1; area[5].x := 2; area[5].y := -2; area[6].x := -1; area[6].y := -2.5; area[7].x := -2.5; area[7].y := -2.5; area[8].x := -3.5; area[8].y := -1.5; area[9].x := -4.6; area[9].y := -1.4; area[10].x := -2; area[10].y := -0.8; area[11].x := -4.4; area[11].y := -0.3; area[12].x := -5.5; L 24
L 25 area[12].y := -3.2; area[13].x := -1.5; area[13].y := -3.4; area[14].x := 2.5; area[14].y := -3.6; area[15].x := 2.2; area[15].y := -6.8; area[16].x := -0.5; area[16].y := -6.2; area[17].x := -1.1; area[17].y := -6.9; area[18].x := -1; area[18].y := -9.5; area[19].x := -0.9; area[19].y := -11.2; area[20].x := -2.6; area[20].y := -7.4; area[21].x := -2.8; area[21].y := -8; area[22].x := -4.2; area[22].y := -10.3; area[23].x := -6; area[23].y := -11.1; area[24].x := -8.2; area[24].y := -7.6; area[25].x := -6.1; area[25].y := -7.4; area[26].x := -9; area[26].y := -13.2; area[27].x := -12; area[27].y := 0; area[28].x := -13.5; area[28].y := -0.9; area[29].x := -6.5; area[29].y := -1.9; area[30].x := -8.4; area[30].y := -4.3; area[31].x := -6.7; area[31].y := -5; procedure TFormInput.Button1Click(Ser: TObject); cek : boolean; i : integer;
L 26 setlength(ptr,0); counter := 0; for i := 1 to 31 do if TCheckBox(FindComponent('checkbox' + inttostr(i))).checked = true then counter := counter + 1; if counter = 0 then MessageDlg('Harap pilih daerah untuk pengiriman',mtwarning,[mbok],0); else skrp.jmlnode := counter; setlength(ptr,skrp.jmlnode+1); counter :=1; ptr[0] := 0; cek := false; for i := 1 to 31 do if TCheckBox(FindComponent('checkbox' + inttostr(i))).checked = true then if TEdit(FindComponent('edit'+inttostr(i))).text <> '' then ptr[counter] := i; counter:=counter+1; cek := true; area[i].demand := strtofloat(tedit(findcomponent('edit'+inttostr(i))).text); else cek := false; if cek = true then MessageDlg('Input Berhasil...',mtInformation,[mbOK],0); unit2.formutama.mmpsocalculate.enabled := true; else MessageDlg('Harap masukkan permintaan untuk daerah yang dipilih',mtwarning,[mbok],0); procedure TFormInput.Button2Click(Ser: TObject);
L 27 i : integer; for i := 1 to 31 do TCheckBox(FindComponent('checkbox' + inttostr(i))).checked := false; TEdit(FindComponent('edit'+inttostr(i))).Text := '';.