diff --git a/app/Http/Controllers/APIController.php b/app/Http/Controllers/APIController.php index cad4a0c57ecb93e00f03df5e4c36e09e36a66d56..87d9734b52d780a5f3aff5eb5ded2effe23ca260 100644 --- a/app/Http/Controllers/APIController.php +++ b/app/Http/Controllers/APIController.php @@ -52,11 +52,7 @@ class APIController extends Controller $population = new Population(); - $forgettingFactor = Config::get('app.forgetting_factor', 0.99); - if (isset($attributes['forgetting_factor'])) { - $forgettingFactor = 1 - 0.01 * $attributes['forgetting_factor']; - } - $population->forgetting_factor = $forgettingFactor; + $population->forgetting_factor = isset($attributes['forgetting_factor']) ? $attributes['forgetting_factor'] : Config::get('app.forgetting_factor', 1); $population->follower_factor = isset($attributes['follower_factor']) ? $attributes['follower_factor'] : Config::get('app.follower_factor', 100); @@ -1108,6 +1104,8 @@ class APIController extends Controller //$votersFactorA = $templatePopulation->no_of_child_populations * $countA; //$votersFactorB = $templatePopulation->no_of_child_populations * $countB; + $previousWeightShareB = 0; + for ($i = 0; $i < $minElectionCount; $i++) { $newWeight = new \stdClass(); $newWeight->min_sum_weight_a = $minWeightsSequencesA[$i]; @@ -1121,6 +1119,9 @@ class APIController extends Controller $newWeight->share_sum_weight_b = $weightShareSequenceB[$i] / $templatePopulation->no_of_child_populations; $newWeight->min_share_sum_weight_b = $minWeightShareSequenceB[$i]; $newWeight->max_share_sum_weight_b = $maxWeightShareSequenceB[$i]; + $shareDiff = $newWeight->share_sum_weight_b - $previousWeightShareB; + $newWeight->diff_share_sum_weight_b = $shareDiff > 0 ? $shareDiff : -$shareDiff; + $previousWeightShareB = $newWeight->share_sum_weight_b; array_push($weightsAvgTimeline, $newWeight); } diff --git a/public/js/app.js b/public/js/app.js index b6e20140dc8db7413db96a07511d3150a2255e35..5117590f1a4e2f9edcda93fa5448755741124f75 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -3956,6 +3956,12 @@ __webpack_require__.r(__webpack_exports__); // // // +// +// +// +// +// +// @@ -4018,6 +4024,7 @@ __webpack_require__.r(__webpack_exports__); var share_sum_weight_b = []; var min_share_sum_weight_b = []; var max_share_sum_weight_b = []; + var diff_share_sum_weight_b = []; this.analytics_weights_timeline.weights.forEach(function (value, idx) { labels.push(idx); avg_sum_weight_a.push(value.avg_sum_weight_a); @@ -4029,6 +4036,7 @@ __webpack_require__.r(__webpack_exports__); share_sum_weight_b.push(value.share_sum_weight_b); min_share_sum_weight_b.push(value.min_share_sum_weight_b); max_share_sum_weight_b.push(value.max_share_sum_weight_b); + diff_share_sum_weight_b.push(value.diff_share_sum_weight_b); }); return { labels: labels, @@ -4037,39 +4045,45 @@ __webpack_require__.r(__webpack_exports__); borderColor: '#169c03', fill: false, data: avg_sum_weight_a, - yAxisID: 'left-y-axis' + yAxisID: 'left-y-axis', + hidden: true }, { label: 'Group A (min sum Weight)', borderColor: '#819c67', fill: false, data: min_sum_weight_a, - yAxisID: 'left-y-axis' + yAxisID: 'left-y-axis', + hidden: true }, { label: 'Group A (max sum Weight)', borderColor: '#819c67', fill: false, data: max_sum_weight_a, - yAxisID: 'left-y-axis' + yAxisID: 'left-y-axis', + hidden: true }, { label: 'Group B (avg sum Weight)', borderColor: '#00259b', fill: false, data: avg_sum_weight_b, - yAxisID: 'left-y-axis' + yAxisID: 'left-y-axis', + hidden: true }, { label: 'Group B (min sum Weight)', borderColor: '#517e9b', fill: false, data: min_sum_weight_b, - yAxisID: 'left-y-axis' + yAxisID: 'left-y-axis', + hidden: true }, { label: 'Group B (max sum Weight)', borderColor: '#517e9b', fill: false, data: max_sum_weight_b, - yAxisID: 'left-y-axis' + yAxisID: 'left-y-axis', + hidden: true }, { - label: 'Group B - sum Weight share', + label: 'Group B - Weight share', borderColor: '#b73c33', fill: false, data: share_sum_weight_b, @@ -4079,13 +4093,21 @@ __webpack_require__.r(__webpack_exports__); borderColor: '#b78365', fill: false, data: min_share_sum_weight_b, - yAxisID: 'right-y-axis' + yAxisID: 'right-y-axis', + hidden: true }, { label: 'Group B - max Weight share', borderColor: '#b78365', fill: false, data: max_share_sum_weight_b, - yAxisID: 'right-y-axis' + yAxisID: 'right-y-axis', + hidden: true + }, { + label: 'Group B - DIFF Weight share', + borderColor: '#b75d02', + fill: false, + data: diff_share_sum_weight_b, + yAxisID: 'left-y-axis' }] }; } @@ -82428,7 +82450,7 @@ var render = function() { _vm.last_elections_data ? _c("div", { staticClass: "text-info" }, [ _vm._v( - "\n Population: (" + + "\n [DONE]\n Population: (" + _vm._s( _vm.last_elections_data .population_name @@ -82450,6 +82472,21 @@ var render = function() { ")\n " ) ]) + : _vm.running_elections_lock + ? _c("div", [ + _c("i", { staticClass: "text-info" }, [ + _vm._v( + "\n Running " + + _vm._s( + _vm.custom_number_elections + ) + + " election" + ), + _vm.custom_number_elections > 1 + ? _c("span", [_vm._v("s ...")]) + : _vm._e() + ]) + ]) : _c("div", [ _c("i", { staticClass: "text-muted" }, [ _vm._v("N/A (run elections first)") diff --git a/resources/js/components/population-template-show.vue b/resources/js/components/population-template-show.vue index fc43feeb0d7819b6c1946dbe685a2638ecc452d3..19dc8db61c9ab0a9dab898506ec49c0a31cca1e1 100644 --- a/resources/js/components/population-template-show.vue +++ b/resources/js/components/population-template-show.vue @@ -186,11 +186,17 @@ <div class="col-md-9 col-lg-9"> <h6>Last elections status: </h6> <div v-if="last_elections_data" class="text-info"> + [DONE] Population: ({{last_elections_data.population_name}}), Election type: ({{last_elections_data.elections_type}}), Number of elections: ({{last_elections_data.number_of_elections}}), Time: ({{last_elections_data.total_time}}) </div> + <div v-else-if="running_elections_lock"> + <i class="text-info"> + Running {{custom_number_elections}} election<span v-if="custom_number_elections > 1">s ...</span> + </i> + </div> <div v-else><i class="text-muted">N/A (run elections first)</i></div> </div> <div class="col-md-3 col-lg-3"> @@ -310,6 +316,7 @@ let share_sum_weight_b = []; let min_share_sum_weight_b = []; let max_share_sum_weight_b = []; + let diff_share_sum_weight_b = []; this.analytics_weights_timeline.weights.forEach((value,idx) => { labels.push(idx); avg_sum_weight_a.push(value.avg_sum_weight_a); @@ -321,6 +328,7 @@ share_sum_weight_b.push(value.share_sum_weight_b); min_share_sum_weight_b.push(value.min_share_sum_weight_b); max_share_sum_weight_b.push(value.max_share_sum_weight_b); + diff_share_sum_weight_b.push(value.diff_share_sum_weight_b); }); return { labels: labels, @@ -330,21 +338,24 @@ borderColor: '#169c03', fill: false, data: avg_sum_weight_a, - yAxisID: 'left-y-axis' + yAxisID: 'left-y-axis', + hidden: true }, { label: 'Group A (min sum Weight)', borderColor: '#819c67', fill: false, data: min_sum_weight_a, - yAxisID: 'left-y-axis' + yAxisID: 'left-y-axis', + hidden: true }, { label: 'Group A (max sum Weight)', borderColor: '#819c67', fill: false, data: max_sum_weight_a, - yAxisID: 'left-y-axis' + yAxisID: 'left-y-axis', + hidden: true }, { @@ -352,24 +363,27 @@ borderColor: '#00259b', fill: false, data: avg_sum_weight_b, - yAxisID: 'left-y-axis' + yAxisID: 'left-y-axis', + hidden: true }, { label: 'Group B (min sum Weight)', borderColor: '#517e9b', fill: false, data: min_sum_weight_b, - yAxisID: 'left-y-axis' + yAxisID: 'left-y-axis', + hidden: true }, { label: 'Group B (max sum Weight)', borderColor: '#517e9b', fill: false, data: max_sum_weight_b, - yAxisID: 'left-y-axis' + yAxisID: 'left-y-axis', + hidden: true }, { - label: 'Group B - sum Weight share', + label: 'Group B - Weight share', borderColor: '#b73c33', fill: false, data: share_sum_weight_b, @@ -380,14 +394,23 @@ borderColor: '#b78365', fill: false, data: min_share_sum_weight_b, - yAxisID: 'right-y-axis' + yAxisID: 'right-y-axis', + hidden: true }, { label: 'Group B - max Weight share', borderColor: '#b78365', fill: false, data: max_share_sum_weight_b, - yAxisID: 'right-y-axis' + yAxisID: 'right-y-axis', + hidden: true + }, + { + label: 'Group B - DIFF Weight share', + borderColor: '#b75d02', + fill: false, + data: diff_share_sum_weight_b, + yAxisID: 'left-y-axis' } ] }