• Tidak ada hasil yang ditemukan

Perbandingan Algoritma Greedy dan Hill Climbing Untuk Menentukan Fasilitas Kesehatan Tingkat Pertama (FKTP) Terdekat Bagi Peserta BPJS Kesehatan

N/A
N/A
Protected

Academic year: 2017

Membagikan "Perbandingan Algoritma Greedy dan Hill Climbing Untuk Menentukan Fasilitas Kesehatan Tingkat Pertama (FKTP) Terdekat Bagi Peserta BPJS Kesehatan"

Copied!
30
0
0

Teks penuh

(1)

LISTING PROGRAM

DatabaseHelper.cs

using System;

using System.Collections.Generic; using System.Data.SQLite;

using System.IO;

using System.Windows.Forms;

namespace Skripsi {

/// <summary>

/// Description of DatabaseHelper. /// </summary>

public class DatabaseHelper {

string TABEL_1 = "TABEL_NODE"; string TABEL_2 = "TABEL_KONEKSI";

SQLiteConnection sql;

public DatabaseHelper() {

bool baruDibuat = false; if(!File.Exists("db.sqlite")){ baruDibuat = true;

SQLiteConnection.CreateFile("db.sqlite"); }

sql = new SQLiteConnection("Data Source=db.sqlite;Version=3;"); sql.Open();

if(baruDibuat){

(2)

+ "alamat TEXT," + "x REAL," + "y REAL," + "wilayah TEXT" + ")";

SQLiteCommand sqlCommand = new SQLiteCommand(sqlSyntax, sql); if(sqlCommand.ExecuteNonQuery() <= 0)

MessageBox.Show("Gagal membuat tabel node");

sqlSyntax = "CREATE TABLE " + TABEL_2 + " (" + "id INTEGER primary key AUTOINCREMENT," + "idAwal INTEGER,"

+ "idAkhir INTEGER," + "jarak REAL" + ")";

sqlCommand = new SQLiteCommand(sqlSyntax, sql); if(sqlCommand.ExecuteNonQuery() <= 0)

MessageBox.Show("Gagal membuat tabel Koneksi"); }

}

public List<Node> ambilSemuaNode(){ List<Node> hasil = new List<Node>();

List<DataKoneksi> koneksi = new List<DataKoneksi>();

String sqlSyntax = "SELECT * FROM " + TABEL_1;

SQLiteCommand sqlCommand = new SQLiteCommand(sqlSyntax, sql); SQLiteDataReader sqlReader = sqlCommand.ExecuteReader();

while(sqlReader.Read()){

Node newNode = new Node(int.Parse(sqlReader["id"].ToString()), sqlReader["nama"].ToString(),

sqlReader["alamat"].ToString(), float.Parse(sqlReader["x"].ToString()), float.Parse(sqlReader["y"].ToString()), sqlReader["wilayah"].ToString() );

(3)

koneksi = ambilSemuaKoneksi(); foreach(Node node in hasil){

foreach(DataKoneksi data in koneksi){ Node asal = new Node(),

tujuan = new Node();

foreach(Node node_pencarian in hasil){ if(node_pencarian.getId() == data.idAwal){ asal = node_pencarian;

}

if(node_pencarian.getId() == data.idTujuan){ tujuan = node_pencarian;

} }

if(data.idAwal == node.getId()){

node.tambahHubungan(tujuan, data.jarak); } elseif(data.idTujuan == node.getId()){ node.tambahHubungan(asal, data.jarak); }

} }

return hasil; }

public List<DataKoneksi> ambilSemuaKoneksi(){ List<DataKoneksi> hasil = new List<DataKoneksi>();

String sqlSyntax = "SELECT tbl2.id AS id, tbl2.idAwal AS idAwal, tbl3.nama AS asal, tbl2.idAkhir AS idTujuan, tbl4.nama AS tujuan, tbl2.jarak AS jarak " +

"FROM " + TABEL_2 + " AS tbl2, (SELECT * FROM " + TABEL_1 + ") AS tbl3, (SELECT * FROM " + TABEL_1 + ") AS tbl4 " +

"WHERE idAwal = tbl3.id AND idTujuan = tbl4.id";

SQLiteCommand sqlCommand = new SQLiteCommand(sqlSyntax, sql); SQLiteDataReader sqlReader = sqlCommand.ExecuteReader();

while(sqlReader.Read()){ hasil.Add(new DataKoneksi(

(4)

sqlReader["asal"].ToString(),

int.Parse(sqlReader["idTujuan"].ToString()), sqlReader["tujuan"].ToString(),

float.Parse(sqlReader["jarak"].ToString()) ));

}

return hasil; }

publicboolhapusNode(int id){

String sqlSyntax = "DELETE FROM " + TABEL_1 + " WHERE id = " + id; SQLiteCommand sqlCommand = new SQLiteCommand(sqlSyntax, sql); if(sqlCommand.ExecuteNonQuery() > 0){

return true; } else {

return false; }

}

publicboolhapusKoneksi(int idKoneksi){

String sqlSyntax = "DELETE FROM " + TABEL_2 + " WHERE id = " + idKoneksi; SQLiteCommand sqlCommand = new SQLiteCommand(sqlSyntax, sql); if(sqlCommand.ExecuteNonQuery() > 0){

return true; } else {

return false; }

}

publicboolupdateNode(int id, Node newNode){ String sqlSyntax = "UPDATE " + TABEL_1 + " SET " + " nama='" + newNode.getNama() + "'," + " alamat='" + newNode.getAlamat() + "'," + " x=" + newNode.getX() + ","

+ " y=" + newNode.getY() + ","

+ " wilayah='" + newNode.getWilayah() + "'" + " WHERE id = " + id;

SQLiteCommand sqlCommand = new SQLiteCommand(sqlSyntax, sql); if(sqlCommand.ExecuteNonQuery() > 0){

(5)

return false; }

}

publicboolupdateNode(int id, String nama, String alamat, float x, float y, String wilayah){

String sqlSyntax = "UPDATE " + TABEL_1 + " SET " + " nama='" + nama + "',"

+ " alamat='" + alamat + "'," + " x=" + x + ","

+ " y=" + y + ","

+ " wilayah='" + wilayah + "'" + " WHERE id = " + id;

SQLiteCommand sqlCommand = new SQLiteCommand(sqlSyntax, sql); if(sqlCommand.ExecuteNonQuery() > 0){

return true; } else {

return false; }

}

publicboolupdateKoneksi(int id, int idAwal, int idTujuan, float jarak){ String sqlSyntax = "UPDATE " + TABEL_2 + " SET "

+ " idAwal=" + idAwal + "," + " idAkhir=" + idTujuan + "," + " jarak=" + jarak

+ " WHERE id = " + id;

SQLiteCommand sqlCommand = new SQLiteCommand(sqlSyntax, sql); if(sqlCommand.ExecuteNonQuery() > 0){

return true; } else {

return false; }

}

publicbooltambahNode(Node node){

String sqlSyntax = "INSERT INTO " + TABEL_1 + "(nama, alamat, x, y, wilayah) VALUES ("

(6)

+ node.getY() + ", "

+ "'" + node.getWilayah() + "'" + ")";

SQLiteCommand sqlCommand = new SQLiteCommand(sqlSyntax, sql); if(sqlCommand.ExecuteNonQuery() > 0){

return true; } else {

return false; }

}

publicbooltambahNode(String nama, String alamat, float x, float y, String wilayah){ String sqlSyntax = "INSERT INTO " + TABEL_1 + "(nama, alamat, x, y, wilayah) VALUES ("

+ "'" + nama + "', " + "'" + alamat + "', " + x + ", "

+ y + ", "

+ "'" + wilayah + "'" + ")";

SQLiteCommand sqlCommand = new SQLiteCommand(sqlSyntax, sql); if(sqlCommand.ExecuteNonQuery() > 0){

return true; } else {

return false; }

}

publicbooltambahKoneksi(int idAwal, int idAkhir, float jarak){

String sqlSyntax = "INSERT INTO " + TABEL_2 + "(idAwal, idAkhir, jarak) VALUES (" + idAwal + ", "

+ idAkhir + ", " + jarak + ")";

SQLiteCommand sqlCommand = new SQLiteCommand(sqlSyntax, sql); if(sqlCommand.ExecuteNonQuery() > 0){

(7)

} } } }

DataKoneksi.cs

using System;

namespace Skripsi {

/// <summary>

/// Description of DataKoneksi. /// </summary>

public class DataKoneksi {

publicintid, idAwal, idTujuan; public String asal, tujuan; publicfloatjarak;

public DataKoneksi() {

}

public DataKoneksi(int id, int idAwal, String asal, int idTujuan, String tujuan, float jarak){ this.id = id;

this.idAwal = idAwal; this.asal = asal;

this.idTujuan = idTujuan; this.tujuan = tujuan; this.jarak = jarak; }

} }

(8)

using System.Collections.Generic; using System.Diagnostics;

namespace Skripsi {

/// <summary>

/// Description of Greedy. /// </summary>

public class Greedy {

List<Node> semuaNode; public List<Node> hasil; publicfloattotalJarak;

publicTimeSpanrunningTime;

public Greedy() {

}

public Greedy(List<Node> semuaNode){ this.semuaNode = semuaNode; this.hasil = new List<Node>(); this.totalJarak = 0;

}

publicboolcariRuteTerpendek(Node asal, String tujuan){

Node nodeAktif = asal; hasil.Add(asal);

Stopwatch startTime = Stopwatch.StartNew();

while(!nodeAktif.getWilayah().Equals(tujuan) || asal == nodeAktif){

float jarakMinimum = float.PositiveInfinity; Node nodeTerdekat = null;

foreach(Hubungan hub in nodeAktif.getHubungan()){

if(hub.getJarak() < jarakMinimum && !hasil.Contains(hub.getNode())){ jarakMinimum = hub.getJarak();

(9)

}

totalJarak = jarakMinimum == float.PositiveInfinity ? (totalJarak + 0) : (totalJarak + jarakMinimum);

nodeAktif = nodeTerdekat;

if(nodeAktif == null){ startTime.Stop();

runningTime = startTime.Elapsed; return false;

} else {

hasil.Add(nodeAktif); }

}

startTime.Stop();

runningTime = startTime.Elapsed; return true;

} } }

HillClimbing.cs

using System;

using System.Collections.Generic; using System.Diagnostics;

namespace Skripsi {

/// <summary>

/// Description of Hill Climbing. /// </summary>

public class HillClimbing {

public class UjiSampel { List<int> ruteId;

(10)

public UjiSampel(){

this.ruteId = new List<int>(); jarak = 0;

nodeAkhir = new Node(); }

public UjiSampel(List<int> rute){ this.ruteId = new List<int>(rute); jarak = 0;

nodeAkhir = new Node(); }

public void tambahRute(int id){ this.ruteId.Add(id);

}

public List<int> getRute(){ return this.ruteId; }

}

List<UjiSampel> Q;

public UjiSampel hasil = new UjiSampel(); publicTimeSpanrunningTime;

Node s, g;

public List<Node> rute; List<int> ruteAktif;

public HillClimbing() {

Q = new List<UjiSampel>(); rute = new List<Node>(); runningTime = newTimeSpan();

(11)

publicboolcariRuteTerpendek(Node asal, Node tujuan){ var watch = System.Diagnostics.Stopwatch.StartNew();

s = asal; g = tujuan;

UjiSampel current = new UjiSampel(); UjiSampel temp = new UjiSampel();

current.nodeAkhir = asal; ruteAktif.Add(s.getId());

List<Node> yangSudahDikerjakan = new List<Node>();

while(true){

if(current.nodeAkhir == tujuan){ hasil = current;

watch.Stop();

runningTime = watch.Elapsed;

return true; } else {

foreach(Hubungan hubungan in current.nodeAkhir.getHubungan()){

bool sudahDilewati = false;

foreach(Node node in yangSudahDikerjakan){ if(node.getId() == hubungan.getNode().getId()){ sudahDilewati = true;

break; }

}

if(sudahDilewati) continue;

UjiSampel sampel = new UjiSampel(ruteAktif);

(12)

sampel.jarak = current.jarak + hubungan.getJarak(); sampel.tambahRute(hubungan.getNode().getId());

if(Q.Count == 0){ Q.Add(sampel); continue; }

for(int i = 0; i < Q.Count; i++){

if(sampel.jarak.CompareTo(Q[i].jarak) == -1){ Q.Insert(i, sampel);

break; }

if(i == (Q.Count - 1)){ Q.Add(sampel); break;

} } } }

yangSudahDikerjakan.Add(current.nodeAkhir);

if(Q.Count == 0) return false; else {

ruteAktif.Clear();

foreach(int id inQ[0].getRute()){ ruteAktif.Add(id);

}

current = Q[0]; Q.RemoveAt(0); }

} }

(13)

Hubungan.cs

using System;

using System.Collections.Generic;

namespace Skripsi {

/// <summary>

/// Description of Hubungan. /// </summary>

public class Hubungan {

Node node; floatjarak;

public Node getNode(){ return node;

}

public void setNode(Node node){ this.node = node;

}

publicfloatgetJarak(){ return this.jarak; }

public void setJarak(float jarak){ this.jarak = jarak;

}

public Hubungan() {

this.node = new Node();

this.jarak = Node.POSITIVE_INFINITY; }

public Hubungan(Node node, float jarak){ this.node = node;

this.jarak = jarak; }

(14)

Map.cs

using System;

using System.Collections.Generic; using System.Windows.Forms; using System.Drawing;

using System.Diagnostics;

using System.Drawing.Drawing2D;

namespace Skripsi {

/// <summary>

/// Description of Map. /// </summary> public class Map {

//MARKER

private static floatmarkerTextSize = 7;

//NODE

private static floatnodeWidth = 20; private static floatnodeHeight = 20; private static intnodeTextSize = 8;

//LINK

private static floatlinkWidth = 1.5F; private static intlinkTextSize = 6;

private static floatdistanceTextBorderWidth = 2F;

private Panel mapContainer; private Brush nodeColor; private Brush linkTextColor; private Brush nodeNameColor; private Brush markerColor; private Brush markerTextColor; private Pen shortestPathColor; private Pen linkColor;

(15)

public Graphics mapGraphics;

public Map(Panel groupBox) {

this.mapContainer = groupBox;

this.mapGraphics = groupBox.CreateGraphics();

this.nodeColor = new SolidBrush(Color.YellowGreen);

this.linkTextColor = new SolidBrush(Color.Black);

this.linkColor = new Pen(Color.Black, linkWidth);

AdjustableArrowCap bigArrow = new AdjustableArrowCap(3, 3); this.linkColor.CustomStartCap = bigArrow;

this.linkColor.CustomEndCap = bigArrow;

this.nodeNameColor = new SolidBrush(Color.Black);

this.markerColor = new SolidBrush(Color.Yellow);

this.markerTextColor = new SolidBrush(Color.Black);

this.linkTextBorderColor = new Pen(Color.Black, distanceTextBorderWidth);

this.popUpBackground = new SolidBrush(Color.DarkGray);

this.popUpTextColor = new SolidBrush(Color.Black);

this.shortestPathColor = new Pen(Color.OrangeRed, 6);

this.shortestPathColor.CustomEndCap = new AdjustableArrowCap(3, 3); }

public void drawPopUp(float x, float y, string msg){

Font popUpFont = new Font(new FontFamily("Segoe UI"), nodeTextSize);

SizeF popUpFontDimension = this.mapGraphics.MeasureString(msg, popUpFont);

this.mapGraphics

.FillRectangle(new SolidBrush(Color.DarkGray), x,

(16)

popUpFontDimension.Width, popUpFontDimension.Height);

this.mapGraphics .DrawString(msg, popUpFont, popUpTextColor, x,

y + popUpFontDimension.Height); }

public void drawPath(List<Node> items){ PointF[] points = newPointF[items.Count]; for(int index = 0; index < items.Count; index++){

points[index] = newPointF(items[index].getX(), items[index].getY()); }

this.mapGraphics

.DrawLines(shortestPathColor, points); }

public void drawPath(List<Node> items, Pen color){ PointF[] points = newPointF[items.Count]; for(int index = 0; index < items.Count; index++){

points[index] = newPointF(items[index].getX(), items[index].getY()); }

this.mapGraphics

.DrawLines(color, points); }

public void drawNode(float x, float y, string id, Brush ndColor){ try {

this.mapGraphics

.FillEllipse(ndColor, newRectangleF(x - (float)(nodeWidth / 2.0), y - (float)(nodeHeight / 2.0),

nodeWidth, nodeHeight));

(17)

float nodeFontHeight = this.mapGraphics.MeasureString(id, nodeFont).Height;

this.mapGraphics

.DrawString(id.ToString(), nodeFont,

nodeNameColor, x - nodeFontWidth / 2, y - nodeFontHeight / 2);

} catch (Exception e){

MessageBox.Show("Error : " + e.ToString()); }

}

public void drawLink(float x, float y, float x2, float y2, float distance, bool hasil){ try {

Pen routeColor; if(hasil){

routeColor = shortestPathColor; } else {

routeColor = linkColor; }

this.mapGraphics

.DrawLine(routeColor, x,

y, x2, y2);

} catch (Exception e){

MessageBox.Show("Error : " + e.ToString()); }

}

public void drawDistance(float x, float y, float x2, float y2, float distance){

Font linkFont = new Font(new FontFamily("Segoe UI"), linkTextSize); SizeF linkFontDimension = new

(18)

float posx = ( x + x2 ) / 2; float posy = ( y + y2 ) / 2;

float textCircleWidth = linkFontDimension.Width; float textCircleHeight = linkFontDimension.Height;

this.mapGraphics

.FillEllipse(new SolidBrush(Color.White), posx - (textCircleWidth / 2), posy - (textCircleHeight / 2), textCircleWidth,

textCircleHeight );

this.mapGraphics

.DrawString(distance.ToString(), linkFont,

linkTextColor,

newPointF(posx - (linkFontDimension.Width / 2), posy - (linkFontDimension.Height / 2) )

); }

public void drawMarker(string sign, float x, float y){

Font markerFont = new Font(new FontFamily("Segoe UI"), markerTextSize); SizeF markerFontDimension = this.mapGraphics.MeasureString(sign, markerFont);

this.mapGraphics.FillRectangle(markerColor,

x - markerFontDimension.Width / 2, y + markerFontDimension.Height / 2, markerFontDimension.Width, markerFontDimension.Height);

this.mapGraphics.DrawString(sign, markerFont, markerTextColor,

(19)

public void updateViewPosition(){ this.mapGraphics.Clear(Color.White);

this.mapGraphics = this.mapContainer.CreateGraphics();

this.mapGraphics.TranslateTransform(this.mapContainer.AutoScrollPosition.X, this.mapContainer.AutoScrollPosition.Y );

} } }

Node.cs

using System;

using System.Collections.Generic;

namespace Skripsi {

/// <summary>

/// Node menandakan vertex

/// Masing-masing vertex memiliki id, nama, alamat, posisi x dan y serta koneksi /// ke node lainnya.

///

/// </summary> ///

public class Node {

public static floatPOSITIVE_INFINITY = float.PositiveInfinity;

intid;

String nama, alamat, wilayah; floatx, y, lat, lng;

List<Hubungan> hubungan;

public Node() {

}

(20)

this.nama = nama; this.alamat = alamat; this.x = x;

this.y = y;

this.wilayah = wilayah;

this.hubungan = new List<Hubungan>(); }

publicintgetId(){ return this.id; }

public String getAbjad(){ return this.id.ToString(); }

public String getNama() { return this.nama; } public String getAlamat() { return this.alamat; }

public List<Hubungan> getHubungan() { return this.hubungan; } publicfloatgetX() { return this.x; }

publicfloatgetY() { return this.y; } public String getWilayah() { return this.wilayah; }

publicfloatcariJarakKe(int id){

foreach(Hubungan hub inhubungan){

if(hub.getNode().getId() == id){ return hub.getJarak(); }

}

return POSITIVE_INFINITY; }

public void tambahHubungan(Node node, float jarak){ if(node == null){

return; }

this.hubungan.Add(

(21)

} } }

Pengujian.cs

using System;

using System.Collections.Generic; using System.Diagnostics;

using System.Drawing;

using System.Drawing.Drawing2D; using System.Windows.Forms;

namespace Skripsi {

/// <summary>

/// Description of Pengujian. /// </summary>

public partial class Pengujian : Form {

Map map;

List<Node> semuaNode, hasilHillClimbing, tujuanDalamWilayah; DatabaseHelper dbHelper;

Node asal; String tujuan;

HillClimbing algoHillClimbing; Greedy algoGreedy;

boolsolusiHillClimbing, solusiGreedy;

booltampilkanRuteHillClimbing, tampilkanRuteGreedy; floatukuranGaris = 5f;

floatukuranPattern = 5f;

public Pengujian() {

//

// The InitializeComponent() call is required for Windows Forms designer support. //

(22)

map = new Map(panel_graph); dbHelper = new DatabaseHelper();

semuaNode = dbHelper.ambilSemuaNode(); hasilHillClimbing = new List<Node>(); asal = null;

tujuan = null;

tampilkanRuteHillClimbing = cb_hillClimbing.Checked; tampilkanRuteGreedy = cb_greedy.Checked;

isiComboBox(); //

// TODO: Add constructor code after the InitializeComponent() call. //

}

Node ambilNodeBerdasarkanId(int id){ foreach(Node node insemuaNode){ if(node.getId() == id) return node; }

return null; }

void gambarGraph(){

map.mapGraphics.Clear(panel_graph.BackColor);

foreach(Node node insemuaNode){

foreach(Hubungan hubungan in node.getHubungan()){

map.drawLink(node.getX(), node.getY(), hubungan.getNode().getX(), hubungan.getNode().getY(), hubungan.getJarak(), false);

} }

if(solusiHillClimbing && tampilkanRuteHillClimbing){

Pen ruteHillClimbing = new Pen(Color.Blue, ukuranGaris);

(23)

}

if(solusiGreedy && tampilkanRuteGreedy){

Pen ruteGreedy = new Pen(Color.Yellow, ukuranGaris);

ruteGreedy.DashPattern = newfloat[]{ukuranPattern, ukuranPattern}; ruteGreedy.DashOffset = 3 * ukuranGaris * ukuranPattern;

map.drawPath(algoGreedy.hasil, ruteGreedy); }

foreach(Node node insemuaNode){

Brush nodeColor = new SolidBrush(Color.LightGray); if(node.getWilayah().Equals("MEDAN BARAT")){ nodeColor = new SolidBrush(Color.LightBlue); } else

if(node.getWilayah().Equals("MEDAN TIMUR")){ nodeColor = new SolidBrush(Color.LightPink); } else

if(node.getWilayah().Equals("MEDAN HELVETIA")){ nodeColor = new SolidBrush(Color.LightGreen); }

map.drawNode(node.getX(), node.getY(), node.getAbjad(), nodeColor); }

foreach(Node node insemuaNode){

foreach(Hubungan hubungan in node.getHubungan()){

map.drawDistance(node.getX(), node.getY(), hubungan.getNode().getX(), hubungan.getNode().getY(), hubungan.getJarak());

} } }

void isiComboBox(){

combobox_asal_pengujian.DataSource = null;

combobox_asal_pengujian.Items.Clear();

(24)

List<object> items = new List<object>(); foreach(Node node insemuaNode){ items.Add(

new {

Text = node.getNama() + " [" + node.getAbjad() + "] ", Value = node.getId()

} ); }

combobox_asal_pengujian.DataSource = new List<object>(items); }

void Button1Click(object sender, EventArgs e) {

semuaNode = dbHelper.ambilSemuaNode(); panel_graph.Invalidate();

isiComboBox();

solusiGreedy = false; solusiHillClimbing = false; }

void Panel_graphPaint(object sender, PaintEventArgs e) {

gambarGraph(); }

void Combobox_asal_pengujianSelectedIndexChanged(object sender, EventArgs e) {

asal =

ambilNodeBerdasarkanId(Convert.ToInt32(combobox_asal_pengujian.SelectedValue)); panel_graph.Invalidate();

}

void Combobox_tujuan_pengujianSelectedIndexChanged(object sender, EventArgs e) {

tujuan = combobox_tujuan_pengujian.SelectedItem.ToString();

(25)

if(node.getWilayah().Equals(tujuan)) tujuanDalamWilayah.Add(node); }

panel_graph.Invalidate(); }

void Btn_cari_ruteClick(object sender, EventArgs e) {

if(asal != null && tujuan != null){

algoGreedy = new Greedy(semuaNode); algoHillClimbing = new HillClimbing(); solusiHillClimbing = false;

solusiGreedy = true;

float jarakMinimum = float.PositiveInfinity; TimeSpan runningTimeHill;

List<int> idRute = new List<int>();

foreach(Node node intujuanDalamWilayah){ algoHillClimbing = new HillClimbing();

if(node == asal) continue;

if(algoHillClimbing.cariRuteTerpendek(asal, node)){ if(algoHillClimbing.hasil.jarak < jarakMinimum){ runningTimeHill = algoHillClimbing.runningTime; jarakMinimum = algoHillClimbing.hasil.jarak; idRute = algoHillClimbing.hasil.getRute();

solusiHillClimbing = true; }

} }

hasilHillClimbing = new List<Node>(); foreach(int id in idRute){

hasilHillClimbing.Add(ambilNodeBerdasarkanId(id)); }

(26)

listbox_rute_hill_climbing.Items.Add(node.getNama()); }

Node lastItemHillClimbing = hasilHillClimbing.Count > 0 ? hasilHillClimbing[hasilHillClimbing.Count - 1] : new Node(); if(lastItemHillClimbing.getWilayah() == tujuan){

lbl_hasil_hill_climbing.Text = "Node " + lastItemHillClimbing.getId() + " - " + lastItemHillClimbing.getNama().ToUpper() + "\n" +

lastItemHillClimbing.getAlamat().ToUpper(); } else {

lbl_hasil_hill_climbing.Text = "Tidak mencapai tujuan"; }

label_running_time_hill_climbing.Text = algoHillClimbing.runningTime.TotalMilliseconds + " ms";

total_jarak_hill_climbing.Text = jarakMinimum + " km";

algoGreedy.cariRuteTerpendek(asal, tujuan); listbox_rute_greedy.Items.Clear();

foreach(Node node inalgoGreedy.hasil){

listbox_rute_greedy.Items.Add(node.getNama()); }

Node lastItemGreedy = algoGreedy.hasil.Count > 0 ? algoGreedy.hasil[algoGreedy.hasil.Count - 1] : new Node(); if(lastItemGreedy.getWilayah() == tujuan){

lbl_hasil_greedy.Text = "Node " + lastItemGreedy.getId() + " - " +

lastItemGreedy.getNama().ToUpper() + "\n" + lastItemGreedy.getAlamat().ToUpper(); } else {

lbl_hasil_greedy.Text = "Tidak mencapai tujuan"; }

label_running_time_greedy.Text = algoGreedy.runningTime.TotalMilliseconds + " ms";

total_jarak_greedy.Text = algoGreedy.totalJarak + " km"; }

(27)

void Panel_graphMouseMove(object sender, MouseEventArgs e) {

foreach(Node node insemuaNode){ float xStart = node.getX() - (35 / 2.0F), xEnd = xStart + 35,

yStart = node.getY() - (25 / 2.0F), yEnd = yStart + 25;

if( e.X >= xStart && e.X <= xEnd && e.Y >= yStart && e.Y <= yEnd){ label_info_node.Text = node.getNama(); label_info_alamat.Text = node.getAlamat(); return;

} }

label_info_node.Text = ""; label_info_alamat.Text = ""; }

void Cb_bruteforceCheckedChanged(object sender, EventArgs e) {

if(cb_hillClimbing.Checked){

tampilkanRuteHillClimbing = true; } else {

tampilkanRuteHillClimbing = false; }

panel_graph.Invalidate(); }

void Cb_astarCheckedChanged(object sender, EventArgs e) {

if(cb_greedy.Checked){

tampilkanRuteGreedy = true; } else {

tampilkanRuteGreedy = false; }

panel_graph.Invalidate(); }

(28)

Program.cs

using System;

using System.Windows.Forms;

namespace Skripsi {

/// <summary>

/// Class with program entry point. /// </summary>

internal sealed class Program {

/// <summary>

/// Program entry point. /// </summary>

[STAThread]

private static void Main(string[] args) {

Application.EnableVisualStyles();

Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Pengujian());

(29)

D

AFTAR

R

IWAYAT

H

IDUP

CURRICULUM VITAE

I. DATA PRIBADI /Personal Identification

Nama Lengkap : Dhea Fithaloka Tempat/

Tgl. Lahir

: Medan/ 29 September 1990

Jenis Kelamin : Perempuan Agama : Islam Kebangsaan : Indonesia

Alamat : Komp KPR BTN Blok AU No 12 Lingk XI, Kel. Besar, Medan Labuhan, Martubung. Telepon : 08116151914

Email : [email protected]

II. PENDIDIKAN FORMAL / Formal Education

 [ 2011 – 2017 ] S1 Ilmu Komputer, Fakultas Ilmu Komputer dan Teknologi Informasi Universitas Sumatera Utara

 [ 2008 – 2011 ] DIII Teknik Informatika, Fakultas Matematika dan Ilmu Pengetauhan Alam Universitas Sumatera Utara

 [ 2005 – 2008 ] SMA Dharmawangsa Medan

 [ 2002 – 2005 ] SMP Negeri 7 Medan

 [ 1996 – 2002 ] SD Swasta Pertiwi Medan

III. PENDIDIKAN NON-FORMAL / Informal Education

 -

IV. PENGALAMAN PEKERJAAN/ Job Vacancy

1) 2013 – 2015 : Staf Teknologi Informasi dan Manajemen Resiko, BPJS Kesehatan Divisi Regional I

(30)

Referensi

Dokumen terkait