diff --git a/prototype/cci/cci1.pdf b/prototype/cci/cci1.pdf new file mode 100644 index 0000000..af05fcc Binary files /dev/null and b/prototype/cci/cci1.pdf differ diff --git a/prototype/cci/cci1.txt b/prototype/cci/cci1.txt new file mode 100644 index 0000000..3078550 --- /dev/null +++ b/prototype/cci/cci1.txt @@ -0,0 +1 @@ + 1 0.000000000000000000000000000000 0.000000000000000000000000000000 diff --git a/prototype/cci/cci10.pdf b/prototype/cci/cci10.pdf new file mode 100644 index 0000000..93a82ab Binary files /dev/null and b/prototype/cci/cci10.pdf differ diff --git a/prototype/cci/cci10.txt b/prototype/cci/cci10.txt new file mode 100644 index 0000000..237fc78 --- /dev/null +++ b/prototype/cci/cci10.txt @@ -0,0 +1,10 @@ + 1 -0.262258924190165855095630653709 -0.689552138434555425611558523406 + 2 0.262258924190165855095630653709 -0.689552138434555425611558523406 + 3 -0.654207495490543857031888931623 -0.340990392505480262378855842125 + 4 0.654207495490543857031888931623 -0.340990392505480262378855842125 + 5 0.000000000000000000000000000000 -0.235306356998833687832605108517 + 6 -0.715460686241806569843043724712 0.179938604472344027862805139398 + 7 0.715460686241806569843043724712 0.179938604472344027862805139398 + 8 0.000000000000000000000000000000 0.289211491381498022358656198900 + 9 -0.415055617900124834285924684739 0.609910427019080420778753583334 + 10 0.415055617900124834285924684739 0.609910427019080420778753583334 diff --git a/prototype/cci/cci11.pdf b/prototype/cci/cci11.pdf new file mode 100644 index 0000000..038bda1 Binary files /dev/null and b/prototype/cci/cci11.pdf differ diff --git a/prototype/cci/cci11.txt b/prototype/cci/cci11.txt new file mode 100644 index 0000000..02e9308 --- /dev/null +++ b/prototype/cci/cci11.txt @@ -0,0 +1,11 @@ + 1 -0.254854701717148909608835737700 -0.700207538209709779458522719445 + 2 0.254854701717148909608835737700 -0.700207538209709779458522719445 + 3 -0.645314757823482092972348022140 -0.372572649141425545195582131150 + 4 0.645314757823482092972348022140 -0.372572649141425545195582131150 + 5 -0.254854701717148909608835737700 -0.044937760073141310932641542855 + 6 0.254854701717148909608835737700 -0.044937760073141310932641542855 + 7 -0.733824866869546118800008853460 0.129393123143898335937886211109 + 8 0.733824866869546118800008853460 0.129393123143898335937886211109 + 9 0.000000000000000000000000000000 0.396483531848771796650108754372 + 10 -0.478970165152397209191173115760 0.570814415065811443520636508336 + 11 0.478970165152397209191173115760 0.570814415065811443520636508336 diff --git a/prototype/cci/cci12.pdf b/prototype/cci/cci12.pdf new file mode 100644 index 0000000..7b7af7b Binary files /dev/null and b/prototype/cci/cci12.pdf differ diff --git a/prototype/cci/cci12.txt b/prototype/cci/cci12.txt new file mode 100644 index 0000000..35d5a11 --- /dev/null +++ b/prototype/cci/cci12.txt @@ -0,0 +1,12 @@ + 1 0.000000000000000000000000000000 -0.751836529428313158455945512868 + 2 -0.468509916422022800799147453449 -0.588010735613764119868275923156 + 3 0.468509916422022800799147453449 -0.588010735613764119868275923156 + 4 -0.248163470571686841544054487132 -0.143277246537595169579619996000 + 5 0.248163470571686841544054487132 -0.143277246537595169579619996000 + 6 -0.743487192950506270382840218584 -0.111736121739513839036609043190 + 7 0.743487192950506270382840218584 -0.111736121739513839036609043190 + 8 0.000000000000000000000000000000 0.286554493075190339159239992000 + 9 -0.651109533978045892394293176753 0.375918264714156579227972756434 + 10 0.651109533978045892394293176753 0.375918264714156579227972756434 + 11 -0.274977276528483469583692765135 0.699746857353277958904884966346 + 12 0.274977276528483469583692765135 0.699746857353277958904884966346 diff --git a/prototype/cci/cci13.pdf b/prototype/cci/cci13.pdf new file mode 100644 index 0000000..06e1e9c Binary files /dev/null and b/prototype/cci/cci13.pdf differ diff --git a/prototype/cci/cci13.txt b/prototype/cci/cci13.txt new file mode 100644 index 0000000..e87a7b0 --- /dev/null +++ b/prototype/cci/cci13.txt @@ -0,0 +1,13 @@ + 1 0.000000000000000000000000000000 -0.763932022500210303590826331269 + 2 -0.449027976579585372441945151797 -0.618033988749894848204586834366 + 3 0.449027976579585372441945151797 -0.618033988749894848204586834366 + 4 0.000000000000000000000000000000 -0.291796067500630910772478993806 + 5 -0.726542528005360885895466757481 -0.236067977499789696409173668731 + 6 0.726542528005360885895466757481 -0.236067977499789696409173668731 + 7 -0.277514551425775513453521605683 0.090169943749474241022934171828 + 8 0.277514551425775513453521605683 0.090169943749474241022934171828 + 9 -0.726542528005360885895466757481 0.236067977499789696409173668731 + 10 0.726542528005360885895466757481 0.236067977499789696409173668731 + 11 0.000000000000000000000000000000 0.472135954999579392818347337463 + 12 -0.449027976579585372441945151797 0.618033988749894848204586834366 + 13 0.449027976579585372441945151797 0.618033988749894848204586834366 diff --git a/prototype/cci/cci2.pdf b/prototype/cci/cci2.pdf new file mode 100644 index 0000000..3b52682 Binary files /dev/null and b/prototype/cci/cci2.pdf differ diff --git a/prototype/cci/cci2.txt b/prototype/cci/cci2.txt new file mode 100644 index 0000000..e265ab5 --- /dev/null +++ b/prototype/cci/cci2.txt @@ -0,0 +1,2 @@ + 1 -0.500000000000000000000000000000 0.000000000000000000000000000000 + 2 0.500000000000000000000000000000 0.000000000000000000000000000000 diff --git a/prototype/cci/cci3.pdf b/prototype/cci/cci3.pdf new file mode 100644 index 0000000..3443743 Binary files /dev/null and b/prototype/cci/cci3.pdf differ diff --git a/prototype/cci/cci3.txt b/prototype/cci/cci3.txt new file mode 100644 index 0000000..a1e943d --- /dev/null +++ b/prototype/cci/cci3.txt @@ -0,0 +1,3 @@ + 1 -0.464101615137754587054892683011 -0.267949192431122706472553658494 + 2 0.464101615137754587054892683011 -0.267949192431122706472553658494 + 3 0.000000000000000000000000000000 0.535898384862245412945107316988 diff --git a/prototype/cci/cci4.pdf b/prototype/cci/cci4.pdf new file mode 100644 index 0000000..befc7a5 Binary files /dev/null and b/prototype/cci/cci4.pdf differ diff --git a/prototype/cci/cci4.txt b/prototype/cci/cci4.txt new file mode 100644 index 0000000..2499108 --- /dev/null +++ b/prototype/cci/cci4.txt @@ -0,0 +1,4 @@ + 1 -0.414213562373095048801688724210 -0.414213562373095048801688724210 + 2 0.414213562373095048801688724210 -0.414213562373095048801688724210 + 3 -0.414213562373095048801688724210 0.414213562373095048801688724210 + 4 0.414213562373095048801688724210 0.414213562373095048801688724210 diff --git a/prototype/cci/cci5.pdf b/prototype/cci/cci5.pdf new file mode 100644 index 0000000..463506a Binary files /dev/null and b/prototype/cci/cci5.pdf differ diff --git a/prototype/cci/cci5.txt b/prototype/cci/cci5.txt new file mode 100644 index 0000000..5034ebc --- /dev/null +++ b/prototype/cci/cci5.txt @@ -0,0 +1,5 @@ + 1 -0.370191908158750137702237641058 -0.509525449494428810513706911251 + 2 0.370191908158750137702237641058 -0.509525449494428810513706911251 + 3 -0.598983089761037227177173011864 0.194621403573803879364825731779 + 4 0.598983089761037227177173011864 0.194621403573803879364825731779 + 5 0.000000000000000000000000000000 0.629808091841249862297762358942 diff --git a/prototype/cci/cci6.pdf b/prototype/cci/cci6.pdf new file mode 100644 index 0000000..b1cefb0 Binary files /dev/null and b/prototype/cci/cci6.pdf differ diff --git a/prototype/cci/cci6.txt b/prototype/cci/cci6.txt new file mode 100644 index 0000000..6c5b990 --- /dev/null +++ b/prototype/cci/cci6.txt @@ -0,0 +1,6 @@ + 1 -0.333333333333333333333333333333 -0.577350269189625764509148780502 + 2 0.333333333333333333333333333333 -0.577350269189625764509148780502 + 3 -0.666666666666666666666666666667 0.000000000000000000000000000000 + 4 0.666666666666666666666666666667 0.000000000000000000000000000000 + 5 -0.333333333333333333333333333333 0.577350269189625764509148780502 + 6 0.333333333333333333333333333333 0.577350269189625764509148780502 diff --git a/prototype/cci/cci7.pdf b/prototype/cci/cci7.pdf new file mode 100644 index 0000000..bd7c87b Binary files /dev/null and b/prototype/cci/cci7.pdf differ diff --git a/prototype/cci/cci7.txt b/prototype/cci/cci7.txt new file mode 100644 index 0000000..c17387c --- /dev/null +++ b/prototype/cci/cci7.txt @@ -0,0 +1,7 @@ + 1 -0.333333333333333333333333333333 -0.577350269189625764509148780502 + 2 0.333333333333333333333333333333 -0.577350269189625764509148780502 + 3 -0.666666666666666666666666666667 0.000000000000000000000000000000 + 4 0.000000000000000000000000000000 0.000000000000000000000000000000 + 5 0.666666666666666666666666666667 0.000000000000000000000000000000 + 6 -0.333333333333333333333333333333 0.577350269189625764509148780502 + 7 0.333333333333333333333333333333 0.577350269189625764509148780502 diff --git a/prototype/cci/cci8.pdf b/prototype/cci/cci8.pdf new file mode 100644 index 0000000..24d6ba3 Binary files /dev/null and b/prototype/cci/cci8.pdf differ diff --git a/prototype/cci/cci8.txt b/prototype/cci/cci8.txt new file mode 100644 index 0000000..72d4c30 --- /dev/null +++ b/prototype/cci/cci8.txt @@ -0,0 +1,8 @@ + 1 -0.302593388348611302909204224933 -0.628341645367213738512227388956 + 2 0.302593388348611302909204224933 -0.628341645367213738512227388956 + 3 -0.679921171839088240043878874469 -0.155187570571975671990838057814 + 4 0.679921171839088240043878874469 -0.155187570571975671990838057814 + 5 0.000000000000000000000000000000 0.000000000000000000000000000000 + 6 -0.545254445070410775447749861103 0.434825910113495061957667559237 + 7 0.545254445070410775447749861103 0.434825910113495061957667559237 + 8 0.000000000000000000000000000000 0.697406611651388697090795775067 diff --git a/prototype/cci/cci9.pdf b/prototype/cci/cci9.pdf new file mode 100644 index 0000000..6e39652 Binary files /dev/null and b/prototype/cci/cci9.pdf differ diff --git a/prototype/cci/cci9.txt b/prototype/cci/cci9.txt new file mode 100644 index 0000000..6243058 --- /dev/null +++ b/prototype/cci/cci9.txt @@ -0,0 +1,9 @@ + 1 -0.276768653914155215717770973808 -0.668178637919298919997757686523 + 2 0.276768653914155215717770973808 -0.668178637919298919997757686523 + 3 -0.668178637919298919997757686523 -0.276768653914155215717770973808 + 4 0.668178637919298919997757686523 -0.276768653914155215717770973808 + 5 0.000000000000000000000000000000 0.000000000000000000000000000000 + 6 -0.668178637919298919997757686523 0.276768653914155215717770973808 + 7 0.668178637919298919997757686523 0.276768653914155215717770973808 + 8 -0.276768653914155215717770973808 0.668178637919298919997757686523 + 9 0.276768653914155215717770973808 0.668178637919298919997757686523 diff --git a/prototype/cci/radii.txt b/prototype/cci/radii.txt new file mode 100644 index 0000000..a829eec --- /dev/null +++ b/prototype/cci/radii.txt @@ -0,0 +1,15 @@ +# N (number of circles) | radius of enclosed circles (enclosing circle has radius of 1) +# source: http://www.packomania.com +1 1.000000000000000000000000000000 +2 0.500000000000000000000000000000 +3 0.464101615137754587054892683012 +4 0.414213562373095048801688724210 +5 0.370191908158750137702237641058 +6 0.333333333333333333333333333333 +7 0.333333333333333333333333333333 +8 0.302593388348611302909204224934 +9 0.276768653914155215717770973808 +10 0.262258924190165855095630653709 +11 0.254854701717148909608835737700 +12 0.248163470571686841544054487132 +13 0.236067977499789696409173668731 diff --git a/prototype/circles.py b/prototype/circles.py index 1e4943e..fda173e 100644 --- a/prototype/circles.py +++ b/prototype/circles.py @@ -1,90 +1,115 @@ from casadi import * import matplotlib.pyplot as plt +import math +import operator -file = open('tmp2019_cci_08_26_11_36_00.txt') +N = 7 # number of enclosed circles + +# this function reads and processes data for optimal circle packaging obtained form packomania.com +def read_circle_data(N): + coords_raw = open('cci/cci{}.txt'.format(N)) + radii_raw = open('cci/radii.txt'.format(N)) + + coords_raw = coords_raw.readlines() + coords_raw = [c.split() for c in coords_raw if c[0] != '#'] + coords = {} + for c in coords_raw: + coords[int(c[0])] = (float(c[1]), float(c[2])) + + coords = sort_ccw(coords, (0,0)) + + radii_raw = radii_raw.readlines() + radii_raw = [r.split() for r in radii_raw if r[0] != '#'] + radii = {} + for r in radii_raw: + radii[int(r[0])] = float(r[1]) + + return radii[N], coords + +# this function sorts enclosed circle coordinates counter-clockwise w.r.t. the center point +# TODO: there is a problem when circles are present that are not touching the boundary of the enclosing circle (e.g. N = 7) +def sort_ccw(coords, center): + a = {} + for c in coords: + a[c] = math.atan2(coords[c][1] - center[1], coords[c][0] - center[0]) + a_sort = sorted(a.items(), key=operator.itemgetter(1)) + + coords_sort = [] + for a in a_sort: + coords_sort.append(coords[a[0]]) + + return coords_sort + +# read radius and center coordinates for enclosed circles +rtilde, coords = read_circle_data(N) c = (0.0, 0.0) # center of big circle -R = 15.0 # radius of big circle +R = 1.0 # radius of big circle -# center for smaller circles -p1 = (-5.55287862, -7.64288174) -p2 = (5.55287862, -7.64288174) -p3 = (-8.98474635, 2.91932105) -p4 = (8.98474635, 2.91932105) -p5 = (0.00000000, 9.44712138) -rtilde = 5.5 # radius of smaller circles - -points = [p1, p2, p3, p4, p5] - -# midpoint between center of two circles -m = np.mean([p1, p2], axis=0) - -# vector in direction of midpoint -v = m - np.array(c) -v = v/np.linalg.norm(v) - -plt.xlim((-16, 16)) -plt.ylim((-16, 16)) +plt.xlim((-1, 1)) +plt.ylim((-1, 1)) plt.gca().set_aspect('equal', 'box') +plt.ion() +plt.show() -for p in points: +for p in coords: plt.plot(p[0], p[1], 'o') circle = plt.Circle(p, rtilde, fill=False) plt.gca().add_artist(circle) circle = plt.Circle(c, R, fill=False) plt.gca().add_artist(circle) -#plt.show() plt.plot(c[0], c[1], 'o') -plt.plot(m[0], m[1], 'o') -opti = casadi.Opti() +for k in range(0, N): + p1 = coords[k] + p2 = coords[(k+1) % N] -r = opti.variable(1) # radius of new circle -p = opti.variable(2) # center of new circle -#v1 = opti.variable(2) # direction vector from -#v2 = opti.variable(2) -lamb = opti.variable(1) + # midpoint between center of two circles + m = np.mean([p1, p2], axis=0) -opti.minimize(-r) -opti.subject_to(p == c + v * lamb) -opti.subject_to((p[0] - p1[0])**2 + (p[1] - p1[1])**2 >= (rtilde + r)**2) -#opti.subject_to(p == (rtilde + r) * v1 + p1) -#opti.subject_to(p == (rtilde + r) * v2 + p2) -#opti.subject_to((v1[0]**2+v1[1]**2)**0.5 == 1) -#opti.subject_to((v2[0]**2+v2[1]**2)**0.5 == 1) -opti.subject_to(R == lamb + r) -opti.subject_to(r >= 0) -opti.subject_to(r <= R) -#opti.subject_to(lamb >= 0.6 * R) + # vector in direction of midpoint + v = m - np.array(c) + v = v/np.linalg.norm(v) + plt.plot(m[0], m[1], 'o') -opti.solver('ipopt') + opti = casadi.Opti() -init_r = 0.1 -init_lamb = R - init_r -init_p = c + v * init_lamb + r = opti.variable(1) # radius of new circle + p = opti.variable(2) # center of new circle + lamb = opti.variable(1) + opti.minimize(-r) + opti.subject_to(p == c + v * lamb) + opti.subject_to((p[0] - p1[0])**2 + (p[1] - p1[1])**2 >= (rtilde + r)**2) + opti.subject_to(R == lamb + r) + opti.subject_to(r >= 0) + opti.subject_to(r <= R) -opti.set_initial(r, init_r) -opti.set_initial(p, init_p) -opti.set_initial(lamb, init_lamb) -#opti.set_initial(v1, ) + opti.solver('ipopt') -sol = opti.solve() + init_r = 0.1 + init_lamb = R - init_r + init_p = c + v * init_lamb -p = sol.value(p) -r = sol.value(r) -lamb = sol.value(lamb) + opti.set_initial(r, init_r) + opti.set_initial(p, init_p) + opti.set_initial(lamb, init_lamb) -print("p = {}".format(p)) -print("r = {}".format(r)) -print("lambda = {}".format(lamb)) -print("v = {}".format(v)) + sol = opti.solve() -plt.plot(p[0], p[1], 'o') -circle = plt.Circle(p, r, fill=False) -plt.gca().add_artist(circle) -plt.show() + p = sol.value(p) + r = sol.value(r) + lamb = sol.value(lamb) + + print("p = {}".format(p)) + print("r = {}".format(r)) + print("lambda = {}".format(lamb)) + print("v = {}".format(v)) + + plt.plot(p[0], p[1], 'o') + circle = plt.Circle(p, r, fill=False) + plt.gca().add_artist(circle) pass \ No newline at end of file diff --git a/prototype/tmp2019_cci_08_26_11_36_00.ps b/prototype/tmp2019_cci_08_26_11_36_00.ps deleted file mode 100644 index 73fc02a..0000000 --- a/prototype/tmp2019_cci_08_26_11_36_00.ps +++ /dev/null @@ -1,95 +0,0 @@ -%!PS-Adobe-3.0 EPSF-3.0 -%%Title: /srv/http/htdocs/packing/tmp/tmp2019_cci_08_26_11_36_00.ps -%%Creator: nicefig-2.0 -%%Pages: 1 -%%BoundingBox: 40 250 580 790 -%%DocumentProcessColors: Cyan Magenta Yellow Black -%%CreationDate: 26-Aug-2019 11:36:00 -%%DocumentFonts: Courier -%%+ Courier-Bold -%%+ Helvetica -%%+ Helvetica-Oblique -%%+ Symbol -%%EndComments -%%EndProlog - -20 dict begin -gsave -/g { setgray } bind def -/rgb { setrgbcolor } bind def -/np { newpath } bind def -/m { moveto } bind def -/rm { rmoveto } bind def -/l { lineto } bind def -/rl { rlineto } bind def -/c { curveto } bind def -/s { stroke } bind def -/f { closepath fill } bind def -/la { setlinejoin setlinecap 1.0417 mul setlinewidth } bind def -/lc { setlinecap } bind def -/lj { setlinejoin } bind def -/ld { setdash } bind def -/lw { setlinewidth } bind def -/font { findfont exch scalefont setfont } bind def -/rgh { dup stringwidth pop neg 0 rm } bind def -/ctr { dup stringwidth pop 2 div neg 0 rm } bind def - - 1 lj 1 lc 0.200 lw - -% - 0.400 lw -% -% box -% - 310.000 520.000 250.000 0 360 arc s -% -% circles -% - 1.000 0.843 0.000 rgb - 309.119 392.619 m 217.452 392.619 91.667 0 360 arc f - 0.000 0.000 0.000 rgb - 1.000 0.843 0.000 rgb - 494.215 392.619 m 402.548 392.619 91.667 0 360 arc f - 0.000 0.000 0.000 rgb - 1.000 0.843 0.000 rgb - 251.921 568.655 m 160.254 568.655 91.667 0 360 arc f - 0.000 0.000 0.000 rgb - 1.000 0.843 0.000 rgb - 551.412 568.655 m 459.746 568.655 91.667 0 360 arc f - 0.000 0.000 0.000 rgb - 1.000 0.843 0.000 rgb - 401.667 677.452 m 310.000 677.452 91.667 0 360 arc f - 0.000 0.000 0.000 rgb - 0.000 0.000 0.000 rgb - 217.452 392.619 91.667 0 360 arc s - 0.000 0.000 0.000 rgb - 402.548 392.619 91.667 0 360 arc s - 0.000 0.000 0.000 rgb - 160.254 568.655 91.667 0 360 arc s - 0.000 0.000 0.000 rgb - 459.746 568.655 91.667 0 360 arc s - 0.000 0.000 0.000 rgb - 310.000 677.452 91.667 0 360 arc s -% -% centers -% - 218.580 392.619 m 217.452 392.619 1.128 0 360 arc f - 403.676 392.619 m 402.548 392.619 1.128 0 360 arc f - 161.383 568.655 m 160.254 568.655 1.128 0 360 arc f - 460.874 568.655 m 459.746 568.655 1.128 0 360 arc f - 311.128 677.452 m 310.000 677.452 1.128 0 360 arc f -% - 12.00 /Courier font - 70.000 251.000 m (www.packomania.com) show - 12.00 /Symbol font - 430.000 250.000 m (Ó) show - 12.00 /Courier font - 442.000 251.000 m (E.S) show - 9.00 /Courier font - 464.000 251.000 m (PECHT) show - 500.000 251.000 m (26-AUG-2019) show - -showpage -grestore end -%%Trailer -%%EOF diff --git a/prototype/tmp2019_cci_08_26_11_36_00.txt b/prototype/tmp2019_cci_08_26_11_36_00.txt deleted file mode 100644 index 60d38c2..0000000 --- a/prototype/tmp2019_cci_08_26_11_36_00.txt +++ /dev/null @@ -1,5 +0,0 @@ - 1 -5.55287862 -7.64288174 - 2 5.55287862 -7.64288174 - 3 -8.98474635 2.91932105 - 4 8.98474635 2.91932105 - 5 0.00000000 9.44712138