1 / 16

G53CLP Constraint Logic Programming

G53CLP Constraint Logic Programming. Solving 8-Queen Puzzle – Demo. Dr Rong Qu. CPLEX Optimization software package Sold via CPLEX Optimization Inc. Acquired by ILOG Inc in 1997 Acquired by IBM in 2009 Also solves integer programming and large linear programming problems. ILOG OPL Studio.

royce
Download Presentation

G53CLP Constraint Logic Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. G53CLPConstraint Logic Programming Solving 8-Queen Puzzle – Demo Dr Rong Qu

  2. CPLEX Optimization software package Sold via CPLEX Optimization Inc. Acquired by ILOG Inc in 1997 Acquired by IBM in 2009 Also solves integer programming and large linear programming problems ILOG OPL Studio http://www.ilog.com/products/cplex/ G53CLP – Constraint Logic Programming Dr R. Qu

  3. OPL Studio One of the modeling systems in ILOG For both mathematic programming and constraint programming OPL (Optimization Programming Language) was originally developed by Pascal van Hentenryck Provide an interpreter OPL models; A script language An IDE; An API ILOG OPL Studio G53CLP – Constraint Logic Programming Dr R. Qu

  4. Gecode 1.0.1 Java interface for constraint programming Free for download Released in Nov 2006 Possible coursework next year? http://www.gecode.org/gecodej/ Other CP Solvers? G53CLP – Constraint Logic Programming Dr R. Qu

  5. Solving the 8-Queen Problem G53CLP – Constraint Logic Programming Dr R. Qu

  6. G52AIP – AI Programming

  7. Solving The 8-Queen Problem – model 2 • Variables • x1, x2, …, xn: position of queens on the chessboard • Domain • {0 … n2-1}: tile index of each queen placed • Constraint R = xi / n + 1 C = xi mod n + 1 Given R1, R2 and C1, C2 of two queens’ positions • One queen each row/column • R1 ≠ R2; C1 ≠ C2 • One queen each diagnal • R1 – R2 ≠ C1 – C2 • R1 – R2 ≠ C2 – C1 G53CLP – Constraint Logic Programming Dr R. Qu

  8. ILOG OPL Studio G53CLP – Constraint Logic Programming Dr R. Qu

  9. Solving The 8-Queen Problem – model 2 //.mod file //declaration part var int queens[1..8] in 0..63; var int r[1..8] in 1..8; var int c[1..8] in 1..8; // problem model solve { … }; • x1, x2, …, xn: position of queens on the chessboard • {0 … n2-1}: tile index of each queen placed • R = xi / n + 1 • C = xi mod n + 1 • R1 ≠ R2; C1 ≠ C2 • R1 – R2 ≠ C1 – C2 • R1 – R2 ≠ C2 – C1 G53CLP – Constraint Logic Programming Dr R. Qu

  10. Solving The 8-Queen Problem – model 2 //.mod file //declaration part … //problem model solve { forall(ordered i,j in 1..8) { r[i] = queens[i] / 8 + 1; c[i] = queens[i] mod 8 + 1; r[j] = queens[j] / 8 + 1; c[j] = queens[j] mod 8 + 1; … }; }; • R = xi / n + 1 • C = xi mod n + 1 • R1 ≠ R2; C1 ≠ C2 • R1 – R2 ≠ C1 – C2 • R1 – R2 ≠ C2 – C1 G53CLP – Constraint Logic Programming Dr R. Qu

  11. Solving The 8-Queen Problem – model 2 //.mod file //declaration part … //problem model solve { forall(ordered i,j in 1..8) { … r[i] <> r[j] ; c[i] <> c[j] ; r[i] - r[j] <> c[i] - c[j]; r[i] - r[j] <> c[j] - c[i]; }; }; • R = xi / n + 1 • C = xi mod n + 1 • R1 ≠ R2; C1 ≠ C2 • R1 – R2 ≠ C1 – C2 • R1 – R2 ≠ C2 – C1 G53CLP – Constraint Logic Programming Dr R. Qu

  12. G52AIP – AI Programming

  13. G52AIP – AI Programming

  14. Solving The 8-Queen Problem – model 2 G53CLP – Constraint Logic Programming Dr R. Qu

  15. Solving The 8-Queen Problem – models 1&3 • Lab sessions start next week • I: comparing the 3 models for solving the n-Queen problem • II: G53CLP – Constraint Logic Programming Dr R. Qu

  16. Solving The 8-Queen Problem • To display decision tree • Debug/Display Decision Tree • To run • Execution/Run, or • To stop at a decision point • Debug/Stop at Decision Point • Next solution • All solutions G53CLP – Constraint Logic Programming Dr R. Qu

More Related