TreesearchLib is a framework for modeling optimization problems that are to be solved by constructive heuristics. It includes a number of algorithms: exhaustive depth-first and breadth-first search, limited discrepancy search, the PILOT method, beam search, monotonic beam search, rake search, and Monte Carlo tree search.
$ dotnet add package TreesearchLibTreesearchLib is a C# framework for modeling optimization problems as search trees and a collection of algorithms to identify good solutions for those problems. It includes exhaustive algorithms, as well as heuristics.
Modeling optimization problems is performed by implementing a problem state class. This class maintains the decisions that have been taken, as well as the next choices, i.e., branches in the search tree. It is possible to compute bounds, which algorithms may use to discard parts of the tree.
Check out the SampleApp to see implementations of the following problems:
These samples should give you an idea on how to use the framework for problem modeling.
You should use the state's extension method Test to check whether your implementation is correct. Not all errors can be detected, but several subtle problems can be discovered, e.g. undo operations that result in a state which outputs a different set of choices than before. The Program.cs in the SampleApp calls this method for all problems. For instance
var hanoi = new TowerOfHanoi(3, 3);
var testResult = hanoi.Test<TowerOfHanoi, (int, int), Minimize>(EqualityComparer<(int, int)>.Default);
Console.WriteLine($"Is TowerOfHanoi implemented correctly: {testResult}");
If the result is TestResult.Ok the implementation is likely correct. Otherwise, the enum provides hints on potential problems.
The algorithms that are included are:
New hybrid algorithms can be implemented, also by making use of the existing algorithms.