Outline of MiniZinc and Eclipse - PowerPoint PPT Presentation

1 / 17
About This Presentation
Title:

Outline of MiniZinc and Eclipse

Description:

Outline of MiniZinc and Eclipse. MiniZinc. MiniZinc is a strongly typed language ... MiniZinc built-in operators. Boolean. not, - , - , xor, / Arithmetic ... – PowerPoint PPT presentation

Number of Views:393
Avg rating:3.0/5.0
Slides: 18
Provided by: NIC53
Category:

less

Transcript and Presenter's Notes

Title: Outline of MiniZinc and Eclipse


1
Outline of MiniZinc and Eclipse
2
MiniZinc
  • MiniZinc is a strongly typed language
  • All declarations must involve a type
  • int n
  • bool b
  • set of 1..N s
  • array1..N, 1..M of -5..5 a

3
MiniZinc
  • MiniZinc has two kinds (insts) of variables
  • decision variables
  • variables to be solved for
  • parameters
  • variables with fixed values (e.g. from data file)
  • Type-inst is type inst
  • Decision variables are identified by var
  • var int n
  • var set of 1..N s
  • array1..N, 1..M of var -5..5 a

4
MiniZinc built-in operators
  • Boolean
  • not, lt-gt, -gt, lt-, \/, xor, /\
  • Arithmetic
  • lt, gt, lt, gt, , , !
  • , -, , /, div, mod
  • Sets
  • in, subset, superset, union, intersect, symdiff
  • Other
  • ..,

5
MiniZinc expressions
  • Set/array comprehensions
  • 2i i in 1..5
  • 2i i in 1..5
  • i-j i in 1..5, j in 1..5 where i ! j
  • Set/array literals
  • 1, 2, 3
  • 4, 5, 6
  • 1, 2, 3 4, 5, 6
  • forall, exists
  • forall(i in 1..3)(i subset s)

6
MiniZinc Items
  • include
  • constraint
  • solve
  • output
  • predicate
  • variable declaration
  • equality
  • annotation

7
MiniZinc Items
  • include
  • include "globals.mzn
  • include module2.mzn
  • output
  • output X , show(x), Y , show(y)
  • constraint
  • constraint x y z
  • constraint forall(i in 1..N)( ai gt 0 )
  • solve
  • solve satisfy
  • solve maximize x 2y

8
MiniZinc Items
  • Solve annotations
  • int_search(Vars, Select, Choice, Method)
  • Select input_order, first_fail, smallest,
  • Choice indomain_min, indomain_middle,
  • Method complete, bbs(Steps), lds(Disc),
  • bool_search
  • float_search
  • set_search
  • solve int_search(x,y,z, input_order,indo
    main_min, complete)
  • maximize x 2y

9
MiniZinc Items
  • predicate
  • predicate
  • between(var int x var int y, var int z)
  • x lt y /\ y lt z
  • variable declaration
  • var int n
  • int M
  • int K 5
  • equality
  • M 6

10
MiniZinc Command Line
  • minizinc ltmodelgt --data ltdatafilegt
  • minizinc --help
  • minizinc --version

11
MiniZinc Command Line
  • --statistics
  • time and space used
  • --model-check-only
  • check model alone is ok (no exec)
  • --instance-check-only
  • check instance is ok (no exec)

12
MiniZinc Command Line
  • --all-solutions
  • find and output all solutions
  • --num-solutions 25
  • find and output at most 25 solutions
  • --output-to-file answers.txt
  • output to file instead of screen

13
Eclipse
  • Predicate definitions
  • between(X, Y, Z) - X lt Y, Y lt Z.
  • fib(0, 1).
  • fib(1, 1).
  • fib(N, F) - N gt 2, N1 N-1, N2 N-2,
  • fib(N1, F1), fib(N2, F2), F F1 F2.

14
Eclipse
  • Compiler commands
  • - lib(ic).
  • Queries
  • - between(5, N, 15), fib(N, F).

15
Eclipse
  • Constraints
  • X 1..5, W, Y, Z 7..9.
  • lt, gt, lt, gt, , \
  • labeling(X, Y, Z)
  • search(Vars, 0, Select, Choice, Method, )
  • Select input_order, first_fail,
  • Choice indomain_min, indomain_middle,
  • Method complete, bbs(Steps), lds(Disc),

16
Eclipse
  • Eclipse executes left-to-right
  • Eclipse executes user-defined predicates by
    expanding a predicate call ( replacing the call
    by the body of a defining clause)
  • Eclipse tries parts of predicate definitions in
    textual order
  • Careful of recursion - base cases should appear
    before recursive cases

17
Eclipse idioms
  • , p(X, Y), q(Y, Z),
  • p(X, Y) - X gt 0, q1(X, Y),
  • p(X, Y) - X lt 0, q2(X, Y),
  • p(, Y) - q1(Y).
  • p(HT, Y) - q2(H, Y), p(T, Y).
Write a Comment
User Comments (0)
About PowerShow.com