Skip to content

erik2222/csp.net

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CSP.NET Build status

A .NET constraint satisfaction problem solver.

Use

Here's an example of setting up and solving a very basic problem:

const int n = 8;
IReadOnlyCollection<int> values = Enumerable.Range(1, n).ToList();
IReadOnlyCollection<Variable<string, int>> variables = Enumerable.Range(1, n).Select(i => new Variable<string, int>(i.ToString(), values)).ToList();
IConstraint<string, int>[] constraints = new[] { new AllDifferentConstraint<string, int>(variables) };
Problem<string, int> problem = new Problem<string, int>(variables, constraints);

ISolver<string, int> solver = new RecursiveBacktrackSolver<string, int>();
Assignment<string, int> solution = solver.Solve(problem, CancellationToken.None);
IReadOnlyDictionary<Variable<string, int>, int> solutionDictionary = solution.AsReadOnlyDictionary();

About

A .NET constraint satisfaction problem solver.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages