- Notifications
You must be signed in to change notification settings - Fork 1.6k
/
Copy pathDecisionsConvolutions.cs
74 lines (63 loc) · 2.73 KB
/
DecisionsConvolutions.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
usingSystem.Collections.Generic;
usingSystem.Linq;
namespaceAlgorithms.Other;
/// <summary>
/// Almost all real complex decision-making task is described by more than one criterion.
/// There are different methods to select the best decisions from the defined set of decisions.
/// This class contains implementations of the popular convolution methods: linear and maxmin.
/// </summary>
publicstaticclassDecisionsConvolutions
{
/// <summary>
/// This method implements the linear method of decision selection. It is based on
/// the calculation of the "value" for each decision and the selection of the most
/// valuable one.
/// </summary>
/// <param name="matrix">Contains a collection of the criteria sets.</param>
/// <param name="priorities">Contains a set of priorities for each criterion.</param>
/// <returns>The most effective decision that is represented by a set of criterias.</returns>
publicstaticList<decimal>Linear(List<List<decimal>>matrix,List<decimal>priorities)
{
vardecisionValues=newList<decimal>();
foreach(vardecisioninmatrix)
{
decimalsum=0;
for(inti=0;i<decision.Count;i++)
{
sum+=decision[i]*priorities[i];
}
decisionValues.Add(sum);
}
decimalbestDecisionValue=decisionValues.Max();
intbestDecisionIndex=decisionValues.IndexOf(bestDecisionValue);
returnmatrix[bestDecisionIndex];
}
/// <summary>
/// This method implements maxmin method of the decision selection. It is based on
/// the calculation of the least criteria value and comparison of decisions based
/// on the calculated results.
/// </summary>
/// <param name="matrix">Contains a collection of the criteria sets.</param>
/// <param name="priorities">Contains a set of priorities for each criterion.</param>
/// <returns>The most effective decision that is represented by a set of criterias.</returns>
publicstaticList<decimal>MaxMin(List<List<decimal>>matrix,List<decimal>priorities)
{
vardecisionValues=newList<decimal>();
foreach(vardecisioninmatrix)
{
decimalminValue=decimal.MaxValue;
for(inti=0;i<decision.Count;i++)
{
decimalresult=decision[i]*priorities[i];
if(result<minValue)
{
minValue=result;
}
}
decisionValues.Add(minValue);
}
decimalbestDecisionValue=decisionValues.Max();
intbestDecisionIndex=decisionValues.IndexOf(bestDecisionValue);
returnmatrix[bestDecisionIndex];
}
}