Skip to content

jmjrawlings/MiniZinc.Net

Repository files navigation

MiniZinc.Net

Create, parse and solve MiniZinc constraint models using C# and .NET

** This is work in progress **

Examples

Models can be created at any time but can only be solved using an instance of MiniZincClient.

var minizinc = MiniZincClient.Create();

Solve a model from a minizinc string

var result = await minizinc.Solve("var 10..20: a; solve minimize a;");
result.GetInt("a"); // 20
result.Objective; // 20
result.Status; // SolveStatus.Optimal

Create and solve a minizinc model

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

Create and solve a minizinc model

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

Developer Guide

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.

Option 1 - Manual Setup

  • 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

Option 2 - Devcontainer

  • 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

Design

TODO

Examples

TODO

References