# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: RL
#     language: python
#     name: rl
# ---

# +
import pandas as pd
import numpy as np
import pickle
import itertools
import os
import random
import math
import time
import numpy as np
import tensorflow as tf
import matplotlib.pyplot as plt

from collections import deque
from tensorflow.keras.optimizers import Adam
from tensorflow.keras import Sequential
from tensorflow.keras.layers import Dense, Conv1D, MaxPooling1D, Flatten, concatenate, Conv2D, MaxPooling2D

from libs.utils import *
from libs.generate_boxes import  *

# +
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '0'
tf.get_logger().setLevel('INFO')
tf.keras.backend.floatx()

plt.style.use('fivethirtyeight')
plt.rcParams['figure.figsize'] = (20,10)
# -

N_MDD = 32
boxes, gt_pos = generation_3dbox_random(case_size=[[20,20,20]],min_s=1,
                                        N_mdd = N_MDD)
boxes = boxes[0]

# +
K = 3
n_candidates = 4

num_max_boxes = len(boxes)
num_max_remain = num_max_boxes - K
print(num_max_boxes, num_max_remain)
# -

env = Bpp3DEnv()
env.reset()
env.container.shape, env.container_h.shape

boxes_all = np.array(boxes).copy()
r_boxes = boxes_all.copy()
k = min(K, len(r_boxes))
k

box = r_boxes[0]
r_list = []
for i in range(32):
    r_list.append(box)
r_list = np.array(r_list)
r_list

selected = cbn_select_boxes(r_list[:n_candidates],k)
s_order = get_selected_order(selected, k)

s_order, selected



StarcoderdataJupyterScriptsDedupFiltered