Mathematical Modeling with LPL : Explain and run a Model
Problem Statement
Modeling Description
||
Back to MatMod
model mstar "The 6-Magic Star"; parameter N:=6; set j:=1..N; k:=1..4; i:=1..2*N; parameter a{j,k}:=(2*j-1+if(k<3,k-2,k-1))%#i+1; alldiff variable x{i} [1..#i+if(N=5,2)]; integer variable S; constraint A{j}: sum{k} x[a] = S; solve; parameter PI:=3.14159; r:=10; g:=PI/N; f:=2*g; s:=(Sin(f)*Cos(f)) / (Sin(f)*Cos(g)); parameter X{i}:=if(i%2=0,s*r,r)*Cos((i-1)*g-PI/2); parameter Y{i}:=if(i%2=0,s*r,r)*Sin((i-1)*g-PI/2); string SS{i}:=['A' 'B' 'C' 'D' 'E' 'F' 'G' 'H' 'I' 'J' 'K' 'L']; Draw.Scale(20,20); {j} Draw.Line(X[a[j,1]],Y[a[j,1]],X[a[j,4]],Y[a[j,4]]); {i} Draw.Circle(x&'',X,Y,1,1,0); --{i} Draw.Circle(SS,X,Y,1,1,0); Draw.Text('sum='&S,-r,-r); end
Problem Statement
Modeling Description
Back to model
The solution is as follows:
The LOG-File output of LPL is as follows: