Mathematical Modeling with LPL : Explain and run a Model
Problem Statement
Modeling Description
||
Back to MatMod
model DrawClock "Draw a Clock"; set i:=1..12; binary variable x{i}; constraint A: sum{i} i*x = (sum{i} i)/2; constraint B: exactly(2){i} (x[i]<>x[i%#i +1]); solve; Write('The numbers%3d are on one side\n',{i|x} i); model output; parameter r:=20; PI:=3.14159; r1:=r-5; x{i}:=r*Sin(2*PI*(6-i)/#i); y{i}:=r*Cos(2*PI*(6-i)/#i); x1{i}:=r1*Sin(2*PI*(6-i)/#i); y1{i}:=r1*Cos(2*PI*(6-i)/#i); Draw.Scale(7,7); --Draw.Scale(7,-7); //try this instead ;-) Draw.DefFont('monospace',25,0,2); Draw.Circle(0,0,r,1,0,3); Draw.Circle(0,0,.5,1,0,3); {i} Draw.Line(i&'',x[i],y[i],x1[i],y1[i],-2,1,-2,1); Draw.Line(-22,-6,22,6,3,3); --Draw.DefLine('line.dash',8,3); --Draw.Line('#dash',-15,-15,6,20,3,3); --Draw.Text('?',-4,2.5,30,3,3); end; end
Problem Statement
Modeling Description
Back to model
The solution is as follows:
The LOG-File output of LPL is as follows: