Giter Club home page Giter Club logo

Comments (4)

sjYoondeltar avatar sjYoondeltar commented on July 17, 2024 1

@Bailey-24
I modify the discrete observation environment (pct_envs/PctDiscrete0)/bin3D.py) by adding render() like this;

    def render(self, mode=None, wait_time=10):
    
            # mode is ignored
    
            vis_plain = self.space.plain
    
            # Create the image from the array
            image = np.empty((len(vis_plain), len(vis_plain[0]), 3), dtype=np.uint8)  # Create an empty image with 3 channels (RGB)
            for i in range(len(vis_plain)):
                for j in range(len(vis_plain[0])):
                    image[i][j] = self.colors_map[vis_plain[i][j]]  # Set the pixel color based on the value in the array
    
            # Resize the image
            expanded_image  = cv2.resize(image, (30*image.shape[1], 30*image.shape[0]), interpolation=cv2.INTER_NEAREST)

            # Write the values on each cell
            font = cv2.FONT_HERSHEY_SIMPLEX  # Define the font
            font_scale = 0.5  # Define the font scale
            thickness = 1  # Define the line thickness
            for i in range(len(vis_plain)):
                for j in range(len(vis_plain[0])):
                    value = str(vis_plain[i][j])  # Convert the value to a string
                    (x, y) = (j * 30 + 5, i * 30 + 20)  # Calculate the position of the text
                    cv2.putText(expanded_image, value, (x, y), font, font_scale, (0, 0, 0), thickness, cv2.LINE_AA)
    
            # Display the image
            cv2.imshow('Bin packing view', expanded_image)
            cv2.waitKey(wait_time)

`

from online-3d-bpp-pct.

Bailey-24 avatar Bailey-24 commented on July 17, 2024 1

Hi, there is a bug.
AttributeError: 'PackingDiscrete' object has no attribute 'colors_map'

how do you initial and process the colors_map in the env.

Thanks in advance.

from online-3d-bpp-pct.

sjYoondeltar avatar sjYoondeltar commented on July 17, 2024 1

@Bailey-24
Hi i'm afraid that i forgot the colors_map
in the PackingDiscrete , I also added the colors_map on the last line def __init__()

``

class PackingDiscrete(gym.Env):
    def __init__(self,
                setting,
                container_size=(10, 10, 10),
                item_set=None, data_name=None, load_test_data=False,
                internal_node_holder=80, leaf_node_holder=50, next_holder=1, shuffle=False,
                LNES = 'EMS',
                **kwags):

        self.internal_node_holder = internal_node_holder
        self.leaf_node_holder = leaf_node_holder
        self.next_holder = next_holder

        self.shuffle = shuffle
        self.bin_size = container_size
        self.size_minimum = np.min(np.array(item_set))
        self.setting = setting
        self.item_set = item_set
        if self.setting == 2: self.orientation = 6
        else: self.orientation = 2
        
        # The class that maintains the contents of the bin.
        self.space = Space(*self.bin_size, self.size_minimum, self.internal_node_holder)

        # Generator for train/test data
        if not load_test_data:
            assert item_set is not None
            self.box_creator = RandomBoxCreator(item_set)
            assert isinstance(self.box_creator, BoxCreator)
        if load_test_data:
            self.box_creator = LoadBoxCreator(data_name)

        self.test = load_test_data
        self.observation_space = gym.spaces.Box(low=0.0, high=self.space.height,
                                                shape=((self.internal_node_holder + self.leaf_node_holder + self.next_holder) * 9,))
        self.action_space = None
        self.next_box_vec = np.zeros((self.next_holder, 9))

        self.LNES = LNES  # Leaf Node Expansion Schemes: EMS (recommend), EV, EP, CP, FC
        
        # Define the color map
        # Define the data type as 8-bit unsigned integer
        self.colors_map = np.array([[20*vidx, 0, 255-20*vidx] for vidx in reversed(range(11))], dtype=np.uint8)    

`

from online-3d-bpp-pct.

sjYoondeltar avatar sjYoondeltar commented on July 17, 2024 1

@Bailey-24

from online-3d-bpp-pct.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.