``hello anyone can you give me tips a random from array 2d i make a small code example
public function autoRandom($simpankota) {
$alfa = 1.0;
$beta = 1.0;
$semut = 3;
$rho = 0.5;
$tijawal = 0.01;
//$route[] = $simpankota;
$new = new addLat();
//$route1 [1] = $simpankota[sizeof($simpankota) - 1];
$route[0] = 0;
$route1[] = reset($simpankota);
echo "<h1> apakah kota awal" . reset($simpankota) ."</h1>";
$d = array();
$simpankota2 = $simpankota;
$simpankota1 = $simpankota;
$simpankota3 = $simpankota;
$zx = 0;
$hit = 1;
foreach ($simpankota1 as $key1 => $value1)
{
$zx++;
$beban = array();
$beban1 = array();
$beban2 = array();
$prob = array();
echo "<h2>" . $simpankota1[$route] ."</h2>";
foreach ($simpankota2 as $key2 => $value2)
{
$berangkat = reset($simpankota1);
$tujuankota = $value2;
$prob = $this->getProbabilitas($berangkat, $tujuankota) * $tijawal;
$prob1[] = $prob;
$ar = array_sum($prob1);
}
foreach ($simpankota3 as $key3 => $value3)
{
$start = reset($simpankota1);
$value2 = $value3;
if ($start != $value2)
{
$beban1[] = ($tijawal * $alfa) * ($this->getProbabilitas($start, $value2)) / $ar;
$beban2[] = array_sum($beban1);
}
else
{
$beban1[] = ($tijawal * $alfa) * ($this->getProbabilitas($start, $value2)) / $ar;
$beban2[] = array_sum($beban);
}
}
$tempnama1 = 'null';
$x;
$tempselisih = 100000000000;
$sum = $this->randomD();
$beban = $beban2;
$xzz = sizeof($beban);
for ($i = 0; $i < sizeof($beban); $i++)
{
if ($sum > $beban[$i])
{
if ($tempselisih > $sum - $beban[$i])
{
$tempselisih = $sum - $beban[$i];
$x = $tempselisih;
$tempnama1 = $i;
}
}
elseif ($beban[$i] > $sum)
{
if ($tempselisih > $beban[$i] - $sum)
{
$tempselisih = $beban[$i] - $sum;
$x = $tempselisih;
$tempnama1 = $i;
}
}
$flag=true;
if ($tempnama1 == true)
{
$beban2[$tempnama1]= 999;
$flag=false;
}
}
$route[sizeof($route)] = $tempnama1;
}
$route [sizeof($route)] = sizeof($simpankota) - 1;
echo "<h1> <pre>KAMPRET" .print_r($route,true) ."</pre></h1>";
return $route;
}
but if i try open show like Array ( [0] => 0 [1] => 2 [2] => 4 [3] => 4 [4] => 4 [5] => 4 [6] => 4 )
but i want make like a if index visited not looping again if checked not itteration looping again Array ( [0] => 0 [1] => 2 [2] => 5 [3] => 3 [4] => 1 [5] => 4 [6] => 6 )
if value checked skip itteration and not get value same again
can you give me tips ?
so do you have some tips? sorry for bad english and bad logic:(
my full code in here
Aucun commentaire:
Enregistrer un commentaire