Skip to content

Commit 703aac5

Browse files
committed
Print statements erased
1 parent 7294232 commit 703aac5

9 files changed

+130
-125
lines changed

box_dimensions.txt

+20-20
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
Contenedor 23 [30, 20, 22]
2-
5 [1, 1, 1]
3-
16 [5, 5, 5]
4-
20 [1, 1, 1]
5-
12 [5, 5, 5]
6-
8 [7, 7, 7]
7-
17 [5, 5, 5]
8-
19 [5, 5, 5]
9-
22 [5, 5, 5]
10-
6 [5, 5, 5]
11-
11 [5, 5, 5]
12-
9 [1, 1, 1]
1+
Contenedor 26 [30, 20, 22]
2+
16 [4, 3, 5]
3+
20 [3, 5, 5]
4+
12 [7, 4, 3]
5+
24 [7, 4, 3]
6+
8 [3, 5, 7]
7+
17 [7, 5, 4]
8+
19 [7, 3, 5]
9+
22 [4, 5, 3]
10+
23 [4, 6, 4]
11+
6 [7, 5, 3]
12+
11 [3, 4, 4]
13+
9 [5, 3, 3]
1314
14 [5, 5, 5]
14-
3 [1, 1, 1]
15-
7 [7, 7, 7]
16-
4 [7, 7, 7]
17-
13 [1, 1, 1]
18-
15 [7, 7, 7]
19-
10 [5, 5, 5]
20-
18 [1, 1, 1]
21-
21 [5, 5, 5]
15+
7 [6, 3, 3]
16+
25 [4, 7, 6]
17+
13 [3, 3, 4]
18+
15 [6, 3, 5]
19+
10 [6, 5, 7]
20+
18 [4, 6, 5]
21+
21 [7, 5, 4]

box_positions.txt

+20-20
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
8 [0, 0, 0] 0
2-
16 [0, 7, 0] 0
3-
11 [0, 12, 0] 0
4-
12 [5, 7, 0] 0
5-
14 [5, 12, 0] 0
6-
7 [7, 0, 0] 0
7-
17 [10, 7, 0] 0
8-
10 [10, 12, 0] 0
9-
4 [14, 0, 0] 0
10-
19 [15, 7, 0] 0
11-
21 [15, 12, 0] 0
12-
22 [20, 7, 0] 0
13-
20 [20, 12, 0] 0
14-
15 [21, 0, 0] 0
15-
3 [21, 12, 0] 0
16-
13 [22, 12, 0] 0
17-
18 [23, 12, 0] 0
18-
6 [25, 7, 0] 0
19-
5 [28, 0, 0] 0
20-
9 [29, 0, 0] 0
1+
10 [0, 0, 0] 0
2+
18 [0, 7, 0] 0
3+
12 [0, 14, 0] 0
4+
8 [4, 7, 0] 0
5+
25 [6, 0, 0] 0
6+
19 [7, 6, 0] 0
7+
24 [7, 11, 0] 0
8+
20 [7, 14, 0] 0
9+
17 [10, 0, 0] 0
10+
22 [10, 14, 0] 0
11+
6 [14, 4, 0] 0
12+
16 [14, 7, 0] 0
13+
7 [14, 12, 0] 0
14+
21 [17, 0, 0] 0
15+
11 [18, 7, 0] 0
16+
9 [20, 11, 0] 0
17+
23 [21, 5, 0] 0
18+
14 [24, 0, 0] 0
19+
15 [25, 5, 0] 1
20+
13 [25, 11, 0] 0

main.py

+63-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# init packing function
1717
packer = Packer()
1818

19-
#Read the file and add ems to the packer
19+
#Read the file and add send it to the packer
2020
file = open('box_dimensions.txt', 'r')
2121
for line in file:
2222
parts = line.split(' [')
@@ -76,6 +76,68 @@
7676
number_of_decimals=0
7777
)
7878

79+
80+
# print result
81+
for box in packer.bins:
82+
83+
volume = box.width * box.height * box.depth
84+
print(":::::::::::", box.string())
85+
86+
print("FITTED ITEMS:")
87+
volume_t = 0
88+
volume_f = 0
89+
unfitted_name = ''
90+
91+
# '''
92+
for item in box.items:
93+
print("partno : ",item.partno)
94+
print("type : ",item.name)
95+
print("color : ",item.color)
96+
#position is (x,y,z)
97+
print("position : ",item.position)
98+
print("rotation type : ",item.rotation_type)
99+
print("W*H*D : ",str(item.width) +'*'+ str(item.height) +'*'+ str(item.depth))
100+
print("volume : ",float(item.width) * float(item.height) * float(item.depth))
101+
print("weight : ",float(item.weight))
102+
volume_t += float(item.width) * float(item.height) * float(item.depth)
103+
print("***************************************************")
104+
print("***************************************************")
105+
# '''
106+
print("UNFITTED ITEMS:")
107+
for item in box.unfitted_items:
108+
print("partno : ",item.partno)
109+
print("type : ",item.name)
110+
print("color : ",item.color)
111+
print("W*H*D : ",str(item.width) +'*'+ str(item.height) +'*'+ str(item.depth))
112+
print("volume : ",float(item.width) * float(item.height) * float(item.depth))
113+
print("weight : ",float(item.weight))
114+
volume_f += float(item.width) * float(item.height) * float(item.depth)
115+
unfitted_name += '{},'.format(item.partno)
116+
print("***************************************************")
117+
print("***************************************************")
118+
print('space utilization : {}%'.format(round(volume_t / float(volume) * 100 ,2)))
119+
print('residual volumn : ', float(volume) - volume_t )
120+
print('unpack item : ',unfitted_name)
121+
print('unpack item volumn : ',volume_f)
122+
print("gravity distribution : ",box.gravity)
123+
# '''
124+
stop = time.time()
125+
print('used time : ',stop - start)
126+
127+
# draw results
128+
painter = Painter(box)
129+
fig = painter.plotBoxAndItems(
130+
title=box.partno,
131+
alpha=0.2,
132+
write_num=True,
133+
fontsize=10
134+
)
135+
136+
137+
138+
139+
fig.show()
140+
79141
#write the ordered positions in the txt
80142
with open('box_positions.txt', 'w') as file:
81143
for box in packer.bins:

packing.jl

+16-33
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ using PyCall
66
using DataStructures
77
queue_cajas = Queue{Int}()
88
queue_cajas_checador = Queue{Int}()
9+
n_grid_model_size = [100, 100]
910

1011
@agent struct Robot(GridAgent{2})
1112
type::String = "Robot"
@@ -66,22 +67,6 @@ function agent_step!(agent::Contenedor, model)
6667
end
6768

6869

69-
# Move the agent along the route and update its rotation
70-
# function move_along_route_with_angle!(agent::Robot, model, pathfinder)
71-
# past_pos = agent.pos
72-
# move_along_route!(agent, model, pathfinder)
73-
# dx = agent.pos[1] - past_pos[1]
74-
# dy = agent.pos[2] - past_pos[2]
75-
# if dx == -1
76-
# agent.angle = 0 # Right
77-
# elseif dx == 1
78-
# agent.angle = 180 # Left
79-
# elseif dy == 1
80-
# agent.angle = 90 # Up
81-
# elseif dy == -1
82-
# agent.angle = 270 # Down
83-
# end
84-
# end
8570

8671

8772
function find_safe_position(agent, next_pos_robot, current_robot_pos, model)
@@ -206,7 +191,6 @@ function agent_step!(agent::Robot, model)
206191
println(box.id)
207192
println(box.pos)
208193
plan_route!(agent, box.pos, pathfinder)
209-
# print("algoooooooooooo2222222")
210194
end
211195
elseif agent.state == 1
212196
#si ya encontró la caja, se mueve a ella
@@ -220,10 +204,10 @@ function agent_step!(agent::Robot, model)
220204

221205
if agent.pos[1] == agent.objective_position[1] && agent.pos[2] == agent.objective_position[2]
222206
agent.state = 2
223-
agent.objective_position = [agent.id, 50] #Aquí deja las cajas
207+
agent.objective_position = [1, 60 - ((agent.id - 1) * 5)] #Aquí deja las cajas
224208
remove_agent!(model[agent.box_id], model)
225209
# dequeue!(queue_cajas)
226-
plan_route!(agent, (agent.objective_position[1],agent.objective_position[2]), pathfinder)
210+
plan_route!(agent, (agent.objective_position[1], agent.objective_position[2]), pathfinder)
227211
#la box id cambia a -1
228212
# agent.box_id = -1
229213
end
@@ -262,27 +246,30 @@ end
262246

263247
function initialize_model()
264248
# Se crea una grid de 50x50
265-
249+
266250
grid_n = 100 #Espacio del Grid
267251
grid = trues(grid_n, grid_n)
268-
space = GridSpace((grid_n,grid_n); periodic=false, metric=:manhattan)
252+
space = GridSpace((grid_n, grid_n); periodic=false, metric=:manhattan)
269253
model = StandardABM(Union{Robot,Box,Contenedor}, space; agent_step!)
270254
#Se agregan los robots
271255
#Supongamos que solo hay uno
272256
add_agent!(Robot, limit=(1, 10), direction=[1, -1], pos=(100, 1), model)
273257
add_agent!(Robot, limit=(1, 10), direction=[1, -1], pos=(99, 1), model)
258+
add_agent!(Robot, limit=(1, 10), direction=[1, -1], pos=(98, 1), model)
259+
add_agent!(Robot, limit=(1, 10), direction=[1, -1], pos=(97, 1), model)
260+
add_agent!(Robot, limit=(1, 10), direction=[1, -1], pos=(96, 1), model)
274261

275262
# #Se agregan las posiciones de las cajas
276-
x = rand(1:grid_n)
277-
y = rand(1:grid_n)
263+
x = rand(2:grid_n-1)
264+
y = rand(2:grid_n-1)
278265

279266
lista_caja = [[1, 1, 1], [5, 5, 5], [7, 7, 7]]
280267

281268

282269
for i in 1:20
283270
while length((ids_in_position((x, y), model))) > 0
284-
x = rand(1:grid_n)
285-
y = rand(1:grid_n)
271+
x = rand(2:grid_n-1)
272+
y = rand(2:grid_n-1)
286273
end
287274
add_agent!(Box, pos=(x, y), model)
288275
println("Box pos", x, " ", y)
@@ -304,10 +291,10 @@ function initialize_model()
304291
for box in allagents(model)
305292
if box.type == "Box"
306293
#dimensiones aletorias
307-
# box.dimension = [rand(3:7), rand(3:7), rand(3:7)]
294+
box.dimension = [rand(3:7), rand(3:7), rand(3:7)]
308295

309296
#dimensiones del socio
310-
box.dimension = lista_caja[rand(1:3)]
297+
# box.dimension = lista_caja[rand(1:3)]
311298

312299
#para indicar que el robot no pueda pasar por la caja
313300
grid[box.pos[1], box.pos[2]] = false
@@ -326,27 +313,23 @@ function initialize_model()
326313
print(file, agent.type, " ")
327314
print(file, agent.id, " ")
328315
println(file, agent.dimension)
329-
# println(file) # Blank line for readability
330316
end
331-
# println(file) # Blank line for readability
332317
end
333318
for agent in allagents(model)
334319
if (agent.type == "Box")
335320
print(file, "$(agent.id) ")
336321
println(file, agent.dimension)
337-
# println(file) # Blank line for readability
338322
end
339-
# println(file) # Blank line for readability
340323
end
341324
end
342325
#Se ejecuta el script de python que nos dira las posiciones de las cajas
343326

344327
#se declara el ejecutable de python
345-
# python_executable = "/Users/ser/Uni/Multiagentes/Proyecto_Packaging/Python3d/simulation.py"
328+
python_executable = "/home/anhuar/anaconda3/envs/my_anaconda_env/bin/python"
346329
# python_executable
347330

348331
#se ejecuta el script de python
349-
run(`python3 main.py`)
332+
run(`$python_executable main.py`)
350333

351334

352335

py_simulation/Basura.py

-14
Original file line numberDiff line numberDiff line change
@@ -47,19 +47,12 @@ def __init__(self, dim=None, vel=1, textures=None, txtIndex=0, Id=-1, posX=0, po
4747

4848
self.W_H_D = [W,D,H]
4949

50-
print("rotationType",self.rotationType)
5150
if self.rotationType == 0:
5251
self.ordered_W_H_D = [self.W_H_D[0],self.W_H_D[1],self.W_H_D[2]]
5352
elif self.rotationType == 1:
5453
self.ordered_W_H_D = [self.W_H_D[1],self.W_H_D[0],self.W_H_D[2]]
5554
elif self.rotationType == 2:
56-
print("ordered antes",self.ordered_W_H_D)
5755
self.ordered_W_H_D = [self.W_H_D[1],self.W_H_D[2],self.W_H_D[0]]
58-
print("---")
59-
print("WHD",self.W_H_D)
60-
print("ordered",self.ordered_W_H_D)
61-
# times = int(input("Cuantas veces quieres que se repita"))
62-
# print("OLa"*times)
6356
elif self.rotationType == 3:
6457
self.ordered_W_H_D = [self.W_H_D[2],self.W_H_D[1],self.W_H_D[0]]
6558
elif self.rotationType == 4:
@@ -194,13 +187,6 @@ def draw_ordenada(self):
194187
self.Position = [0,0,0]
195188
self.W_H_D = self.ordered_W_H_D
196189

197-
print("basura")
198-
# print("First WHD",self.firstW_H_D)
199-
print("Current WHD",self.W_H_D)
200-
print("Ordered WHD",self.ordered_W_H_D)
201-
print("Rotation",self.rotationType)
202-
print(self.Position)
203-
print(self.orderedPosition)
204190
self.draw()
205191
glPopMatrix()
206192

py_simulation/Contenedor.py

-3
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,6 @@ def draw(self):
7171
glColor4f(1.0, 0.0, 0.0, 0.5) # Set color with alpha for transparency
7272

7373

74-
print("Contenedor")
75-
print(self.W_H_D)
76-
print(self.Position)
7774
glBegin(GL_LINE_LOOP)
7875

7976
W = self.W_H_D[0]

py_simulation/Lifter.py

-6
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,6 @@ def update(self,posX,posZ,angle,status,platformHeight,box_id):
8484
self.platformHeight = platformHeight * 0.01
8585
self.box_id = box_id
8686

87-
# if self.platformHeight == -1.5:
88-
# print("NO"*100)
89-
# self.basura = None
90-
91-
9287
def draw(self):
9388
displacement = 2
9489
glPushMatrix()
@@ -231,7 +226,6 @@ def drawTrash(self):
231226

232227
# glBegin(GL_QUADS)
233228
if self.basura != None:
234-
# print("O"*10)
235229
self.basura.Position = [0, 0, 0]
236230
self.basura.draw()
237231

Binary file not shown.

0 commit comments

Comments
 (0)