# Constraint Programming

# What is it for?

Puzzle solving

- n-queens
- sudoku

Compiler problems

Routing Problems Allocation problems

Plannning Reachability Verification

# Minizinc

Exploring a shipping puzzle, part 3

```
var int : x;
solve satisfy;
```

How to make DSLs. Look for macros. Look for function call. Look for gensyms

```
mov("a","b");
```

var vs par is compile vs runtime distinction in type system it would be cool if minizinc could support adts or records.

### Embedding datalog into minizinc

```
set of int : verts = 1..3;
array[verts,verts] of bool : edge;
%array[int,int] of verts : edge0;
array[verts,verts] of var bool : path;
%edge0 = [|1,2 | 2,3];
% check if in edges list
function bool: edge0(int : i, int : j) =
i = 1 /\ j = 2 \/
i = 2 /\ j = 3;
edge = array2d(verts,verts, [ edge0(i,j) | i,j in verts]);
constraint forall(i,k in verts)(
path[i,k] <- % <-> ?
edge[i,k] \/ exists(j in verts)(edge[i,j] /\ path[j,k])
);
%output ["\(edge)"];
solve satisfy;
```

Note that `-a`

or `--all-solutions`

will show all solutions.

Non negated datalog should have a unique solution. Datalog with negation is a different ballgame.

# Picat

index mode annotations table annotions include lattice type stuff “mode-directed tabling”

action rules loops

# Answer Set Programming

See notes on answer set programming

# Topics

## Branch and Bound

## Local Search

## Lattices

## Propagators

## Heuristics

# Misc

- google or-tools
- eclipse https://www.eclipseclp.org/

Hakan’s site an insane number fo examples in systems

Coursera Course

ORTools is apprently killer according to Minizinc Challenge

GeCode

constraint programming for robotics Also see interval constraint programming interval mooc http://www.codac.io/tutorial/index.html

csplib a library of constrains

art of propagators geocode manual on propagators (appendix P) Propagators have been described as “just” monotonic functions between lattices. https://www.youtube.com/watch?v=s2dknG7KryQ&ab_channel=ConfEngine

constraint acquisition inferring predoncitions for code?

Using and Understanding ortools’ CP-SAT: A Primer and Cheat Sheet