Obtaining combinations of k elements from n in C#

I needed an algorithm that could return all combinations of k number of elements within a finite set of n elements. Furthermore I wanted the algorithm to work in a non-recursive (iterative) way in C#. Step forward StackOverflow, specifically this answer given by Juan Antonio Cano I’ve taken his code and just made one or …

Continue reading ‘Obtaining combinations of k elements from n in C#’ »

Applying the 2-opt algorithm to travelling salesman problems in C# / WPF

For the Java equivalent see this link: https://www.technical-recipes.com/2017/applying-the-2-opt-algorithm-to-traveling-salesman-problems-in-java/ For the C++ equivalent see this link: https://www.technical-recipes.com/2012/applying-c-implementations-of-2-opt-to-travelling-salesman-problems/ This post demonstrates how to apply the 2-opt algorithm to a number of standard test problems in C# while displaying the results in a WPF style window, while using the MVVM design pattern. See this link for an overview …

Continue reading ‘Applying the 2-opt algorithm to travelling salesman problems in C# / WPF’ »

Using the Supervisor Controller Pattern to access View controls in MVVM

As discussed on a StackOverflow post, this is considered bad practice, so only use this when necessary. Step 1: Create a new WPF project Step 2: Add event handling code A number of classes are needed for doing command bindings in MVVM. Create the following classes and add to your Visual Studio project: RelayCommand.cs EventRaiser.cs …

Continue reading ‘Using the Supervisor Controller Pattern to access View controls in MVVM’ »