Fix RecommandPoint Class
This commit is contained in:
parent
9fe8401bde
commit
6f159c3a63
@ -1,4 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* RecommandPoint.php
|
||||||
|
*/
|
||||||
|
|
||||||
namespace UElearning\Recommand;
|
namespace UElearning\Recommand;
|
||||||
|
|
||||||
@ -14,10 +17,14 @@ use UElearning\Database;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 推薦學習點
|
* 推薦學習點
|
||||||
|
*
|
||||||
* Usage:
|
* Usage:
|
||||||
* $recommand = new RecommandPoint();
|
* $recommand = new RecommandPoint();
|
||||||
|
*
|
||||||
|
* @version 2.0.0
|
||||||
|
* @package UElearning
|
||||||
|
* @subpackage Study
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class RecommandPoint
|
class RecommandPoint
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@ -58,14 +65,13 @@ class RecommandPoint
|
|||||||
$VirtualSum = 0; //虛擬學習點分別算權重之後的值
|
$VirtualSum = 0; //虛擬學習點分別算權重之後的值
|
||||||
|
|
||||||
$edge = $this->recommand->queryEdgeByID('0');
|
$edge = $this->recommand->queryEdgeByID('0');
|
||||||
$this->theme = new Study\Theme($theme_number);
|
|
||||||
|
|
||||||
for($i=0;$i<count($edge);$i++)
|
for($i=0;$i<count($edge);$i++)
|
||||||
{
|
{
|
||||||
$next_point = $edge[$i]["next_point"];
|
$next_point = $edge[$i]["next_point"];
|
||||||
$move_time = $edge[$i]["move_time"];
|
$move_time = $edge[$i]["move_time"];
|
||||||
$next_target = new Target\Target($next_point);
|
$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"];
|
$weight = $belong["weight"];
|
||||||
|
|
||||||
$VirtualSum += $weight / $next_target->getLearnTime();
|
$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)
|
private function excludeIrregularTarget($point_list,$activityObj)
|
||||||
{
|
{
|
||||||
$regularTarget = array();
|
$regularTarget = array();
|
||||||
for($i=0;$i<count($point_list);$i++)
|
for($i=0;$i<count($point_list);$i++)
|
||||||
{
|
{
|
||||||
$nextPoint = $point_list[$i]["next_point"];
|
$nextPoint = $point_list[$i]['next_point'];
|
||||||
if($this->isEnableTargetId($a)ctivityObj,$nextPoint)) array_push($reregularTarget,$point_list[i]);
|
if($this->isEnableTargetId($activityObj,$nextPoint)) {
|
||||||
|
array_push($regularTarget,$point_list[$i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return $regularTarget;
|
return $regularTarget;
|
||||||
}
|
}
|
||||||
@ -116,7 +127,7 @@ class RecommandPoint
|
|||||||
public function recommand($current_point,$activity_number)
|
public function recommand($current_point,$activity_number)
|
||||||
{
|
{
|
||||||
$this->activity = new Study\StudyActivity($activity_number);
|
$this->activity = new Study\StudyActivity($activity_number);
|
||||||
$themeID = $activity->getThemeId();
|
$themeID = $this->activity->getThemeId();
|
||||||
$this->theme = new Study\Theme($themeID);
|
$this->theme = new Study\Theme($themeID);
|
||||||
$this->gamma = $this->computeNormalizationParameter($themeID);
|
$this->gamma = $this->computeNormalizationParameter($themeID);
|
||||||
$pointList = $this->recommand->queryEdgeByID($current_point);
|
$pointList = $this->recommand->queryEdgeByID($current_point);
|
||||||
@ -130,7 +141,7 @@ class RecommandPoint
|
|||||||
for($i=0;$i<count($targetList);$i++)
|
for($i=0;$i<count($targetList);$i++)
|
||||||
{
|
{
|
||||||
$next_point = $targetList[$i]["next_point"];
|
$next_point = $targetList[$i]["next_point"];
|
||||||
$moveTime = $targetList[$i]["MoveTime"];
|
$moveTime = $targetList[$i]["move_time"];
|
||||||
$nextPoint = new Target\Target($next_point);
|
$nextPoint = new Target\Target($next_point);
|
||||||
$weight = $this->theme->getWeightByNextTarget($next_point);
|
$weight = $this->theme->getWeightByNextTarget($next_point);
|
||||||
if($nextPoint->isFullPeople())
|
if($nextPoint->isFullPeople())
|
||||||
@ -143,10 +154,10 @@ class RecommandPoint
|
|||||||
{
|
{
|
||||||
if($nextPoint->isNumberOfPeopleZero()) $Rj = 0;
|
if($nextPoint->isNumberOfPeopleZero()) $Rj = 0;
|
||||||
else $Rj = $nextPoint->getMj()/$nextPoint->getPLj();
|
else $Rj = $nextPoint->getMj()/$nextPoint->getPLj();
|
||||||
$pastCost = RecommandPoint::ALPHA * $this->gamma * ($weight * ($nextPoint->getS()-$Rj+1)/$moveTime + $nextPoint->getLearnTime());
|
$pathCost = RecommandPoint::ALPHA * $this->gamma * ($weight * ($nextPoint->getS()-$Rj+1)/$moveTime + $nextPoint->getLearnTime());
|
||||||
$virtualCost = RecommandPoint::ALPHA * $this->gamma * ($wright/$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,
|
"isEntity" => $isEntity,
|
||||||
"PathCost"=>$pathCost,
|
"PathCost"=>$pathCost,
|
||||||
"VirtualCost"=>$virtualCost));
|
"VirtualCost"=>$virtualCost));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user