Skip to content

Commit 5c28fe5

Browse files
committed
Add project files.
1 parent 8f371c4 commit 5c28fe5

60 files changed

Lines changed: 2955 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

AnalyticHierarchyProcess.sln

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.4.33213.308
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AnalyticHierarchyProcess", "AnalyticHierarchyProcess\AnalyticHierarchyProcess.csproj", "{1309E7E0-C40A-4BA3-A57F-2364D1EF6013}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{1309E7E0-C40A-4BA3-A57F-2364D1EF6013}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{1309E7E0-C40A-4BA3-A57F-2364D1EF6013}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{1309E7E0-C40A-4BA3-A57F-2364D1EF6013}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{1309E7E0-C40A-4BA3-A57F-2364D1EF6013}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {A4D78644-B6B1-40F5-949B-6FA6951E784A}
24+
EndGlobalSection
25+
EndGlobal

AnalyticHierarchyProcess/AHP.cs

Lines changed: 215 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,215 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Collections.Specialized;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
8+
namespace AnalyticHierarchyProcess
9+
{
10+
// Class responsible for AHP structure
11+
[Serializable]
12+
internal class AHP
13+
{
14+
public Node Goal { get; }
15+
public List<Node> Criteria { get; } = new();
16+
public List<Node> Subcriteria { get; } = new();
17+
public List<Node> Alternatives { get; } = new();
18+
19+
public AHP(string goal)
20+
{
21+
Goal = new Node(goal);
22+
}
23+
24+
public void AddCriterion(string criterion)
25+
{
26+
Node newCriterion = new Node(criterion);
27+
Goal.AddChild(newCriterion);
28+
Criteria.Add(newCriterion);
29+
}
30+
31+
public void AddSubcriterion(string criterion, string subcriterion)
32+
{
33+
Node newSubcriterion = new Node(subcriterion);
34+
foreach (Node node in Criteria)
35+
{
36+
if (node.Name == criterion)
37+
{
38+
node.AddChild(newSubcriterion);
39+
}
40+
}
41+
Subcriteria.Add(newSubcriterion);
42+
}
43+
44+
public void AddAlternative(string alternative)
45+
{
46+
Node newAlternative = new Node(alternative);
47+
foreach (Node node in Subcriteria)
48+
{
49+
node.AddChild(newAlternative);
50+
}
51+
Alternatives.Add(newAlternative);
52+
}
53+
54+
public void FinalizeStructure()
55+
{
56+
foreach (Node criterion in Criteria)
57+
{
58+
if (criterion.Children.Count == 0)
59+
{
60+
foreach (Node alternative in Alternatives)
61+
{
62+
criterion.AddChild(alternative);
63+
}
64+
}
65+
}
66+
}
67+
68+
public void UpdateAllPriorities()
69+
{
70+
Goal.Priority = 1.0;
71+
foreach (Node criterion in Criteria)
72+
{
73+
criterion.Priority = 0.0;
74+
}
75+
foreach (Node subcriterion in Subcriteria)
76+
{
77+
subcriterion.Priority = 0.0;
78+
}
79+
foreach (Node alternative in Alternatives)
80+
{
81+
alternative.Priority = 0.0;
82+
}
83+
84+
Goal.PropagatePriority();
85+
foreach (Node criterion in Criteria)
86+
{
87+
criterion.PropagatePriority();
88+
}
89+
foreach (Node subcriterion in Subcriteria)
90+
{
91+
subcriterion.PropagatePriority();
92+
}
93+
}
94+
95+
public void ResetNodes()
96+
{
97+
ResetNode(Goal);
98+
foreach (Node criterion in Criteria)
99+
{
100+
ResetNode(criterion);
101+
}
102+
foreach (Node subcriterion in Subcriteria)
103+
{
104+
ResetNode(subcriterion);
105+
}
106+
foreach (Node alternative in Alternatives)
107+
{
108+
ResetNode(alternative);
109+
}
110+
}
111+
112+
private void ResetNode(Node node)
113+
{
114+
node.Priority = 0.0;
115+
for (int i = 0; i < node.Children.Count; i++)
116+
{
117+
for (int j = 0; j < node.Children.Count; j++)
118+
{
119+
if (i == j)
120+
{
121+
node.Matrix[i, j] = 1.0;
122+
} else
123+
{
124+
node.Matrix[i, j] = 0.0;
125+
}
126+
}
127+
}
128+
}
129+
130+
public List<Node> GetAllNodes()
131+
{
132+
List<Node> result = new();
133+
134+
result.Add(Goal);
135+
foreach (Node criterion in Criteria)
136+
{
137+
result.Add(criterion);
138+
}
139+
foreach (Node subcriterion in Subcriteria)
140+
{
141+
result.Add(subcriterion);
142+
}
143+
foreach (Node alternative in Alternatives)
144+
{
145+
result.Add(alternative);
146+
}
147+
148+
return result;
149+
}
150+
151+
public string GetGoalName()
152+
{
153+
return Goal.Name;
154+
}
155+
156+
public List<string> GetCriterionNames()
157+
{
158+
List<string> result = new();
159+
160+
foreach (Node criterion in Criteria)
161+
{
162+
result.Add(criterion.Name);
163+
}
164+
165+
return result;
166+
}
167+
168+
public List<string> GetAllSubcriterionNames()
169+
{
170+
List<string> result = new();
171+
172+
foreach (Node subcriterion in Subcriteria)
173+
{
174+
result.Add(subcriterion.Name);
175+
}
176+
177+
return result;
178+
}
179+
180+
public List<string> GetSubcriterionNames(string criterion)
181+
{
182+
List<string> result = new();
183+
184+
foreach (Node node in Criteria)
185+
{
186+
if (node.Name == criterion)
187+
{
188+
foreach (Node subcriterion in node.Children)
189+
{
190+
result.Add(subcriterion.Name);
191+
}
192+
}
193+
}
194+
195+
return result;
196+
}
197+
198+
public List<string> GetAlternativeNames()
199+
{
200+
List<string> result = new();
201+
202+
foreach (Node alternative in Alternatives)
203+
{
204+
result.Add(alternative.Name);
205+
}
206+
207+
return result;
208+
}
209+
210+
public bool HasSubcriteria(Node criterion)
211+
{
212+
return Subcriteria.Contains(criterion.Children[0]);
213+
}
214+
}
215+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<Page x:Class="AnalyticHierarchyProcess.AddAnotherCriterionPage"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
xmlns:local="clr-namespace:AnalyticHierarchyProcess"
7+
mc:Ignorable="d"
8+
d:DesignHeight="450" d:DesignWidth="800"
9+
Title="AddAnotherCriterionPage">
10+
11+
<Grid>
12+
<Grid Height="400" VerticalAlignment="Center">
13+
<Label Content="Enter the name of new criterion:" HorizontalAlignment="Center" Margin="0,80,0,0" VerticalAlignment="Top" FontSize="44" Foreground="#FF353B48"/>
14+
<TextBox x:Name="textBox" HorizontalAlignment="Center" VerticalAlignment="Top" Width="404" Height="62" Margin="0,180,0,0" Foreground="#FF353B48" FontSize="25" BorderBrush="#FF353B48" VerticalContentAlignment="Center" SelectionBrush="#FF353B48" Padding="10,10,10,10"/>
15+
</Grid>
16+
<Button Click="Back" Content="Back" HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="50,0,0,40" Height="60" Width="150" BorderBrush="#FF353B48" Foreground="#FF353B48" Background="White" BorderThickness="2,2,2,2" FontSize="25" FontFamily="Segoe UI Semibold"/>
17+
<Button Click="Confirm" Content="Confirm" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0,0,50,40" Height="60" Width="150" BorderBrush="#FF353B48" Foreground="White" Background="#FF353B48" BorderThickness="2,2,2,2" FontSize="25" FontFamily="Segoe UI Semibold"/>
18+
19+
</Grid>
20+
</Page>
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using System.Windows;
7+
using System.Windows.Controls;
8+
using System.Windows.Data;
9+
using System.Windows.Documents;
10+
using System.Windows.Input;
11+
using System.Windows.Media;
12+
using System.Windows.Media.Imaging;
13+
using System.Windows.Navigation;
14+
using System.Windows.Shapes;
15+
16+
namespace AnalyticHierarchyProcess
17+
{
18+
/// <summary>
19+
/// Interaction logic for AddAnotherCriterionPage.xaml
20+
/// </summary>
21+
public partial class AddAnotherCriterionPage : Page
22+
{
23+
public AddAnotherCriterionPage()
24+
{
25+
InitializeComponent();
26+
}
27+
28+
private void Back(object sender, RoutedEventArgs e)
29+
{
30+
NavigationService.GoBack();
31+
}
32+
33+
private void Confirm(object sender, RoutedEventArgs e)
34+
{
35+
if (textBox.Text.Length == 0)
36+
{
37+
return;
38+
}
39+
Globals.AHP.AddCriterion(textBox.Text);
40+
NavigationService.GoBack();
41+
}
42+
}
43+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<Page x:Class="AnalyticHierarchyProcess.AddAnotherOptionPage"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
xmlns:local="clr-namespace:AnalyticHierarchyProcess"
7+
mc:Ignorable="d"
8+
d:DesignHeight="450" d:DesignWidth="800"
9+
Title="AddAnotherOptionPage">
10+
11+
<Grid>
12+
<Grid Height="400" VerticalAlignment="Center">
13+
<Label Content="Enter the name of new option:" HorizontalAlignment="Center" Margin="0,80,0,0" VerticalAlignment="Top" FontSize="44" Foreground="#FF353B48"/>
14+
<TextBox x:Name="textBox" HorizontalAlignment="Center" VerticalAlignment="Top" Width="404" Height="62" Margin="0,180,0,0" Foreground="#FF353B48" FontSize="25" BorderBrush="#FF353B48" VerticalContentAlignment="Center" SelectionBrush="#FF353B48" Padding="10,10,10,10"/>
15+
</Grid>
16+
<Button Click="Back" Content="Back" HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="50,0,0,40" Height="60" Width="150" BorderBrush="#FF353B48" Foreground="#FF353B48" Background="White" BorderThickness="2,2,2,2" FontSize="25" FontFamily="Segoe UI Semibold"/>
17+
<Button Click="Confirm" Content="Confirm" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0,0,50,40" Height="60" Width="150" BorderBrush="#FF353B48" Foreground="White" Background="#FF353B48" BorderThickness="2,2,2,2" FontSize="25" FontFamily="Segoe UI Semibold"/>
18+
19+
</Grid>
20+
</Page>
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using System.Windows;
7+
using System.Windows.Controls;
8+
using System.Windows.Data;
9+
using System.Windows.Documents;
10+
using System.Windows.Input;
11+
using System.Windows.Media;
12+
using System.Windows.Media.Imaging;
13+
using System.Windows.Navigation;
14+
using System.Windows.Shapes;
15+
16+
namespace AnalyticHierarchyProcess
17+
{
18+
/// <summary>
19+
/// Interaction logic for AddAnotherOptionPage.xaml
20+
/// </summary>
21+
public partial class AddAnotherOptionPage : Page
22+
{
23+
public AddAnotherOptionPage()
24+
{
25+
InitializeComponent();
26+
}
27+
28+
private void Confirm(object sender, RoutedEventArgs e)
29+
{
30+
if (textBox.Text.Length == 0)
31+
{
32+
return;
33+
}
34+
Globals.AHP.AddAlternative(textBox.Text);
35+
NavigationService.GoBack();
36+
}
37+
38+
private void Back(object sender, RoutedEventArgs e)
39+
{
40+
NavigationService.GoBack();
41+
}
42+
}
43+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<Page x:Class="AnalyticHierarchyProcess.AddSubcriterionPage"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
xmlns:local="clr-namespace:AnalyticHierarchyProcess"
7+
mc:Ignorable="d"
8+
d:DesignHeight="450" d:DesignWidth="800"
9+
Title="AddSubcriterionPage">
10+
11+
<Grid>
12+
<Grid Height="400" VerticalAlignment="Center">
13+
<Label Content="Enter the name of subcriterion:" HorizontalAlignment="Center" Margin="0,80,0,0" VerticalAlignment="Top" FontSize="44" Foreground="#FF353B48"/>
14+
<TextBox x:Name="textBox" HorizontalAlignment="Center" VerticalAlignment="Top" Width="404" Height="62" Margin="0,180,0,0" Foreground="#FF353B48" FontSize="25" BorderBrush="#FF353B48" VerticalContentAlignment="Center" SelectionBrush="#FF353B48" Padding="10,10,10,10"/>
15+
</Grid>
16+
<Button Click="Back" Content="Back" HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="50,0,0,40" Height="60" Width="150" BorderBrush="#FF353B48" Foreground="#FF353B48" Background="White" BorderThickness="2,2,2,2" FontSize="25" FontFamily="Segoe UI Semibold"/>
17+
<Button Click="Confirm" Content="Confirm" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0,0,50,40" Height="60" Width="150" BorderBrush="#FF353B48" Foreground="White" Background="#FF353B48" BorderThickness="2,2,2,2" FontSize="25" FontFamily="Segoe UI Semibold"/>
18+
19+
</Grid>
20+
</Page>

0 commit comments

Comments
 (0)