Problem
A 6pointed magic star is a star polygon in which numbers are placed at each of the 6 vertices and 6 intersections, such that the four numbers on each line sum to the same magic constant (see Figure 1).
The 6magic star contains the consecutive integers 1 to 12 without repetition. The magic constant of a 6pointed normal magic star is S = 26. Write a mathematical model that solves the problem (See: planetseed).
Modeling Steps
Let the order of the star by N, for the 6star, we have N = 6. The set of all points is i = {1…2N} (there are 12 points for the 6star). The star has N lines containing 4 points each. We model this by a set of lines (j = {1…N}) and the number of points on a line as (k = {1…4}). We order the points in such a way – clockwise starting at noon – that it is easy to specify the 6 lines. The data table a_{j,k} identifies the kth point on the jth line. For example, the third point on line 6 is point number 2 (since a_{6,3} = 2). The table is assigned as follows:

We introduce an alldiff variable x_{i} – integer variable where the values of all 12 variables are different (from 1 to 12) (a permutation). An additional variable S is the sum on the lines.

On each line, the 4 corresponding variables are summed up and must be equal to S:

There is only a feasible solution needed.
model mstar "The 6Magic Star";
parameter N:=6;
set j:=1..N; k:=1..4;
i:=1..2*N;
parameter a{j,k}:=(2*j1+if(k<3,k2,k1))%#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((i1)*gPI/2);
parameter Y{i}:=if(i%2=0,s*r,r)*Sin((i1)*gPI/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
To draw the solution – and the star – the positions of the circles are calculated and stored in the two vectors X_{i} and Y _{i} (Hint: a point (x,y) on a circle with center (0, 0) is calculated as follows, see Figure 2):
The outer radius on the star is r, and the inner radius r′ is s ⋅ r, (s being the factor) hence:
Solution
The solution is given in Figure 3. The number on each line sums up to 26 (4N + 2).
Further Comments
No star polygons with less than 5 points exist, and the construction of a normal 5pointed magic star turns out to be impossible, except we accept numbers in the interval [1…12]. The smallest examples of normal magic stars are therefore 6pointed. Notice that for specific values of N, the Npointed magic stars are also known as magic hexagram. With N ≥ 7, there are several “configurations”
(see http://www.magicsquares.net/magic_stars_index.htm).
Questions

Find the value s for calculating the inner radius r′ = s ⋅ r.

Run the model with N = 7 then N = 8
Answers

One can use vector geometry to calculate s. Refer to Figure 4 for the following explanation.
Let N be the order of the magic star, then we define α = 2π∕N. We have (see Figure): OP = s ⋅OC. Furthermore we have:
Hence we get:
From the two equations we can easily derive β and s, and hence the formula above for s.

The only change is the definition of N. The whole graph will be drawn correctly. Verify! The solution graph with N = 7 and n = 8 is shown in Figure 5.
References
[1] MatMod. Homepage for Learning Mathematical Modeling : https://matmod.ch.
[2] Hürlimann T. Reference Manual for the LPL Modeling Language, most recent version. https://matmod.ch/lpl/doc/manual.pdf.