Our Departement of informatics
Main Model Page
Go to Virtual Optima
Contact
Solving Mathematical Models through the Internet using LPL
Problem Description
Model Description
MODEL chess4 ; SET h,i,j := /1:8/; BINARY VARIABLE x{i,j} ; CONSTRAINT ATT{i,j}: OR{h|h<>i and h-i+j>=1 and h-i+j<=#h} x[h,h-i+j] OR OR{h|h<>i and i+j-h>=1 and i+j-h<=#h} x[h,i+j-h] OR OR{h|h<>i} x[h,j] OR OR{h|h<>j} x[i,h]; MINIMIZE obj: SUM{i,j} x ; WRITE 'The minimal number of Queens is: %3d\n The chessboard is\n %2s \n %s %2s \n': obj, COL{j} j, ROW{i} (i,COL{j} IF(x,'*','-')); Draw.Ratio(50,50); Draw.Rect(.95,.95,#i+1.05,#j+1.05,0); FOR{i,j} DO Draw.Rect(i,j,i+1,j+1,if((i+j)%2,0,1)); END FOR{i,j|x} DO Draw.Ellipse(j+.2,i+.2,j+.8,i+.8,6); END END
Problem Description
Model Description
Back to model
The solution is as follows:
The LOG-File output of LPL is as follows: