Skip to content

Commit

Permalink
Merge pull request #2 from nadahasnim/develop
Browse files Browse the repository at this point in the history
feature/fuzzy_calculation
  • Loading branch information
nadahasni-dot authored Aug 30, 2023
2 parents c2551cf + a98a522 commit b423f20
Show file tree
Hide file tree
Showing 25 changed files with 80,561 additions and 39,556 deletions.
12 changes: 12 additions & 0 deletions app/Http/Controllers/CalculateController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public function index(Project $project)
$ksloc = $project->ksloc();
$scaleFactor = $project->scaleFactor->scale_factor;
$effortMultiplier = $project->effortMultiplier->effort_multiplier;
$effortMultiplierFuzzy = $project->effortMultiplier->effort_multiplier_fuzzy;

// CALCULATE EXPONENTIAL FACTOR
define('B_CONSTANT', 0.91);
Expand All @@ -25,24 +26,35 @@ public function index(Project $project)
// EFFORT ESTIMATION
define('A_CONSTANT', 2.94);
$effortEstimation = A_CONSTANT * pow($ksloc, $exponentFactor) * $effortMultiplier;
$effortEstimationFuzzy = A_CONSTANT * pow($ksloc, $exponentFactor) * $effortMultiplierFuzzy;

// TIME ESTIMATION
define('C_CONSTANT', 3.67);
define('D_CONSTANT', 0.28);
$power = D_CONSTANT + (0.2 * ($exponentFactor - B_CONSTANT));
$timeEstimation = C_CONSTANT * pow($effortEstimation, $power);
$timeEstimationFuzzy = C_CONSTANT * pow($effortEstimationFuzzy, $power);

// STAFF ESTIMATION
$staffEstimation = $effortEstimation / $timeEstimation;
$staffEstimationFuzzy = $effortEstimation / $timeEstimationFuzzy;

// COST ESTIMATION
$staffCostEstimation = $staffEstimation * $project->avg_staff_cost;
$staffCostEstimationFuzzy = $staffEstimationFuzzy * $project->avg_staff_cost;
$totalCostEstimation = $staffCostEstimation * $timeEstimation;
$totalCostEstimationFuzzy = $staffCostEstimationFuzzy * $timeEstimation;

$project->est_effort = $effortEstimation;
$project->est_time = $timeEstimation;
$project->est_staff = $staffEstimation;
$project->est_cost = $totalCostEstimation;

$project->est_effort_fuzzy = $effortEstimationFuzzy;
$project->est_time_fuzzy = $timeEstimationFuzzy;
$project->est_staff_fuzzy = $staffEstimationFuzzy;
$project->est_cost_fuzzy = $totalCostEstimationFuzzy;

$project->status = 1;

if ($project->save()) {
Expand Down
23 changes: 23 additions & 0 deletions app/Http/Controllers/EffortMultiplierController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Http\Controllers;

use App\Http\Requests\EffortMultiplier\CreateEffortMultiplierRequest;
use App\Logic\FuzzyLogic;
use App\Models\EffortMultiplier;
use App\Models\Project;
use Illuminate\Http\Request;
Expand Down Expand Up @@ -184,6 +185,28 @@ public function update(CreateEffortMultiplierRequest $request, Project $project,
abs($data['sced']),
);

// EFFORT MULTIPLIER FUZZY
$fuzzyLogic = new FuzzyLogic([
'rely' => abs($data['rely']),
'data' => abs($data['data']),
'cplx' => abs($data['cplx']),
'docu' => abs($data['docu']),
'acap' => abs($data['acap']),
'pcap' => abs($data['pcap']),
'pcon' => abs($data['pcon']),
'ruse' => abs($data['ruse']),
'time' => abs($data['time']),
'stor' => abs($data['stor']),
'pvol' => abs($data['pvol']),
'aplex' => abs($data['aplex']),
'plex' => abs($data['plex']),
'ltex' => abs($data['ltex']),
'tool' => abs($data['tool']),
'site' => abs($data['site']),
'sced' => abs($data['sced']),
]);
$effortmultiplier->effort_multiplier_fuzzy = $fuzzyLogic->calculateFuzzy();

if ($effortmultiplier->save()) {
return redirect()->route('projects.show', [$project]);
}
Expand Down
123 changes: 123 additions & 0 deletions app/Logic/Acap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
<?php

namespace App\Logic;

class Acap extends Membership
{
private $input;

/**
* Create RELY input membership instance
*
* @param float $input
*/
public function __construct(float $input)
{
$this->input = $input;
}

/**
* Calculate membership
*
* @return array
*/
public function calculateMembership()
{
$input = $this->input;
$calculations = [];

// EXTRA HIGH
$calculations['EXTRA_HIGH'] = 0;

// VERY HIGH
$veryHigh = 1;

if ($input > 0.71 && $input < 0.85) {
$veryHigh = $this->alphaPredicateDown(0.71, 0.85, $input);
}

if ($input >= 0.85) {
$veryHigh = 0;
}

$calculations['VERY_HIGH'] = $veryHigh;

// HIGH
$high = 0;

if ($input > 0.71 && $input < 0.85) {
$high = $this->alphaPredicateUp(0.71, 0.85, $input);
}

if ($input == 0.85) {
$high = 1;
}

if ($input > 0.85 && $input < 1) {
$high = $this->alphaPredicateDown(0.85, 1, $input);
}

if ($input >= 1) {
$high = 0;
}

$calculations['HIGH'] = $high;

// NOMINAL
$nominal = 0;

if ($input > 0.85 && $input < 1) {
$nominal = $this->alphaPredicateUp(0.85, 1, $input);
}

if ($input == 1) {
$nominal = 1;
}

if ($input > 1 && $input < 1.19) {
$nominal = $this->alphaPredicateDown(1, 1.19, $input);
}

if ($input >= 1.19) {
$nominal = 0;
}

$calculations['NOMINAL'] = $nominal;

// LOW
$low = 0;

if ($input > 1 && $input < 1.19) {
$low = $this->alphaPredicateUp(1, 1.19, $input);
}

if ($input == 1.19) {
$low = 1;
}

if ($input > 1.19 && $input < 1.42) {
$low = $this->alphaPredicateDown(1.19, 1.42, $input);
}

if ($input >= 1.42) {
$low = 0;
}

$calculations['LOW'] = $low;

// VERY LOW
$veryLow = 0;

if ($input > 1.19 && $input < 1.42) {
$veryLow = $this->alphaPredicateUp(1.19, 1.42, $input);
}

if ($input >= 1.42) {
$veryLow = 1;
}

$calculations['VERY_LOW'] = $veryLow;

return array_reverse($calculations);
}
}
123 changes: 123 additions & 0 deletions app/Logic/Aplex.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
<?php

namespace App\Logic;

class Aplex extends Membership
{
private $input;

/**
* Create RELY input membership instance
*
* @param float $input
*/
public function __construct(float $input)
{
$this->input = $input;
}

/**
* Calculate membership
*
* @return array
*/
public function calculateMembership()
{
$input = $this->input;
$calculations = [];

// EXTRA HIGH
$calculations['EXTRA_HIGH'] = 0;

// VERY HIGH
$veryHigh = 1;

if ($input > 0.76 && $input < 0.88) {
$veryHigh = $this->alphaPredicateDown(0.76, 0.88, $input);
}

if ($input >= 0.88) {
$veryHigh = 0;
}

$calculations['VERY_HIGH'] = $veryHigh;

// HIGH
$high = 0;

if ($input > 0.76 && $input < 0.88) {
$high = $this->alphaPredicateUp(0.76, 0.88, $input);
}

if ($input == 0.88) {
$high = 1;
}

if ($input > 0.88 && $input < 1) {
$high = $this->alphaPredicateDown(0.88, 1, $input);
}

if ($input >= 1) {
$high = 0;
}

$calculations['HIGH'] = $high;

// NOMINAL
$nominal = 0;

if ($input > 0.88 && $input < 1) {
$nominal = $this->alphaPredicateUp(0.88, 1, $input);
}

if ($input == 1) {
$nominal = 1;
}

if ($input > 1 && $input < 1.1) {
$nominal = $this->alphaPredicateDown(1, 1.1, $input);
}

if ($input >= 1.1) {
$nominal = 0;
}

$calculations['NOMINAL'] = $nominal;

// LOW
$low = 0;

if ($input > 1 && $input < 1.1) {
$low = $this->alphaPredicateUp(1, 1.1, $input);
}

if ($input == 1.1) {
$low = 1;
}

if ($input > 1.1 && $input < 1.22) {
$low = $this->alphaPredicateDown(1.1, 1.22, $input);
}

if ($input >= 1.22) {
$low = 0;
}

$calculations['LOW'] = $low;

// VERY LOW
$veryLow = 0;

if ($input > 1.1 && $input < 1.22) {
$veryLow = $this->alphaPredicateUp(1.1, 1.22, $input);
}

if ($input >= 1.22) {
$veryLow = 1;
}

$calculations['VERY_LOW'] = $veryLow;

return array_reverse($calculations);
}
}
Loading

0 comments on commit b423f20

Please sign in to comment.