Skip to content

Commit 4f2cca7

Browse files
committed
feat: mcda new insight Differentiating criteria
1 parent f6aaad4 commit 4f2cca7

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

src/lib/helpers/mcda-format.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,10 @@ export const buildMcdaKeyInsights = (
182182
let conflictDetail =
183183
"Add at least two GAIA criteria vectors to estimate trade-off conflicts.";
184184

185+
let differentiatingCriteriaValue = "Not enough GAIA criteria";
186+
let differentiatingCriteriaDetail =
187+
"Add GAIA criteria vectors to identify the most differentiating criteria.";
188+
185189
const gaiaCriteria = results.gaia_criteria ?? [];
186190
if (gaiaCriteria.length >= 2) {
187191
let bestPair: [string, string] | null = null;
@@ -218,6 +222,26 @@ export const buildMcdaKeyInsights = (
218222
}
219223
}
220224

225+
const criteriaByLength = gaiaCriteria
226+
.map((criterion) => ({
227+
key: criterion.key,
228+
label: criteriaLabels[criterion.key] || criterion.key,
229+
length: Math.hypot(criterion.x, criterion.y),
230+
}))
231+
.filter((criterion) => criterion.length > 0)
232+
.sort((a, b) => b.length - a.length);
233+
234+
if (criteriaByLength.length > 0) {
235+
const topDifferentiatingCriteria = criteriaByLength.slice(0, 3);
236+
const topCount = topDifferentiatingCriteria.length;
237+
differentiatingCriteriaValue = topDifferentiatingCriteria
238+
.map((criterion) => criterion.label)
239+
.join(", ");
240+
differentiatingCriteriaDetail = `Top ${topCount} by vector length: ${topDifferentiatingCriteria
241+
.map((criterion) => criterion.length.toFixed(2))
242+
.join(", ")}.`;
243+
}
244+
221245
let alignmentValue = "Not enough GAIA vectors";
222246
let alignmentDetail =
223247
"Decision stick and GAIA alternatives are required to estimate alignment.";
@@ -304,6 +328,14 @@ export const buildMcdaKeyInsights = (
304328
tooltip:
305329
"GAIA quality indicates how much decision information is preserved in the 2D plane.",
306330
},
331+
{
332+
title: "Differentiating criteria",
333+
description: "Most discriminating in the GAIA plane",
334+
value: differentiatingCriteriaValue,
335+
detail: differentiatingCriteriaDetail,
336+
tooltip:
337+
"Longer criterion vectors in the GAIA plane indicate stronger discrimination between alternatives.",
338+
},
307339
// {
308340
// title: "Decision alignment",
309341
// description: "Best aligned with GAIA decision stick",

0 commit comments

Comments
 (0)