Create, parse and solve MiniZinc constraint models using C# and .NET
** This is work in progress **
Models can be created at any time but can only be solved using an instance of MiniZincClient
.
var minizinc = MiniZincClient.Create();
var result = await minizinc.Solve("var 10..20: a; solve minimize a;");
result.GetInt("a"); // 20
result.Objective; // 20
result.Status; // SolveStatus.Optimal
var model = new IntModel(); var a = model.AddInt("a", 10, 20); var b = model.AddInt("b", 10, 20); model.AddConstraint(a < b); model.Minimize(a + b); var result = await minizinc.Solve(model); result.GetInt(a); // 10 result.GetInt(b); // 11 result.Objective; // 21 result.Status; // SolveStatus.Optimal
var model = new IntModel(); var a = model.AddInt("a", 10, 20); var b = model.AddInt("b", 10, 20); model.AddConstraint(a < b); model.Minimize(a + b); var result = await minizinc.Solve(model); result.GetInt(a); // 10 result.GetInt(b); // 11 result.Objective; // 21 result.Status; // SolveStatus.Optimal
To develop and test the codebase you need will need to have access to an environment where both the .NET8 SDK and MiniZinc toolchain installed. You can install these dependencies manually or use a preconfigured docker container.
- Install the .NET 8 SDK
- Install MiniZinc toolchain
git clone https://github.com/jmjrawlings/MiniZinc.Net.git
cd MiniZinc.Net
dotnet tool restore
dotnet test
- Install Docker
- Install VSCode
git clone https://github.com/jmjrawlings/MiniZinc.Net.git
code MiniZinc.Net
- "Reopen in container" when prompted
dotnet test
from within the container
TODO
TODO