HW2_Solutions

# HW2_Solutions - ORIE 3300/5300 SOLUTIONS ASSIGNMENT 2 Fall...

This preview shows pages 1–3. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ORIE 3300/5300 SOLUTIONS: ASSIGNMENT 2 Fall 2008 1. The following is the solution to the puzzle: Model file for the Sudoku-style puzzle:------------------------------------------------------------------------------------------------------------------ param N:= 4; var x {i in 1..N, j in 1..N, k in 1..N} binary; #if the cell in row i, column j is assigned value k, x[i,j,k]=1; otherwise x[i,j,k]=0 var v {i in 1..N, j in 1..N} integer >= 0; #v[i,j] is the value assigned to the cell in row i column j maximize objective: sum {i in 1..N, j in 1..N, k in 1..N} x[i,j,k]; subject to cell222: x[2,2,2] = 1; subject to cell134: x[1,3,4] = 1; subject to cell423: x[4,2,3] = 1; subject to cell341: x[3,4,1] = 1; subject to values {i in 1..N, j in 1..N}: v[i,j] = sum {k in 1..N} k*x[i,j,k]; #make the connection between indicators and the cell values subject to AssignCell {i in 1..N, j in 1..N}: sum{k in 1..N} x[i,j,k] = 1; #each cell must be assigned exactly one value subject to AssignRow{i in 1..N, k in 1..N}: sum{j in 1..N} x[i,j,k] = 1; #each row's cell must have exactly one of each value subject to AssignColumn {j in 1..N, k in 1..N}: sum{i in 1..N} x[i,j,k] = 1; #each column's cell must have exactly one of each value subject to Quadruple{i in {1,3}, j in {1,3}, k in 1..N}: x[i,j,k]+ x[i+1,j,k] + x[i,j+1,k] + x[i+1,j+1,k] = 1; #each quadrant's cell must have exactly one of each value ------------------------------------------------------------------------------------------------------------------ ampl: display v; v:= 1 2 3 4 1 3 1 4 2 2 4 2 1 3 3 2 4 3 1 4 1 3 2 4 1 4 2 4 2 1 4 1 2 3 1 3 3 3 1 4 2 Figure 1: Sudoku-Style Puzzle....
View Full Document

{[ snackBarMessage ]}

### Page1 / 6

HW2_Solutions - ORIE 3300/5300 SOLUTIONS ASSIGNMENT 2 Fall...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online