private static function recurse($uids) { // Base Case if (empty($uids)) { return $uids; } // Loop over each user id foreach ($uids as $uid) { // Seed this cluster $cluster = new Cluster($uid); // Loop over each user id again foreach ($uids as $uid2) { // Add the user id if it is within the threshold if ($uid == $uid2) { continue; } $dist = self::distance($uid, $uid2); if ($dist <= self::$threshold) { $cluster->add_user($uid2); } } // Only save this cluster if it is the largest one if (!isset($max) || $cluster->size() > $max->size()) { $max = $cluster; } unset($cluster); } // Remove cluster from uids $uids = array_diff($uids, $max->users); // Return all of the clusters return array_merge(array($max), self::recurse($uids)); }
public function nestUptoAt($node, $levels = 10, $attrs = array()) { for ($i = 0; $i < $levels; $i++, $node = $new) { $new = Cluster::create(array_merge($attrs, array('name' => "{$node->name}.1"))); $new->makeChildOf($node); } }
/** * @param mixed $servers * @param bool $compress * @see Cluster::__construct */ public function __construct($servers = 'tcp://localhost', $compress = false) { parent::__construct($servers); if ($compress && defined('MEMCACHE_COMPRESSED')) { $this->compress = \MEMCACHE_COMPRESSED; } }
function Guardar() { $cluster = new Cluster(); if (isset($_POST['nombre']) && $_POST['nombre'] != "") { $nombre = $_POST['nombre']; $estatus = $_POST['estatus']; if ($estatus == "on") { $cluster->Nueva_Cluster($nombre, "1"); } else { $cluster->Nueva_Cluster($nombre, "0"); } header("Location: index.php?oksave"); } else { header("Location: index.php?error"); } }
/** * Execute the console command * * @return void */ public function fire() { $allowed_types = array('array', 'boolean', 'integer', 'number', 'null', 'object', 'string'); $cluster = Cluster::where('clustername', '=', $this->option('cluster'))->first(); if (!isset($cluster)) { $this->comment("This cluster doesn't exist."); return; } do { // get company name do { $name = $this->ask("Company name : "); if (empty($name)) { $this->comment("Your company name is empty."); } } while (empty($name)); // check if a company with this name and cluster already exists $company = Company::byName($cluster, $name)->first(); if (isset($company)) { $this->comment("A company with this name already exists, please choose another one."); } } while (isset($company)); // get company logo url do { $logo_url = $this->ask("Logo url: "); if (empty($logo_url)) { $this->comment("Your logo url is empty."); } } while (empty($logo_url)); $domains = array(); // get company domains $add_domains = $this->ask("Do you want to add any domains (like: '@flatturtle.com')? [Y]/n") ? 0 : 1; while ($add_domains) { $domain = $this->ask("Domain: "); if (empty($domain)) { $this->comment("Your domain is empty."); } array_push($domains, $domain); $add_domains = $this->ask("Do you want to add more domains (like: '@flatturtle.com')? [Y]/n") ? 0 : 1; } $company = Company::create(array("name" => $name, "logo_url" => $logo_url, "cluster_id" => $cluster->id, "domains" => json_encode($domains))); $this->info("Company '{$company->name}' has been saved."); return; }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { if (Auth::check()) { $clusters = Cluster::all(); $clustersCount = Cluster::all()->count(); //Get bulbs $bulbs = Bulb::all(); $bulbsCount = Bulb::all()->count(); //Get schedules $schedules = Schedule::all(); $schedulesCount = Schedule::all()->count(); $distinct_bulbs = array_fetch(DB::select("SELECT DISTINCT bulb_id FROM poweranalyzers ORDER BY bulb_id"), 'bulb_id'); $readings = Bulb::whereIn('id', $distinct_bulbs)->get(); $readingsCount = count($readings); $markers = Cluster::find($id)->bulbs; $markersCount = count($markers); return View::make('cluster')->with('markers', $markers)->with('markersCount', $markersCount)->with('clusters', $clusters)->with('clustersCount', $clustersCount)->with('bulbs', $bulbs)->with('bulbsCount', $bulbsCount)->with('readings', $readings)->with('readingsCount', $readingsCount)->with('schedules', $schedules)->with('schedulesCount', $schedulesCount); } }
public function index() { //Get the markers $markers = Bulb::all(); $markersCount = Bulb::all()->count(); $clusters = Cluster::all(); $clustersCount = Cluster::all()->count(); //Get bulbs $bulbs = Bulb::all(); $bulbsCount = Bulb::all()->count(); //Get distinct bulbs $distinct_bulbs = array_fetch(DB::select("SELECT DISTINCT bulb_id FROM poweranalyzers ORDER BY bulb_id"), 'bulb_id'); $readings = Bulb::whereIn('id', $distinct_bulbs)->get(); $readingsCount = count($readings); //Get schedules $schedules = Schedule::all(); $schedulesCount = Schedule::all()->count(); return View::make('home')->with('markers', $markers)->with('markersCount', $markersCount)->with('clusters', $clusters)->with('clustersCount', $clustersCount)->with('bulbs', $bulbs)->with('bulbsCount', $bulbsCount)->with('readings', $readings)->with('readingsCount', $readingsCount)->with('schedules', $schedules)->with('schedulesCount', $schedulesCount); }
public function run() { DB::table('clusters')->delete(); Cluster::create(array('name' => 'Diliman Quezon City Area')); Cluster::create(array('name' => 'Elliptical Road Area')); }
function Muestra() { $cluster = new Cluster(); if (isset($_GET['c_id'])) { $cluster_id = $_GET['c_id']; $cluster->Load_Cluster($cluster_id); } else { header("Location: index.php"); } $I = new Interfaz("Usuarios:: Editar Usuario", true); include "../../lib/php/messageResources.php"; $INDEXIDIOMA = $_SESSION["idiomausuario"]; ?> <style type="text/css"> <!-- .Estilo1 {color: #FF0000} --> </style> <script src="../../lib/js/jquery/jquery-1.3.2.js" type="text/javascript"></script> <script src="../../lib/js/validateForm.js" type="text/javascript"></script> <script src="js/validaform.js" type="text/javascript"></script> <br><br> <form name="form1" method="post" action=""> <table width="80%" align="center" cellpadding="4" cellspacing="4" border="0" bgcolor="#f4f4f4" style="padding-top: 20px;"> <tr> <td align="right"> </td> <td><strong><?php echo $LABELINDEX[$INDEXIDIOMA][328] . " " . $LABELINDEX[$INDEXIDIOMA][78]; ?> </strong></td> </tr> <tr> <td align="right"> </td> <td> <input type="hidden" name="c_id" id="c_id" value="<?php echo $cluster_id; ?> " readonly="readonly" style="border-color:#FFFFFF" /> </td> </tr> <tr> <td align="right" width="30%"><?php echo $LABELINDEX[$INDEXIDIOMA][327]; ?> <span class="Estilo1">*</span>: </td> <td> <input type="text" name="nombre" id="nombre" size="70" value="<?php echo $cluster->Get_dato("c_nombre"); ?> "/> </td> </tr> <tr> <td align="right" width="30%"><?php echo $LABELINDEX[$INDEXIDIOMA][28]; ?> : </td> <td> <?php if ($cluster->Get_dato("c_estatus") == "0") { ?> <input type="checkbox" name="estatus" id="estatus"/> <?php } else { ?> <input type="checkbox" name="estatus" id="estatus" checked /> <?php } ?> </td> </tr> <tr> <td colspan="2"> </td></tr> <tr> <td colspan="2" align="center"> <input type="submit" value="<?php echo $LABELINDEX[$INDEXIDIOMA][345]; ?> " name="Actualizar" onclick="return validate(); "> <input type="submit" value="<?php echo $LABELINDEX[$INDEXIDIOMA][219]; ?> " name="Cancelar"> </td> </tr> </table> </form> <?php $I->Footer(); }
/** * Restart worker */ public function restart() { $this->cluster->restart($this); }
/** * Forms the clusters by removing maximum weighted edges. * performs breadth-first search to cluster the recipes. * * @param int $k queue size * @param int $size number of recipes. * @return array $cluster clusters of recipes. */ function formCluster($k, $size) { $this->cluster_heap->top(); $nodeQueue = new Queue($k); $cluster_count = $size * CLUSTER_RATIO; $cluster = array(); /* Idea remove $cluster_count many weightiest edges from tree to get a forest. As do this add to queue end points of removed edges. */ for ($j = 0; $j < $cluster_count - 1; $j++) { $max_edge = $this->cluster_heap->extract(); $cluster1_start = $max_edge->getStartVertex()->getLabel(); $cluster2_start = $max_edge->getEndVertex()->getLabel(); $this->adjMatrix[$cluster1_start][$cluster2_start] = -1; $this->adjMatrix[$cluster2_start][$cluster1_start] = -1; $nodeQueue->enqueue($cluster1_start); $nodeQueue->enqueue($cluster2_start); } $queue = new Queue($k); $i = 0; // Now use Queue above to make clusters (trees in resulting forest) while (!$nodeQueue->isEmpty()) { $node = $nodeQueue->dequeue(); if ($this->vertices[$node]->isVisited() == false) { $this->vertices[$node]->visited(); $cluster[$i][] = $this->vertices[$node]->getLabel(); $queue->enqueue($this->vertices[$node]->getLabel()); while (!$queue->isEmpty()) { $node = $queue->dequeue(); while (($nextnode = $this->getNextVertex($node)) != -1) { $this->vertices[$nextnode]->visited(); $cluster[$i][] = $this->vertices[$nextnode]->getLabel(); $queue->enqueue($this->vertices[$nextnode]->getLabel()); } } } $i++; } return $cluster; }
public function query($asarray) { $sql = $this->getSql(); if ($asarray) { $dbc = new DatabaseConnection(); $cluster = $dbc->query($sql); } else { // Handle cluster creation $cluster = new Cluster($this->_from['table']); $cluster->populate($this->_from['table'], $sql); } return $cluster; }
function explodeSmallClusters($minNbCluster) { try { //check number format if (intval($minNbCluster) > 0) { $clustersExploded = array(); foreach ($this->clusters as $cluster) { if ($cluster->markers != null && count($cluster->markers) < $minNbCluster) { foreach ($cluster->markers as $markerToAdd) { $clusterToAdd = new Cluster($this); $clusterToAdd->addMarker($markerToAdd); $clustersExploded[] = $clusterToAdd; } } else { $clustersExploded[] = $cluster; } } $this->clusters = $clustersExploded; } } catch (Exception $e) { // TODO: handle exception } }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { //Get the markers $marker = Bulb::find($id); //Get clusters //$clusters = DB::table($cluster_tbl)->lists('clusterid','name'); $clusters = Cluster::all(); $clustersCount = Cluster::all()->count(); //Get bulbs $bulbs = Bulb::all(); $bulbsCount = Bulb::all()->count(); //Get readings $readings = Poweranalyzer::all(); $readingsCount = count($readings); //Get schedules $schedules = Schedule::all(); $schedulesCount = Schedule::all()->count(); return View::make('bulb')->with('marker', $marker)->with('clusters', $clusters)->with('clustersCount', $clustersCount)->with('bulbs', $bulbs)->with('bulbsCount', $bulbsCount)->with('readings', $readings)->with('readingsCount', $readingsCount)->with('schedules', $schedules)->with('schedulesCount', $schedulesCount); //return $marker; }
|-------------------------------------------------------------------------- | | Here is where you can register all of the routes for an application. | It's a breeze. Simply tell Laravel the URIs it should respond to | and give it the Closure to execute when that URI is requested. | */ App::error(function (\Symfony\Component\HttpKernel\Exception\HttpException $e) { return Response::json(array('error' => $e->getMessage()), $e->getStatusCode()); }); /* * Model bindings * */ Route::bind('cluster', function ($cluster_name, $route) { $cluster = $cluster = Cluster::where('clustername', '=', $cluster_name)->first(); if (!isset($cluster)) { throw new EntityNotFoundException("Cluster.NotFound"); } return $cluster; }); /** * AUTH routes */ Route::group(array('before' => 'auth.basic'), function () { /* PUT http://reservation.hostname/{cluster_name}/amenities/{name} create or update an amenity. */ Route::put('/{cluster}/amenities/{name}', 'EntityController@createAmenity'); /*
function Muestra() { include "../../lib/php/messageResources.php"; $INDEXIDIOMA = $_SESSION["idiomausuario"]; $Usu = new Usuario(); if (isset($_GET['usuario_id'])) { $usuario_id = $_GET['usuario_id']; $Usu->Load_Usuario_By_ID($usuario_id); } else { header("Location: index.php"); } $I = new Interfaz("Usuarios:: Editar Usuario", true); ?> <style type="text/css"> <!-- .Estilo1 {color: #FF0000} --> </style> <br><br> <form name="form1" method="post"/> <table width="80%" align="center" cellpadding="4" cellspacing="4" border="0" bgcolor="#f4f4f4" style="padding-top: 20px;"> <tr> <td> </td> <td colspan="4" align="center"> <strong><?php echo $LABELINDEX[$INDEXIDIOMA][441]; ?> </strong> </td> <td> </td> </tr> <tr> <td width="2%"> </td> <td colspan="2" align="right" width="33%"> <?php echo $LABELINDEX[$INDEXIDIOMA][327]; ?> <span class="Estilo1">*</span>:</td> <td colspan="2"> <input type="text" name="nombre" id="nombre" size="63" value="<?php echo $Usu->Get_dato("u_nombre"); ?> " /> </td> <td width="2%"> </td> </tr> <tr> <td> </td> <td colspan="2" align="right" width="30%"> <?php echo $LABELINDEX[$INDEXIDIOMA][0]; ?> <span class="Estilo1">*</span>: </td> <td colspan="2"> <input type="text" name="user" id="user" size="40" onKeypress="return bloqueaEspacio(event);" value="<?php echo $Usu->Get_dato("u_usuario"); ?> " /> </td> <td> </td> </tr> <tr> <td> </td> <td colspan="2" align="right" width="30%"> <?php echo $LABELINDEX[$INDEXIDIOMA][1]; ?> <span class="Estilo1">*</span>: </td> <td colspan="2"> <input type="password" name="passwd" id="passwd" size="40" onKeypress="return bloqueaEspacio(event);" value="<?php echo $Usu->Get_dato("u_passwd"); ?> " /> </td> <td> </td> </tr> <tr> <td> </td> <td colspan="2" align="right" width="30%"> <?php echo $LABELINDEX[$INDEXIDIOMA][112]; ?> <span class="Estilo1">*</span>: </td> <td colspan="2"> <input type="password" name="passwd2" id="passwd2" size="40" onKeypress="return bloqueaEspacio(event);" value="<?php echo $Usu->Get_dato("u_passwd"); ?> " /> </td> <td> </td> </tr> <tr> <td> </td> <td colspan="2" align="right" width="30%"> <?php echo $LABELINDEX[$INDEXIDIOMA][96]; ?> <span class="Estilo1">*</span>: </td> <td colspan="2"> <input type="text" name="email" id="email" size="40" onKeypress="return bloqueaEspacio(event);" value="<?php echo $Usu->Get_dato("u_email"); ?> " /> </td> <td> </td> </tr> <tr> <td> </td> <td colspan="4" align="right"> </td> <td> </td> </tr> <tr> <td> </td> <td colspan="4" align="center"><strong><?php echo $LABELINDEX[$INDEXIDIOMA][442]; ?> </strong></td> <td> </td> </tr> <? $Usu2 = new Usuario(); $normal = ""; $administrador = ""; $av1 = ""; $av2 = ""; $av3 = ""; $uafi = ""; foreach($Usu2->Load_tipo_usuario_by_id($usuario_id) as $datos){ if($datos['tu_nombre'] == "Normal"){ $normal = "checked"; } if($datos['tu_nombre'] == "Administrador"){ $administrador = "checked"; } if($datos['tu_nombre'] == "Area FI"){ $uafi = "checked"; } if($datos['tu_nombre'] == "Agencia1"){ $av1 = "checked"; } if($datos['tu_nombre'] == "Agencia2"){ $av2 = "checked"; } if($datos['tu_nombre'] == "Agencia3"){ $av3 = "checked"; } } ?> <tr> <td> </td> <td align="right" width="30%"><?php echo $LABELINDEX[$INDEXIDIOMA][443]; ?> :</td> <td> <input type=checkbox name="normal" id="normal" <? echo $normal ?>/> </td> <td align="right" width="30%"><?php echo $LABELINDEX[$INDEXIDIOMA][445]; ?> 1:</td> <td> <input type=checkbox name="av1" id="av1" <? echo $av1 ?> /> </td> <td> </td> </tr> <tr> <td> </td> <td align="right" width="30%"><?php echo $LABELINDEX[$INDEXIDIOMA][444]; ?> :</td> <td> <input type=checkbox name="administrador" id="administrador" <? echo $administrador ?> /> </td> <td align="right" width="30%"><?php echo $LABELINDEX[$INDEXIDIOMA][445]; ?> 2:</td> <td> <input type=checkbox name="av2" id="av2" <? echo $av2 ?> /> </td> <td> </td> </tr> <tr> <td> </td> <td align="right" width="30%"><?php echo $LABELINDEX[$INDEXIDIOMA][446]; ?> :</td> <td> <input type=checkbox name="uafi" id="uafi" <? echo $uafi ?> /> </td> <td align="right" width="30%"><?php echo $LABELINDEX[$INDEXIDIOMA][445]; ?> 3:</td> <td> <input type=checkbox name="av3" id="av3" <? echo $av3 ?> /> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td align="right" width="30%"><?php echo $LABELINDEX[$INDEXIDIOMA][447]; ?> :</td> <td> <input type=checkbox name="aprobador" id="aprobador" <? if($Usu->Get_dato("u_aprobador")==1){echo "checked";} ?> /> </td> <td> </td> </tr> <tr> <td> </td> <td colspan="4" align="right"> </td> <td> </td> </tr> <tr> <td> </td> <td colspan="4" align="center"><strong><?php echo $LABELINDEX[$INDEXIDIOMA][182]; ?> </strong></td> <td> </td> </tr> <tr> <td> </td> <td colspan="2" align="right" width="30%"> <?php echo $LABELINDEX[$INDEXIDIOMA][78]; ?> <span class="Estilo1">*</span>: </td> <td colspan="2"> <?php $cluster = new Cluster(); ?> <select name="cluster_id" id="cluster_id" onChange="cargarPaises(this.value)"> <option name="cluster_id" id="cluster_id" value="-1"> <?php echo $LABELINDEX[$INDEXIDIOMA][448]; ?> </option> <?php foreach ($cluster->Load_all(1) as $arrE) { ?> <option name="cluster_id" id="cluster_id" value="<?php echo $arrE['c_id']; ?> "> <?php echo $arrE['c_nombre']; ?> </option> <?php } ?> </select> </td> <td> </td> </tr> <tr> <td> </td> <td colspan="2" align="right" width="30%"> <?php echo $LABELINDEX[$INDEXIDIOMA][55]; ?> <span class="Estilo1">*</span>: </td> <td colspan="2"> <select name="pais_id" id="pais_id" onChange="cargarSociedades(this.value)" > <option name="pais_id" id="pais_id" value="-1"> <?php echo $LABELINDEX[$INDEXIDIOMA][449]; ?> </option> </select> </td> <td> </td> </tr> <tr> <td> </td> <td colspan="2" align="right" width="30%"> <?php echo $LABELINDEX[$INDEXIDIOMA][58]; ?> <span class="Estilo1">*</span>: </td> <td colspan="2"> <select name="sociedad_id" id="sociedad_id" onChange="cargarCecos(this.value)" > <option name="sociedad_id" id="sociedad_id" value="-1"> <?php echo $LABELINDEX[$INDEXIDIOMA][449]; ?> </option> </select> </td> <td> </td> </tr> <tr> <td> </td> <td colspan="2" align="right" width="30%"> <?php echo $LABELINDEX[$INDEXIDIOMA][450]; ?> <span class="Estilo1">*</span>: </td> <td colspan="2"> <select name="ceco_id" id="ceco_id" onChange="cargarJefes(this.value)" > <option name="ceco_id" id="ceco_id" value="-1"> <?php echo $LABELINDEX[$INDEXIDIOMA][449]; ?> </option> </select> </td> <td> </td> </tr> <tr> <td> </td> <td colspan="2" align="right"><?php echo $LABELINDEX[$INDEXIDIOMA][451]; ?> :</td> <td colspan="2"><input type="text" name="telefono" id="telefono" size="20" onKeyPress="return validaNum(event)" value="<?php echo $Usu->Get_dato("telefono"); ?> " /></td> <td> </td> </tr> <tr> <td> </td> <td colspan="2" align="right"><?php echo $LABELINDEX[$INDEXIDIOMA][452]; ?> :</td> <td colspan="2"><input type="text" name="extension" id="extension" size="20" onKeyPress="return validaNum(event)" value="<?php echo $Usu->Get_dato("extension"); ?> " /></td> <td> </td> </tr> <!-- <tr> <td> </td> <td colspan="2" align="right">No. Tarjeta Crédito<span class="Estilo1">*</span>:</td> <td colspan="2"><input type="text" name="no_tarjeta" id="no_tarjeta" size="20" value="<?php echo $Usu->Get_dato("notarjetacredito"); ?> " /></td> <td> </td> </tr> --> <tr> <td> </td> <td colspan="2" align="right"><?php echo $LABELINDEX[$INDEXIDIOMA][453]; ?> :</td> <td colspan="2"><input type="text" name="no_tarjeta_corp" id="no_tarjeta_corp" size="20" value="<?php echo $Usu->Get_dato("notarjetacorp"); ?> "/></td> <td> </td> </tr> <tr> <td> </td> <td colspan="2" align="right"><?php echo $LABELINDEX[$INDEXIDIOMA][454]; ?> :</td> <td colspan="2"><input type="text" name="no_tarjeta_viajero" id="no_tarjeta_viajero" size="20" value="<?php echo $Usu->Get_dato("notarjetaviajero"); ?> "/></td> <td> </td> </tr> <tr> <td> </td> <td colspan="2" align="right"><?php echo $LABELINDEX[$INDEXIDIOMA][455]; ?> :</td> <td colspan="2"><input type="text" name="no_acreedor" id="no_acreedor" size="20" value="<?php echo $Usu->Get_dato("noacreedorsap"); ?> " /></td> <td> </td> </tr> <tr> <td> </td> <td colspan="2" align="right" width="30%"> <?php echo $LABELINDEX[$INDEXIDIOMA][456]; ?> <span class="Estilo1">*</span>: </td> <td colspan="2"> <?php //$cluster=new Cluster(); ?> <select name="nivel_id" id="nivel_id" > <option name="nivel_id" id="nivel_id" value="-1"> <?php echo $LABELINDEX[$INDEXIDIOMA][448]; ?> </option> <?php foreach ($Usu->Load_niveles(1) as $arrE) { ?> <option name="nivel_id" id="nivel_id" value="<?php echo $arrE['j_id']; ?> "> <?php echo $arrE['j_nombre']; ?> </option> <?php } ?> </select> </td> <td> </td> </tr> <tr> <td> </td> <td colspan="2" align="right" width="30%"> <?php echo $LABELINDEX[$INDEXIDIOMA][440]; ?> : </td> <td colspan="2"> <select name="jefe_id" id="jefe_id" > <option name="jefe_id" id="jefe_id" value="-1"> <?php echo $LABELINDEX[$INDEXIDIOMA][449]; ?> </option> </select> </td> <td> </td> </tr> <tr> <td> </td> <td colspan="2" align="right" width="30%"><?php echo $LABELINDEX[$INDEXIDIOMA][28]; ?> :</td> <td colspan="2"> <input type=checkbox name="estatus" id="estatus" <? if($Usu->Get_dato("u_estatus")==1){echo "checked";} ?> /> </td> <td> </td> </tr> <tr> <td> </td> <td colspan="4" align="center"> <input type="submit" value="<?php echo $LABELINDEX[$INDEXIDIOMA][345]; ?> " name="actualizar" onclick="return validaUsuarioDuplicado();"> <input type="submit" value="<?php echo $LABELINDEX[$INDEXIDIOMA][219]; ?> " name="cancelar"> </td> <td> </td> </tr> </table> </form> <?php $I->Footer(); }
public function testClusterCentroidConstructClusters() { $cluster = new Cluster(new Cluster(new Point(1, 2)), new Cluster(new Point(3, 2)), new Cluster(new Point(5, -10))); $this->assertEquals($cluster->getCentroid(), new Point(3, -2)); }
private function init($data) { // Fill search class with all the points $this->search->setData($data); // Initialize auxiliary variables $this->visited = array(); $this->cluster = array(); $this->noise = array(); // Check if any parameter is missing to calculate heuristic values if ($this->eps === null || $this->minPoints === null) { $data_clustered = $data; if (!$data_clustered instanceof Cluster) { // Convert array to cluster $data_clustered = new Cluster($data); } // Calculate heuristic values and set them as DBSCAN parameters $x_diff = $data_clustered->getXMax() - $data_clustered->getXMin(); $y_diff = $data_clustered->getYMax() - $data_clustered->getYMin(); $this->eps = max($x_diff, $y_diff) / $this::HEURISTIC_DIVISION; if ($this->eps <= 0) { // If all the points are in the same place, eps will be 0, // and because the distance comparison is a "less strict" // all points would be noise. This way they will all belong // to the same cluster $this->eps = 1; } $this->minPoints = 1; } }
public function testGetNestedList() { $seperator = ' '; $nestedList = Cluster::getNestedList('name', 'id', $seperator); $expected = array('7461d8f5-2ea9-4788-99c4-9d0244f0bfb1' => str_repeat($seperator, 0) . 'Root 1', '5d7ce1fd-6151-46d3-a5b3-0ebb9988dc57' => str_repeat($seperator, 1) . 'Child 1', '07c1fc8c-53b5-4fe7-b9c4-e09f266a455c' => str_repeat($seperator, 1) . 'Child 2', '3315a297-af87-4ad3-9fa5-19785407573d' => str_repeat($seperator, 2) . 'Child 2.1', '054476d2-6830-4014-a181-4de010ef7114' => str_repeat($seperator, 1) . 'Child 3', '3bb62314-9e1e-49c6-a5cb-17a9ab9b1b9a' => str_repeat($seperator, 0) . 'Root 2'); $this->assertArraysAreEqual($expected, $nestedList); }
private function get_cluster() { // A little caching if ($this->data['pid']) { if (isset($m_cluster)) { return $m_cluster; } else { return $m_cluster = Cluster::find_by_user($this); } } return false; }
function agglomerate($labels, $grid) { $clusters = $labels; while (count($clusters) > 1) { $distances = array(array(1, 0, $grid[1][0])); for ($i = 2; $i < count($grid); $i++) { for ($j = 0; $j < $i; $j++) { $distances[] = array($i, $j, $grid[$i][$j]); } } usort($distances, function ($a, $b) { return $b[2] < $a[2]; }); list($j, $i, $d) = $distances[0]; # merge i⇐j $c = new Cluster($d); list($clusters, $grid) = $c->add($clusters, $grid, $i, $j); $clusters[$i] = $c; } return $clusters[min(0, count($clusters) - 1)]; }
function Muestra() { include "../../lib/php/messageResources.php"; $INDEXIDIOMA = $_SESSION["idiomausuario"]; $I = new Interfaz("Usuarios:: Nuevo Usuario", true); ?> <style type="text/css"> <!-- .Estilo1 {color: #FF0000} --> </style> <br><br> <form name="form1" method="post"/> <table width="80%" align="center" cellpadding="4" cellspacing="4" border="0" bgcolor="#f4f4f4" style="padding-top: 20px;"> <tr> <td> </td> <td colspan="4" align="center"> <strong><?php echo $LABELINDEX[$INDEXIDIOMA][441]; ?> </strong> </td> <td> </td> </tr> <tr> <td width="2%"> </td> <td colspan="2" align="right" width="33%"> <?php echo $LABELINDEX[$INDEXIDIOMA][327]; ?> <span class="Estilo1">*</span>:</td> <td colspan="2"> <input type="text" name="nombre" id="nombre" size="63" /> </td> <td width="2%"> </td> </tr> <tr> <td> </td> <td colspan="2" align="right" width="30%"> <?php echo $LABELINDEX[$INDEXIDIOMA][0]; ?> <span class="Estilo1">*</span>: </td> <td colspan="2"> <input type="text" name="user" id="user" size="40" onKeypress="return bloqueaEspacio(event);"/> </td> <td> </td> </tr> <tr> <td> </td> <td colspan="2" align="right" width="30%"> <?php echo $LABELINDEX[$INDEXIDIOMA][1]; ?> <span class="Estilo1">*</span>: </td> <td colspan="2"> <input type="password" name="passwd" id="passwd" size="40" onKeypress="return bloqueaEspacio(event);"/> </td> <td> </td> </tr> <tr> <td> </td> <td colspan="2" align="right" width="30%"> <?php echo $LABELINDEX[$INDEXIDIOMA][112]; ?> <span class="Estilo1">*</span>: </td> <td colspan="2"> <input type="password" name="passwd2" id="passwd2" size="40" onKeypress="return bloqueaEspacio(event);"/> </td> <td> </td> </tr> <tr> <td> </td> <td colspan="2" align="right" width="30%"> <?php echo $LABELINDEX[$INDEXIDIOMA][96]; ?> <span class="Estilo1">*</span>: </td> <td colspan="2"> <input type="text" name="email" id="email" size="40" onKeypress="return bloqueaEspacio(event);"/> </td> <td> </td> </tr> <tr> <td> </td> <td colspan="4" align="right"> </td> <td> </td> </tr> <tr> <td> </td> <td colspan="4" align="center"><strong><?php echo $LABELINDEX[$INDEXIDIOMA][442]; ?> </strong></td> <td> </td> </tr> <tr> <td> </td> <td align="right" width="30%"><?php echo $LABELINDEX[$INDEXIDIOMA][443]; ?> :</td> <td> <input type=checkbox name="normal" id="normal" /> </td> <td align="right" width="30%"><?php echo $LABELINDEX[$INDEXIDIOMA][445]; ?> 1:</td> <td> <input type=checkbox name="av1" id="av1" /> </td> <td> </td> </tr> <tr> <td> </td> <td align="right" width="30%"><?php echo $LABELINDEX[$INDEXIDIOMA][444]; ?> :</td> <td> <input type=checkbox name="administrador" id="administrador" /> </td> <td align="right" width="30%"><?php echo $LABELINDEX[$INDEXIDIOMA][445]; ?> 2:</td> <td> <input type=checkbox name="av2" id="av2" /> </td> <td> </td> </tr> <tr> <td> </td> <td align="right" width="30%"><?php echo $LABELINDEX[$INDEXIDIOMA][446]; ?> :</td> <td> <input type=checkbox name="uafi" id="uafi" /> </td> <td align="right" width="30%"><?php echo $LABELINDEX[$INDEXIDIOMA][445]; ?> 3:</td> <td> <input type=checkbox name="av3" id="av3" /> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td align="right" width="30%"><?php echo $LABELINDEX[$INDEXIDIOMA][447]; ?> :</td> <td> <input type=checkbox name="aprobador" id="aprobador" /> </td> <td> </td> </tr> <tr> <td> </td> <td colspan="4" align="right"> </td> <td> </td> </tr> <tr> <td> </td> <td colspan="4" align="center"><strong><?php echo $LABELINDEX[$INDEXIDIOMA][182]; ?> </strong></td> <td> </td> </tr> <tr> <td> </td> <td colspan="2" align="right" width="30%"> <?php echo $LABELINDEX[$INDEXIDIOMA][78]; ?> <span class="Estilo1">*</span>: </td> <td colspan="2"> <?php $cluster = new Cluster(); ?> <select name="cluster_id" id="cluster_id" onChange="cargarPaises(this.value)"> <option name="cluster_id" id="cluster_id" value="-1"> <?php echo $LABELINDEX[$INDEXIDIOMA][448]; ?> </option> <?php foreach ($cluster->Load_all(1) as $arrE) { ?> <option name="cluster_id" id="cluster_id" value="<?php echo $arrE['c_id']; ?> "> <?php echo $arrE['c_nombre']; ?> </option> <?php } ?> </select> </td> <td> </td> </tr> <tr> <td> </td> <td colspan="2" align="right" width="30%"> <?php echo $LABELINDEX[$INDEXIDIOMA][55]; ?> <span class="Estilo1">*</span>: </td> <td colspan="2"> <select name="pais_id" id="pais_id" onChange="cargarSociedades(this.value)" > <option name="pais_id" id="pais_id" value="-1"> <?php echo $LABELINDEX[$INDEXIDIOMA][449]; ?> </option> </select> </td> <td> </td> </tr> <tr> <td> </td> <td colspan="2" align="right" width="30%"> <?php echo $LABELINDEX[$INDEXIDIOMA][58]; ?> <span class="Estilo1">*</span>: </td> <td colspan="2"> <select name="sociedad_id" id="sociedad_id" onChange="cargarCecos(this.value)" > <option name="sociedad_id" id="sociedad_id" value="-1"> <?php echo $LABELINDEX[$INDEXIDIOMA][449]; ?> </option> </select> </td> <td> </td> </tr> <tr> <td> </td> <td colspan="2" align="right" width="30%"> <?php echo $LABELINDEX[$INDEXIDIOMA][450]; ?> <span class="Estilo1">*</span>: </td> <td colspan="2"> <select name="ceco_id" id="ceco_id" onChange="cargarJefes(this.value)" > <option name="ceco_id" id="ceco_id" value="-1"> <?php echo $LABELINDEX[$INDEXIDIOMA][449]; ?> </option> </select> </td> <td> </td> </tr> <tr> <td> </td> <td colspan="2" align="right"><?php echo $LABELINDEX[$INDEXIDIOMA][451]; ?> :</td> <td colspan="2"><input type="text" name="telefono" id="telefono" size="20" onKeyPress="return validaNum(event)" /></td> <td> </td> </tr> <tr> <td> </td> <td colspan="2" align="right"><?php echo $LABELINDEX[$INDEXIDIOMA][452]; ?> :</td> <td colspan="2"><input type="text" name="extension" id="extension" size="20" onKeyPress="return validaNum(event)" /></td> <td> </td> </tr> <!-- <tr> <td> </td> <td colspan="2" align="right">No. Tarjeta Crédito<span class="Estilo1">*</span>:</td> <td colspan="2"><input type="text" name="no_tarjeta" id="no_tarjeta" size="20" /></td> <td> </td> </tr> --> <tr> <td> </td> <td colspan="2" align="right"><?php echo $LABELINDEX[$INDEXIDIOMA][453]; ?> :</td> <td colspan="2"><input type="text" name="no_tarjeta_corp" id="no_tarjeta_corp" size="20" /></td> <td> </td> </tr> <tr> <td> </td> <td colspan="2" align="right"><?php echo $LABELINDEX[$INDEXIDIOMA][454]; ?> :</td> <td colspan="2"><input type="text" name="no_tarjeta_viajero" id="no_tarjeta_viajero" size="20" /></td> <td> </td> </tr> <tr> <td> </td> <td colspan="2" align="right"><?php echo $LABELINDEX[$INDEXIDIOMA][455]; ?> :</td> <td colspan="2"><input type="text" name="no_acreedor" id="no_acreedor" size="20" /></td> <td> </td> </tr> <tr> <td> </td> <td colspan="2" align="right" width="30%"> <?php echo $LABELINDEX[$INDEXIDIOMA][456]; ?> <span class="Estilo1">*</span>: </td> <td colspan="2"> <?php //$cluster=new Cluster(); ?> <select name="nivel_id" id="nivel_id" > <option name="nivel_id" id="nivel_id" value="-1"> <?php echo $LABELINDEX[$INDEXIDIOMA][448]; ?> </option> <?php $Usu = new Usuario(); foreach ($Usu->Load_niveles(1) as $arrE) { ?> <option name="nivel_id" id="nivel_id" value="<?php echo $arrE['j_id']; ?> "> <?php echo $arrE['j_nombre']; ?> </option> <?php } ?> </select> </td> <td> </td> </tr> <tr> <td> </td> <td colspan="2" align="right" width="30%"> <?php echo $LABELINDEX[$INDEXIDIOMA][440]; ?> : </td> <td colspan="2"> <select name="jefe_id" id="jefe_id" > <option name="jefe_id" id="jefe_id" value="-1"> <?php echo $LABELINDEX[$INDEXIDIOMA][449]; ?> </option> </select> </td> <td> </td> </tr> <tr> <td> </td> <td colspan="2" align="right" width="30%"><?php echo $LABELINDEX[$INDEXIDIOMA][28]; ?> :</td> <td colspan="2"> <input type=checkbox name="estatus" id="estatus" /> </td> <td> </td> </tr> <tr> <td> </td> <td colspan="4" align="center"> <input type="submit" value="<?php echo $LABELINDEX[$INDEXIDIOMA][116]; ?> " name="registrar" onclick="return validaUsuarioDuplicado();"> <input type="submit" value="<?php echo $LABELINDEX[$INDEXIDIOMA][219]; ?> " name="cancelar"> </td> <td> </td> </tr> </table> </form> <?php $I->Footer(); }
public function testDepthIsUpdatedOnDescendantsWhenParentMoves() { $a = Cluster::create(array('name' => 'A')); $b = Cluster::create(array('name' => 'B')); $c = Cluster::create(array('name' => 'C')); $d = Cluster::create(array('name' => 'D')); // a > b > c > d $b->makeChildOf($a); $c->makeChildOf($b); $d->makeChildOf($c); $a->reload(); $b->reload(); $c->reload(); $d->reload(); $b->moveToRightOf($a); $a->reload(); $b->reload(); $c->reload(); $d->reload(); $this->assertEquals(0, $b->getDepth()); $this->assertEquals(1, $c->getDepth()); $this->assertEquals(2, $d->getDepth()); }
$busqueda_value = ""; if (isset($_GET["name_cluster"])) { $cluster_name = $_GET["name_cluster"]; $busqueda_value = "name_cluster=" . $cluster_name; } $I = new Interfaz("Cluster", true); $L = new Lista($busqueda_value); $L->Cabeceras($LABELINDEX[$INDEXIDIOMA][327]); // Nombre $L->Cabeceras($LABELINDEX[$INDEXIDIOMA][412]); // Estatus $L->Herramientas("E", "./index.php?mode=edit&c_id="); include "../../lib/php/mnu_toolbar.php"; cluster_toolbar(); $query = "SELECT c_nombre, if(c_estatus=1,'" . $LABELINDEX[$INDEXIDIOMA][348] . "','" . $LABELINDEX[$INDEXIDIOMA][349] . "') as status,c_id FROM cluster c WHERE c_nombre LIKE '%" . $cluster_name . "%' ORDER BY c_id"; $L->muestra_lista($query, 2, false, 2); $I->Footer(); break; case "new": require_once "clusters_new.php"; break; case "edit": require_once "clusters_edit.php"; break; case "delete": $cluster_id = $_GET["c_id"]; $cluster = new Cluster(); $cluster->Delete_Cluster($cluster_id); header("Location: index.php"); break; }
<?php /** * Created by PhpStorm. * User: Happy * Date: 2015/9/26 * Time: 9:58 */ require_once './Cluster.php'; $cluster = new Cluster(); $cluster->cluster_prepare(); $cluster->centroid_clustering(); echo "Finish the job!!";
public function testKeyIsNonNumeric() { $root = Cluster::root(); $this->assertTrue(is_string($root->getKey())); $this->assertFalse(is_numeric($root->getKey())); }
<style type="text/css"> .style1 {color: #FF0000} </style> <?PHP if(isset ($_GET['reporte'])){ $_SESSION['reporte'] = $_GET['reporte']; } echo "<center><h3>".$_SESSION['reporte']."</h3></center>"; ?> <FORM ACTION="reporte.php" METHOD="post" name="formReporte"> <table align='center', width='30%' > <!-- Cluster --> <tr> <td colspan='1' align='right' style="left:20px;">Cluster:</td> <td colspan='2' align="left" style="top:100px;"> <?php $cluster = new Cluster();?> <select name="clusterOpciones" id="clusterOpciones" onChange="obtener_pais(this.value); inicializa_vice();obtener_vicepresidencia_cluster(this.value);clus(this.value);"> <option name="clusterOpciones" id="clusterOpciones" value=" "> Selecciona un Cluster </option> <?php foreach($cluster->Load_all(1) as $arrE){ ?> <option name="clusterOpciones" id="clusterOpciones" value="<?php echo $arrE['c_nombre'];?>"> <?php echo $arrE['c_nombre'];?> </option> <?php } ?> </select> </td> </tr> <!-- Pais --> <tr> <?php if($INDEXIDIOMA == 2){
public function test_scenario5() { $data = array(array("filename" => "data/iris.csv", "options" => array("summary_fields" => array("sepal width"), 'seed' => 'BigML tests', 'cluster_seed' => 'BigML', 'k' => 8), "data_input" => array("petal length" => 1, "petal width" => 1, "sepal length" => 1, "species" => "Iris-setosa"), "centroid" => "Cluster 0", "distance" => 0.7310939266123302)); foreach ($data as $item) { print "I create a data source uploading a " . $item["filename"] . " file\n"; $source = self::$api->create_source($item["filename"], $options = array('name' => 'local_test_source')); $this->assertEquals(BigMLRequest::HTTP_CREATED, $source->code); $this->assertEquals(1, $source->object->status->code); print "check local source is ready\n"; $resource = self::$api->_check_resource($source->resource, null, 20000, 30); $this->assertEquals(BigMLRequest::FINISHED, $resource["status"]); print "create dataset with local source\n"; $dataset = self::$api->create_dataset($source->resource); $this->assertEquals(BigMLRequest::HTTP_CREATED, $dataset->code); $this->assertEquals(BigMLRequest::QUEUED, $dataset->object->status->code); print "check the dataset is ready " . $dataset->resource . " \n"; $resource = self::$api->_check_resource($dataset->resource, null, 20000, 30); $this->assertEquals(BigMLRequest::FINISHED, $resource["status"]); $cluster = self::$api->create_cluster($dataset->resource, $item["options"]); $this->assertEquals(BigMLRequest::HTTP_CREATED, $cluster->code); $this->assertEquals(BigMLRequest::QUEUED, $cluster->object->status->code); print "I wait until the cluster is ready\n"; $resource = self::$api->_check_resource($cluster->resource, null, 20000, 30); $this->assertEquals(BigMLRequest::FINISHED, $resource["status"]); $local_cluster = new Cluster($cluster->resource, self::$api); print "create a centroid\n"; $centroid = self::$api->create_centroid($cluster->resource, $item["data_input"]); print "Then the centroid is <centroid> with distance <distance>"; $this->assertEquals(round($item["distance"], 6), round($centroid->object->distance, 6)); $local_centroid = $local_cluster->centroid($item["data_input"]); print "the local centroid is " . $item["centroid"] . " with distance " . $item["distance"] . "\n"; $this->assertEquals($item["centroid"], $local_centroid["centroid_name"]); $this->assertEquals(round($item["distance"], 6), round($local_centroid["distance"], 6)); } }