file:///C/Documents%20and%20Settings/mol23/Desktop/ORIE%203300_5300/assignments/ass2/ass2sols/ass21.txt
param N:=4;
var x{ i in 1..N, j in 1..N, t in 1..N} binary;
#x[i,j,t]=1 if entry in row i column j is assigned to be value
var v {i in 1..N, j in 1..N} integer;
maximize total_number_assigned: sum {i in 1..N, j in 1..N, t in 1..N}
x[i,j,t];
subject to cell111: x[1,1,1]=1;
subject to cell232: x[2,3,2]=1;
subject to cell314: x[3,1,4]=1;
subject to cell443: x[4,4,3]=1;
subject to Values {i in 1..N, j in 1..N}: v[i,j] = sum {t in 1..N}
t*x[i,j,t];
subject to AssignCell {i in 1..N, j in 1..N}:
sum {t in 1..N} x[i,j,t]<=1;
#each cell can be assigned at most one value
subject to AssignRow {i in 1..N, t in 1..N}:
sum {j in 1..N} x[i,j,t]<=1;
#each row's cells can have at most one of each value
subject to AssignColumn {j in 1..N, t in 1..N}:
sum {i in 1..N} x[i,j,t]<=1;
#each column's cells can have at most one of each value
subject to AssignBox {a in {1,3}, b in {1,3}, t in 1..N}:
sum {i in {a,a+1}, j in {b,b+1}} x[i,j,t]<=1;
#each box's cells can have at most one of each value
_______________________________________________________________________
ampl: model sudoku.mod;
ampl: option solver cplex;
file:///C/Documents%20and%20Settings/mol23/Desktop/ORIE%203300_5300/assignments/ass2/ass2sols/ass21.txt (1 of 2) [9/20/2011 11:01:08 PM]
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
file:///C/Documents%20and%20Settings/mol23/Desktop/ORIE%203300_5300/assignments/ass2/ass2sols/ass21.txt
This is the end of the preview.
Sign up
to
access the rest of the document.
 Fall '08
 TODD
 Linear Programming, Optimization, Line segment, basic solution, extreme point

Click to edit the document details