示例#1
0
 public function calcFuzzy()
 {
     $this->clearSolution();
     $sum = 0;
     $tmpx = array();
     $sum = array();
     $cnt = array();
     // fill output agregate table
     foreach ($this->getOutputNames() as $outname) {
         $AgregateDeltaX = ($this->FMax[$outname] - $this->FMin[$outname]) / $this->AgregatePoints;
         $this->FXValues[$outname] = Range($this->FMin[$outname], $this->FMax[$outname], $AgregateDeltaX);
         $this->FYValues[$outname] = array_fill(0, count($this->FXValues[$outname]), 0.0);
     }
     $rules = $this->getRules();
     foreach ($rules as $key => $rule) {
         list($outItem, $value) = $this->processRule($rule);
         list($outputName, $memberName) = preg_split("/\\./", $outItem);
         $this->StateOutput[$memberName] = $value;
         $member = $this->getMemberByName($outputName, $memberName);
         // get OUTPUT member
         if ($value > 0) {
             $this->fuzzyAgregate($outputName, $member, $value);
         }
     }
     $result = array();
     foreach ($this->getOutputNames() as $outname) {
         $suma = 0.0;
         $sumb = 0.0;
         foreach ($this->FXValues[$outname] as $id => $x) {
             $y = $this->FYValues[$outname][$id];
             if ($y > 0) {
                 $suma += $x * $y;
                 $sumb += $y;
             }
         }
         if ($sumb == 0) {
             $result[$outname] = 0;
         } else {
             $result[$outname] = $suma / $sumb;
         }
     }
     return $result;
 }
示例#2
0
                $Group = $group;
            }
            if (isset($_REQUEST['del'])) {
                safe_w_sql("delete from TargetGroups\n\t\t\t\t\twhere TgTournament={$_SESSION['TourId']} and TgTargetNo='{$tgt}'");
            } else {
                safe_w_sql("insert into TargetGroups\n\t\t\t\t\tset TgTournament={$_SESSION['TourId']},\n\t\t\t\t\tTgSession=" . substr($tgt, 0, 1) . ",\n\t\t\t\t\tTgSesType='" . $SesType . ($SPhase ? $SPhase : '') . "',\n\t\t\t\t\tTgTargetNo='{$tgt}',\n\t\t\t\t\tTgGroup=" . StrSafe_DB($group) . "\n\t\t\t\t\ton duplicate key update\n\t\t\t\t\tTgGroup=" . StrSafe_DB($group) . "\n\t\t\t\t\t\t\t");
            }
        }
    }
}
header('Content-Type: text/xml');
print '<response>' . "\n";
print '<error>0</error>' . "\n";
if (isset($_REQUEST['new'])) {
    require_once './lib.php';
    switch ($SesType) {
        case 'Q':
            $q = safe_r_sql(getSesSQL('Q', $Session));
            $SesRow = safe_fetch($q);
            $SesRow->Range = Range($SesRow->SesFirstTarget, $SesRow->SesTar4Session + $SesRow->SesFirstTarget - 1);
            break;
        case 'E':
            $q = safe_r_sql(getSesSQL('E', $Session, $Phase));
            $SesRow = safe_fetch($q);
            $SesRow->Range = explode(',', $SesRow->SesTar4Session);
            break;
    }
    $ret = BuildGroups($SesType, $Session, $Phase, $SesRow->Range, $Group);
    echo "<row><![CDATA[{$ret}]]></row>";
}
print '</response>' . "\n";