require_once MODULE_DIR . "statistics/mod.query.inc"; require_once MODULE_DIR . "ind_functions.inc"; include_once MODULE_DIR . "edasimuuja.inc"; //require_once(MODULE_DIR . "sitevariables/mod.sitevariables.inc"); if (!$objIPAccess->fnValidate($arrAllowIP["access"], $_SERVER["REMOTE_ADDR"]) or $objIPAccess->fnValidate($arrAllowIP["deny"], $_SERVER["REMOTE_ADDR"])) { header("Location: " . LOGINCENTER_PATH); } if (!is_object($_SESSION["user"])) { header("Location: " . LOGINCENTER_PATH); } require_once CONFIG_DIR . $_SESSION["lang"] . ".translation.inc"; foreach ($_POST as $key => $value) { $_POST[$key] = norm($value); } foreach ($_GET as $key => $value) { $_GET[$key] = norm($value); } $strUsertype = "client"; if ($_POST['ID']) { $recData['ID'] = $_POST['ID']; $recData['userID'] = $_POST['userID']; } $recData['fname'] = $_POST['form_fname']; $recData['contact_name'] = $_POST['form_contact']; $recData['email'] = $_POST['form_email']; $recData['password'] = $_POST['form_password']; $recData['telefon'] = $_POST['form_telefon']; $recData['fax'] = $_POST['form_fax']; $recData['http'] = $_POST['form_http']; $recData['markused'] = $_POST['form_markused']; $recData['index'] = $_POST['form_index'];
// print_r ($norm_crt); $sumf_crtPD = sumfunc($norm_crt); // print_r($sumf_crtPD); /**********Matrix for two criteria (price and entertainment)***********/ $critPE = array(array(1, 0, 4), array(0, 0, 0), array(1 / 4, 0, 1)); $sum_crit = sum($critPE); // print_r ($sum_crit); $norm_crt = norm($critPE, $sum_crit); // print_r ($norm_crt); $sumf_crtPE = sumfunc($norm_crt); // print_r($sumf_crtPE); /**********Matrix for two criteria (distance and entertainment)***********/ $critDE = array(array(0, 0, 0), array(0, 1, 3), array(0, 1 / 3, 1)); $sum_crit = sum($critDE); // print_r ($sum_crit); $norm_crt = norm($critDE, $sum_crit); // print_r ($norm_crt); $sumf_crtDE = sumfunc($norm_crt); // print_r($sumf_crtDE); /***************Compute decision matrix from alternative vectors**************************************/ $result = array(); for ($l = 0; $l < 3; $l++) { if ($l == 0) { $v = $sumf_p; } elseif ($l == 1) { $v = $sumf_d; } elseif ($l == 2) { $v = $sumf_e; } $i = 0; foreach ($v as $key => $value) {
/** * Cosine similarity for non-normalised vectors * sim(a, b) = (a�b) / (||a|| * ||b||) * * @param array $a * @param array $b * @return mixed */ function cosinus(array $a, array $b) { $normA = norm($a); $normB = norm($b); return $normA * $normB != 0 ? dotProduct($a, $b) / ($normA * $normB) : 0; }
function normalize($vector) { return scalarProduct($vector, 1 / norm($vector)); }
$person_node = $people_node->addChild('person'); $id_node = $person_node->addChild('id', $id); $group_node = $person_node->addChild('groupid', $gruppo_id); if (!in_array($gruppo_id, $arr_gruppi)) { $arr_gruppi[] = $gruppo_id; } $name_node = $person_node->addChild('name', $nome); $surname_node = $person_node->addChild('surname', $cognome); $x_node = $person_node->addChild('x', sprintf('%7.2f', norm($x, $XYZ_MAX, $xyz_max))); // hack per leggere le colonne giuste dai files di coordinate if ($ramo == 'C') { $y_node = $person_node->addChild('y', sprintf('%7.2f', norm($y, $XYZ_MAX, $xyz_max))); } else { $y_node = $person_node->addChild('y', sprintf('%7.2f', norm($z, $XYZ_MAX, $xyz_max))); } printf("%d: (%7.2f, %7.2f) %s %s - %d [%d]\n\n", $cnt, norm($x, $XYZ_MAX, $xyz_max), norm($z, $XYZ_MAX, $xyz_max), $nome, $cognome, $gruppo_id, $id); } $groups_node = $xml->addChild('groups'); $c = new Criteria(); $c->add(OppGruppoPeer::ID, $arr_gruppi, Criteria::IN); $c->addAscendingOrderByColumn(OppGruppoPeer::ID); $gruppi = OppGruppoPeer::doSelect($c); foreach ($gruppi as $gruppo) { //HACK PER GRUPPO FUTURO E LIBERTA' if ($gruppo->getId() == 21) { $gruppo_id = 1; } else { $gruppo_id = $gruppo->getId(); } $group_node = $groups_node->addChild('group'); $id_group = $group_node->addChild('id', $gruppo_id);
private function getCat($mas, $st, $par, $deep, $temp, $type, $lemit) { $st .= $temp['start']; foreach ($mas as $k => $v) { $ma = $this->get_List(array("Parent_id" => $v['id'], "count" => 100)); if ($ma && $deep <= $lemit) { $deep1 = $deep; $deep1++; $varr = $this->getCat($ma, "", $v['id'], $deep1, $temp, $type, $lemit); } else { $varr = ""; } $par1 = ""; if ($deep == 1) { $par1 = first($v); } else { if ($deep == $this->maxDeep) { $par1 = last($v); } else { $par1 = norm($v); } } $st .= "<li class='dd-item dd3-item' data-id='{$v['id']}'>\n {$par1}\n {$varr}\n </li>"; } $st .= $temp['end']; return $st; }