Modeling with ILOG OPL studio - PowerPoint PPT Presentation

1 / 10
About This Presentation
Title:

Modeling with ILOG OPL studio

Description:

Modeling. with ILOG OPL studio. GBAIS November 20. ILOG IDE ... var int queens[1..8] in 1..8; solve { forall(ordered i,j in 1..8) { queens[i] queens[j] ... – PowerPoint PPT presentation

Number of Views:141
Avg rating:3.0/5.0
Slides: 11
Provided by: Cami62
Category:
Tags: ilog | opl | modeling | queens | studio

less

Transcript and Presenter's Notes

Title: Modeling with ILOG OPL studio


1
Modeling with ILOG OPL studio
  • GBAIS November 20

2
ILOG IDE (SNAPSHOT 1)
3
ILOG IDE (SNAPSHOT 1)
4
Solving Nqueens
  • var int queens1..8 in 1..8
  • solve
  • forall(ordered i,j in 1..8)
  • queensi ltgt queensj
  • queensi i ltgt queensj j
  • queensi - i ltgt queensj - j

5
Search tree for Nqueens
6
Output to search tree
  • In Debug Menu, deselect Stepping in Model, then
    select the Display Search Tree option in addition
    to Stop at Choice Point.
  • Execute the project by clicking on Run.
  • Select the View -gt Choice Stack menu item.
  • Click on Next 3 times. Note that, with the option
    Stop at Choice Point,
  • OPL Studio does not stop at the fail nodes. The
    n-ary tree corresponding to your search is
    displayed

7
Search tree for 2 solutions
8
SUDOKU (1)
  • //STANDARD SUDOKU 9x9 EXAMPLE 1 using 2
    dimensional variable with alldifferent and forall
  • range dim1 1..9
  • range dim2 1..9
  • range bindex 0..2
  • int inputdim1,dim2...
  • int setnumf in bindexx x in dim1 x lt
    (43f) x gt 3f
  • var int posdim1,dim2 in 1..9

9
SUDOKU (2)
  • solve
  • forall(i in 1..9)
  • forall(j in dim2 inputi,j ltgt0)
  • posi,jinputi,j
  • forall(j in dim2)
  • alldifferent(all(i in dim1)posi,j)
  • forall(i in dim1)
  • alldifferent(all(j in dim2)posi,j)
  • forall(b1 in bindex)
  • forall(b2 in bindex)
  • alldifferent(all(i in setnumb1, j in
    setnumb2) posi,j)

10
Dat file
input 0 6 0 0 5 0 0 2 0 0 0 0 3 0 0 0 9 0
7 0 0 6 0 0 0 1 0 0 0 6 0 3 0 4 0 0 0 0 4
0 7 0 1 0 0 0 0 5 0 9 0 8 0 0 0 4 0 0 0 1 0
0 6 0 3 0 0 0 8 0 0 0 0 2 0 0 4 0 0 5 0
Write a Comment
User Comments (0)
About PowerShow.com