Skip to content

Commit a80c8f9

Browse files
committed
Sample data button for task allocation
1 parent 1e5b76a commit a80c8f9

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

OptimizationIssues/Views/TaskAllocationView.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
</StackPanel>
9292

9393
<StackPanel Grid.Column="1" Margin="10">
94+
<Button Content="Generuj przykładowe dane" VerticalAlignment="Top" Width="200" Click="GenerateSampleDataButton_Click"/>
9495
<TextBlock Text="Wyniki:" FontWeight="Bold" FontSize="16" VerticalAlignment="Top"/>
9596
<TextBlock x:Name="ResultTextBlock" Text="Tutaj pojawią się wyniki..." VerticalAlignment="Top" FontSize="14"/>
9697
</StackPanel>

OptimizationIssues/Views/TaskAllocationView.xaml.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,5 +156,32 @@ private void InputsChanged(object sender, TextChangedEventArgs e)
156156
{
157157
SolveButton.IsEnabled = ValidateInputs(out _, out _, out _);
158158
}
159+
private void GenerateSampleDataButton_Click(object sender, RoutedEventArgs e)
160+
{
161+
Random random = new Random();
162+
163+
int numberOfResources = random.Next(2, 6);
164+
int numberOfTasks = random.Next(2, 6);
165+
166+
var costMatrix = new List<List<int>>();
167+
168+
for (int i = 0; i < numberOfResources; i++)
169+
{
170+
var row = new List<int>();
171+
172+
for (int j = 0; j < numberOfTasks; j++)
173+
row.Add(random.Next(10, 100));
174+
175+
costMatrix.Add(row);
176+
}
177+
178+
NumberOfResourcesTextBox.Text = numberOfResources.ToString();
179+
NumberOfTasksTextBox.Text = numberOfTasks.ToString();
180+
181+
var costMatrixText = string.Join(Environment.NewLine, costMatrix.Select(row => string.Join(",", row)));
182+
CostMatrixTextBox.Text = costMatrixText;
183+
184+
SolveButton.IsEnabled = true;
185+
}
159186
}
160187
}

0 commit comments

Comments
 (0)