Fix RecommandPoint Class

This commit is contained in:
Yuan Chiu 2015-01-25 20:29:15 +08:00
parent 9fe8401bde
commit 6f159c3a63
2 changed files with 22 additions and 11 deletions

View File

@ -1,4 +1,7 @@
<?php
/**
* RecommandPoint.php
*/
namespace UElearning\Recommand;
@ -14,13 +17,17 @@ use UElearning\Database;
/**
* 推薦學習點
*
* Usage:
* $recommand = new RecommandPoint();
*
* @version 2.0.0
* @package UElearning
* @subpackage Study
*/
class RecommandPoint
{
/**
/**
* 正規化參數
*
* @access private
@ -58,14 +65,13 @@ class RecommandPoint
$VirtualSum = 0; //虛擬學習點分別算權重之後的值
$edge = $this->recommand->queryEdgeByID('0');
$this->theme = new Study\Theme($theme_number);
for($i=0;$i<count($edge);$i++)
{
$next_point = $edge[$i]["next_point"];
$move_time = $edge[$i]["move_time"];
$next_target = new Target\Target($next_point);
$belong = $this->recommand->queryBelongByID($next_point,$theme->getId());
$belong = $this->recommand->queryBelongByID($next_point,$theme_number);
$weight = $belong["weight"];
$VirtualSum += $weight / $next_target->getLearnTime();
@ -94,14 +100,19 @@ class RecommandPoint
/**
* 過濾非法的標的
*
* @param array $point_list 全部的標的清單
* @param StudyActivity $activityObj 學習活動物件
* @return array 合法的學習點
*/
private function excludeIrregularTarget($point_list,$activityObj)
{
$regularTarget = array();
for($i=0;$i<count($point_list);$i++)
{
$nextPoint = $point_list[$i]["next_point"];
if($this->isEnableTargetId($a)ctivityObj,$nextPoint)) array_push($reregularTarget,$point_list[i]);
$nextPoint = $point_list[$i]['next_point'];
if($this->isEnableTargetId($activityObj,$nextPoint)) {
array_push($regularTarget,$point_list[$i]);
}
}
return $regularTarget;
}
@ -116,7 +127,7 @@ class RecommandPoint
public function recommand($current_point,$activity_number)
{
$this->activity = new Study\StudyActivity($activity_number);
$themeID = $activity->getThemeId();
$themeID = $this->activity->getThemeId();
$this->theme = new Study\Theme($themeID);
$this->gamma = $this->computeNormalizationParameter($themeID);
$pointList = $this->recommand->queryEdgeByID($current_point);
@ -130,7 +141,7 @@ class RecommandPoint
for($i=0;$i<count($targetList);$i++)
{
$next_point = $targetList[$i]["next_point"];
$moveTime = $targetList[$i]["MoveTime"];
$moveTime = $targetList[$i]["move_time"];
$nextPoint = new Target\Target($next_point);
$weight = $this->theme->getWeightByNextTarget($next_point);
if($nextPoint->isFullPeople())
@ -143,10 +154,10 @@ class RecommandPoint
{
if($nextPoint->isNumberOfPeopleZero()) $Rj = 0;
else $Rj = $nextPoint->getMj()/$nextPoint->getPLj();
$pastCost = RecommandPoint::ALPHA * $this->gamma * ($weight * ($nextPoint->getS()-$Rj+1)/$moveTime + $nextPoint->getLearnTime());
$virtualCost = RecommandPoint::ALPHA * $this->gamma * ($wright/$nextPoint->getLearnTime());
$pathCost = RecommandPoint::ALPHA * $this->gamma * ($weight * ($nextPoint->getS()-$Rj+1)/$moveTime + $nextPoint->getLearnTime());
$virtualCost = RecommandPoint::ALPHA * $this->gamma * ($weight/$nextPoint->getLearnTime());
}
array_push($recommand,array("nextPoint"=>$nextPoint,
array_push($recommand,array("nextPoint"=>$next_point,
"isEntity" => $isEntity,
"PathCost"=>$pathCost,
"VirtualCost"=>$virtualCost));