Fix 導引演算法
This commit is contained in:
parent
61642d9846
commit
85095457cc
@ -1353,22 +1353,26 @@ $app->group('/tokens', 'APIrequest', function () use ($app, $app_template) {
|
|||||||
// 取得本次採用的教材風格
|
// 取得本次採用的教材風格
|
||||||
$materialMode = $sact->getMaterialStyle();
|
$materialMode = $sact->getMaterialStyle();
|
||||||
|
|
||||||
// 取得推薦的學習點
|
|
||||||
$recommand = new Recommand\RecommandPoint();
|
|
||||||
$recommandResult = $recommand->recommand($currentTId, $saId);
|
|
||||||
$recommandTotal = count($recommandResult);
|
|
||||||
if($recommandTotal > $maxItemTotal) {
|
|
||||||
$result_recommand_total = $maxItemTotal;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$result_recommand_total = $recommandTotal;
|
|
||||||
}
|
|
||||||
// 是否已經學完了
|
// 是否已經學完了
|
||||||
if($sact->getRemainingPointTotal() <= 0) {
|
if($sact->getRemainingPointTotal() <= 0) {
|
||||||
$isEnd = true;
|
$isEnd = true;
|
||||||
|
|
||||||
|
$recommandResult = array();
|
||||||
|
$recommandTotal = 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$isEnd = false;
|
$isEnd = false;
|
||||||
|
|
||||||
|
// 取得推薦的學習點
|
||||||
|
$recommand = new Recommand\RecommandPoint();
|
||||||
|
$recommandResult = $recommand->recommand($currentTId, $saId);
|
||||||
|
$recommandTotal = count($recommandResult);
|
||||||
|
if($recommandTotal > $maxItemTotal) {
|
||||||
|
$result_recommand_total = $maxItemTotal;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$result_recommand_total = $recommandTotal;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 製作
|
// 製作
|
||||||
|
@ -128,6 +128,7 @@ class RecommandPoint
|
|||||||
{
|
{
|
||||||
$this->activity = new Study\StudyActivity($activity_number);
|
$this->activity = new Study\StudyActivity($activity_number);
|
||||||
$themeID = $this->activity->getThemeId();
|
$themeID = $this->activity->getThemeId();
|
||||||
|
$enableVirtual = $this->activity->isEnableVirtual();
|
||||||
$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);
|
||||||
@ -137,30 +138,40 @@ class RecommandPoint
|
|||||||
$pathCost = 0;
|
$pathCost = 0;
|
||||||
$VirtualPathCost = 0;
|
$VirtualPathCost = 0;
|
||||||
$recommand = array();
|
$recommand = array();
|
||||||
$isEntity = true;
|
|
||||||
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]["move_time"];
|
$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())
|
||||||
{
|
{
|
||||||
$pastCost = 0;
|
$pathCost = 0;
|
||||||
$virtualCost = RecommandPoint::ALPHA * $this->gamma * ($weight/$nextPoint->getLearnTime());
|
$virtualCost = RecommandPoint::ALPHA * $this->gamma * ($weight/$nextPoint->getLearnTime());
|
||||||
$isEntity=false;
|
$isEntity=false;
|
||||||
|
|
||||||
|
if($enableVirtual) {
|
||||||
|
array_push($recommand,array("nextPoint" => $next_point,
|
||||||
|
"isEntity" => $isEntity,
|
||||||
|
"PathCost" => $pathCost,
|
||||||
|
"VirtualCost" => $virtualCost));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
$isEntity=true;
|
||||||
if($nextPoint->isNumberOfPeopleZero()) $Rj = 0;
|
if($nextPoint->isNumberOfPeopleZero()) $Rj = 0;
|
||||||
else $Rj = $nextPoint->getMj()/$nextPoint->getPLj();
|
else $Rj = $nextPoint->getMj()/$nextPoint->getPLj();
|
||||||
$pathCost = 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 * ($weight/$nextPoint->getLearnTime());
|
$virtualCost = RecommandPoint::ALPHA * $this->gamma * ($weight/$nextPoint->getLearnTime());
|
||||||
}
|
|
||||||
array_push($recommand,array("nextPoint"=>$next_point,
|
array_push($recommand,array("nextPoint" => $next_point,
|
||||||
"isEntity" => $isEntity,
|
"isEntity" => $isEntity,
|
||||||
"PathCost"=>$pathCost,
|
"PathCost" => $pathCost,
|
||||||
"VirtualCost"=>$virtualCost));
|
"VirtualCost" => $virtualCost));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(count($recommand) >= 1) {
|
if(count($recommand) >= 1) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user