started working on prototype design. wrote a python script for computing radius and position of optimally placed outside storage columns
This commit is contained in:
commit
3398f44be0
90
prototype/circles.py
Normal file
90
prototype/circles.py
Normal file
|
@ -0,0 +1,90 @@
|
|||
from casadi import *
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
file = open('tmp2019_cci_08_26_11_36_00.txt')
|
||||
|
||||
c = (0.0, 0.0) # center of big circle
|
||||
R = 15.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.gca().set_aspect('equal', 'box')
|
||||
|
||||
|
||||
for p in points:
|
||||
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()
|
||||
|
||||
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)
|
||||
|
||||
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)
|
||||
|
||||
opti.solver('ipopt')
|
||||
|
||||
init_r = 0.1
|
||||
init_lamb = R - init_r
|
||||
init_p = c + v * init_lamb
|
||||
|
||||
|
||||
opti.set_initial(r, init_r)
|
||||
opti.set_initial(p, init_p)
|
||||
opti.set_initial(lamb, init_lamb)
|
||||
#opti.set_initial(v1, )
|
||||
|
||||
sol = opti.solve()
|
||||
|
||||
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)
|
||||
plt.show()
|
||||
|
||||
pass
|
95
prototype/tmp2019_cci_08_26_11_36_00.ps
Normal file
95
prototype/tmp2019_cci_08_26_11_36_00.ps
Normal file
|
@ -0,0 +1,95 @@
|
|||
%!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
|
5
prototype/tmp2019_cci_08_26_11_36_00.txt
Normal file
5
prototype/tmp2019_cci_08_26_11_36_00.txt
Normal file
|
@ -0,0 +1,5 @@
|
|||
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
|
Loading…
Reference in New Issue
Block a user