Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
47
Task/Sudoku/SAS/sudoku.sas
Normal file
47
Task/Sudoku/SAS/sudoku.sas
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
/* define SAS data set */
|
||||
data Indata;
|
||||
input C1-C9;
|
||||
datalines;
|
||||
. . 5 . . 7 . . 1
|
||||
. 7 . . 9 . . 3 .
|
||||
. . . 6 . . . . .
|
||||
. . 3 . . 1 . . 5
|
||||
. 9 . . 8 . . 2 .
|
||||
1 . . 2 . . 4 . .
|
||||
. . 2 . . 6 . . 9
|
||||
. . . . 4 . . 8 .
|
||||
8 . . 1 . . 5 . .
|
||||
;
|
||||
|
||||
/* call OPTMODEL procedure in SAS/OR */
|
||||
proc optmodel;
|
||||
/* declare variables */
|
||||
set ROWS = 1..9;
|
||||
set COLS = ROWS;
|
||||
var X {ROWS, COLS} >= 1 <= 9 integer;
|
||||
|
||||
/* declare nine row constraints */
|
||||
con RowCon {i in ROWS}:
|
||||
alldiff({j in COLS} X[i,j]);
|
||||
|
||||
/* declare nine column constraints */
|
||||
con ColCon {j in COLS}:
|
||||
alldiff({i in ROWS} X[i,j]);
|
||||
|
||||
/* declare nine 3x3 block constraints */
|
||||
con BlockCon {s in 0..2, t in 0..2}:
|
||||
alldiff({i in 3*s+1..3*s+3, j in 3*t+1..3*t+3} X[i,j]);
|
||||
|
||||
/* fix variables to cell values */
|
||||
/* X[i,j] = c[i,j] if c[i,j] is not missing */
|
||||
num c {ROWS, COLS};
|
||||
read data indata into [_N_] {j in COLS} <c[_N_,j]=col('C'||j)>;
|
||||
for {i in ROWS, j in COLS: c[i,j] ne .}
|
||||
fix X[i,j] = c[i,j];
|
||||
|
||||
/* call CLP solver */
|
||||
solve;
|
||||
|
||||
/* print solution */
|
||||
print X;
|
||||
quit;
|
||||
Loading…
Add table
Add a link
Reference in a new issue