public function getTotalG($node) { //menghitung total GCost sampai titik $node //GCost sampai titik node adalah Nilai total G dari $start sampai $node melewati semua $best Node //getting partial G echo 'menghitung Total GCost for ' . $node . '...' . PHP_EOL; // $gcost = \App\Models\real::where('idKotaAsal', $this->currentBestNode)->where('idKotaTujuan', $node)->pluck('gCost'); $this->tempNode = $node; $gcost = \App\Models\real::where(function ($qry) { $qry->where('idKotaAsal', $this->evalNode)->where('idKotaTujuan', $this->tempNode); })->orWhere(function ($p) { $p->where('idKotaAsal', $this->tempNode)->where('idKotaTujuan', $this->evalNode); })->pluck('gCost'); echo 'gcost = ' . $gcost . PHP_EOL; $totalG = $this->gCostOfBestNode + $gcost; $this->gCostNodes[$node] = $totalG; return $totalG; }
public function getBestG() { $this->bestNode = $this->getMinF(); $kotaAsal = $this->currentEval; $gcosts = \App\Models\real::where('idKotaAsal', $kotaAsal)->where('idKotaTujuan', $this->bestNode)->pluck('gCost'); //GCost sekarang + G Cost best node $this->currentGCost = $this->currentGCost + $gcosts; }
public function getGCostToParent() { $gCost = real::where(function ($q) { $q->where('idKotaAsal', $this->parentID)->where('idKotaTujuan', $this->id)->orWhere('idKotaAsal', $this->id)->where('idKotaTujuan', $this->parentID); })->pluck('gCost'); return $gCost; }