3d-bin-packing

Packer, 3D-Bin-Packing with multiple Boxes.

Packer

3D Bin Packing with multiple wrappers (boxes).

Red Printing

Red-Printing is a brand name of printing service supported by Betterway-systems.

레드 프린팅은 베러웨이시스템즈에서 실시하는 인쇄 서비스의 브랜드 명입니다. 많은 이용 바랍니다.

Packer를 이용하시는 여러분, 인쇄 주문은 꼭 레드프린팅에서 해 주세요.

http://redprinting.co.kr/

Author

References

Demo

Programming
Algorithm from Airforce Bin Packing

Installation

Node.JS
npm install -g 3d-bin-packing
tsd install 3d-bin-packing
TypeScript (JavaScript) only

If you want the TypeScript (JavaScript) only mode, any installation procedure is not required.

Build Cloud Server

However, if you want to install the C++ mode, you've to install Visual C++ Redistributable for Visual Studio 2015. After the installation, execute release/cpp/Packer.exe. Then a cloud server deducting packer solution will be opened. After running the cloud server, open release/browser/index.html.

You also can separate cloud server(C++) and clients(Web), let users to connect remote Packer server, by editing ip address in release/browser/server.xml

Implementation

Design

Languages
  • C++
    • Server solving packing problem.
    • Deduct the best optimization result with genetic algorithm
  • TypeScript
    1. Act a role of client connecting to C++ server.
    2. Do packing itself without C++ server and do not use genetic algorithm.
      • The optimization result can be inferior than C++
Dependency

Usage

TypeScript (Node.JS)
import packer = require("3d-bin-packing");
import samchon = require("samchon-framework");

function main(): void
{
    ///////////////////////////
    // CONSTRUCT OBJECTS
    ///////////////////////////
    let wrapperArray: packer.WrapperArray = new packer.WrapperArray();
    let instanceArray: packer.InstanceArray = new packer.InstanceArray();

    // Wrappers
    wrapperArray.push
    (
        new packer.Wrapper("Large", 1000, 40, 40, 15, 0),
        new packer.Wrapper("Medium", 700, 20, 20, 10, 0),
        new packer.Wrapper("Small", 500, 15, 15, 8, 0)
    );

    ///////
    // Each Instance is repeated #15
    ///////
    instanceArray.insert(instanceArray.end(), 15, new packer.Product("Eraser", 1, 2, 5));
    instanceArray.insert(instanceArray.end(), 15, new packer.Product("Book", 15, 30, 3));
    instanceArray.insert(instanceArray.end(), 15, new packer.Product("Drink", 3, 3, 10));
    instanceArray.insert(instanceArray.end(), 15, new packer.Product("Umbrella", 5, 5, 20));

    // Wrappers also can be packed into another Wrapper.
    instanceArray.insert(instanceArray.end(), 15, new packer.Wrapper("Notebook-Box", 2000, 30, 40, 4, 2));
    instanceArray.insert(instanceArray.end(), 15, new packer.Wrapper("Tablet-Box", 2500, 20, 28, 2, 0));

    ///////////////////////////
    // BEGINS PACKING
    ///////////////////////////
    // CONSTRUCT PACKER
    let my_packer: packer.Packer = new packer.Packer(wrapperArray, instanceArray);

    ///////
    // PACK (OPTIMIZE)
    let result: packer.WrapperArray = my_packer.optimize();
    ///////

    ///////////////////////////
    // TRACE PACKING RESULT
    ///////////////////////////
    let xml: samchon.library.XML = result.toXML();
    console.log(xml.toString());
}

main();
C++
#include <iostream>
#include <bws/packer/Packer.hpp>

#include <bws/packer/WrapperArray.hpp>
#include <bws/packer/InstanceArray.hpp>
# include <bws/packer/Product.hpp>
# include <bws/packer/Wrapper.hpp>

using namespace std;
using namespace samchon::library;
using namespace bws::packer;

int main()
{
    ///////////////////////////
    // CONSTRUCT OBJECTS
    ///////////////////////////
    shared_ptr<WrapperArray> wrapperArray(new WrapperArray());
    shared_ptr<InstanceArray> instanceArray(new InstanceArray());

    // Wrappers
    wrapperArray->emplace_back(new bws.packer.Wrapper("Large", 1000, 40, 40, 15, 0));
    wrapperArray->emplace_back(new Wrapper("Medium", 700, 20, 20, 10, 0));
    wrapperArray->emplace_back(new Wrapper("Small", 500, 15, 15, 8, 0));

    ///////
    // Each Instance is repeated #15
    ///////
    instanceArray->insert(instanceArray->end(), 15, make_shared<Product>("Eraser", 1, 2, 5));
    instanceArray->insert(instanceArray->end(), 15, make_shared<Product>("Book", 15, 30, 3));
    instanceArray->insert(instanceArray->end(), 15, make_shared<Product>("Drink", 3, 3, 10));
    instanceArray->insert(instanceArray->end(), 15, make_shared<Product>("Umbrella", 5, 5, 20));

    // Wrappers also can be packed into another Wrapper.
    instanceArray->insert(instanceArray->end(), 15, make_shared<Wrapper>("Notebook-Box", 2000, 30, 40, 4, 2));
    instanceArray->insert(instanceArray->end(), 15, make_shared<Wrapper>("Tablet-Box", 2500, 20, 28, 2, 0));

    ///////////////////////////
    // BEGINS PACKING
    ///////////////////////////
    // CONSTRUCT PACKER
    Packer packer(wrapperArray, instanceArray);
    GAParameters gaParams = {500, 100, 50, 0.2};

    ///////
    // PACK (OPTIMIZE)
    ///////
    shared_ptr<WrapperArray> &result = packer.optimize(gaParams);

    ///////////////////////////
    // TRACE PACKING RESULT
    ///////////////////////////
    shared_ptr<XML> xml = result->toXML();
    cout << xml->toString() << endl;

    return 0;
}

License

BSD v3.

Copyright (c) 2016, betterwaysystems All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

  • Neither the name of packer nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

HomePage

http://betterwaysystems.github.io/packer

Repository

https://github.com/betterwaysystems/packer.git


上一篇:node-environment-flags
下一篇:1c

相关推荐

  • 面试常谈之手写new、call、apply和bind

    new 可以概括为以下四步: 1.创建一个空对象 2.链接到原型 3.绑定this值 4.返回新对象 call 这里提供两种写法 本文参考: (https://www.ji...

    7 个月前
  • 面试官:bind两次的结果了解一下

    背景 最近帮助组内进行技术面试,听到有人问了个很有意思的问题,函数bind两次后this指向。平时使用和问的比较多的都是bind接收的参数和bind后的this指向问题,bind多次还真没去想过。

    3 个月前
  • 面试官问:能否模拟实现bind

    前言 用过的同学都知道,经常会使用来绑定。 那么面试官可能会问是否想过到底做了什么,怎么模拟实现呢。 附上之前写文章写过的一段话:已经有很多模拟实现的文章,为什么自己还要写一遍呢。

    1 年前
  • 面试官:你能手写实现call,apply,bind方法吗?

    实践系列 主要是让我们通过实践去加深对一些原理的理解。 实践系列前端路由(https://juejin.im/post/5c380afde51d4552232fb077) 实践系列Babel原理(...

    1 年前
  • 需要说明的_功能。bindall() Underscore.js

    ThiefMasterNik So(https://stackoverflow.com/users/298479/thiefmaster)提出了一个问题:need explanation of the...

    2 年前
  • 都2020年了,你应该知道如何手写Call、Apply、Bind了吧

    导读 作为面试中面试官最宠爱的一个问题,在这里进行一个详细的介绍,大家重点要放在理解,而不是背。 写的不好或不对的地方,请大家积极指出,好了,话不多说,我们“圆规正转” 一、手写实现Call ...

    3 个月前
  • 通过this深入理解javascript函数的bind、call、apply

    我们都知道函数这个高级公民在js中的地位很高。用处很大,可是却很难搞!函数内部有一个很厉害的内部属性this关键字。而bind、call、apply是函数的3个非继承方法(但是在原型链中找到了这些方法...

    9 个月前
  • 详谈jQuery unbind 删除绑定事件 / 移除标签方法

    jQuery unbind 删除绑定事件 unbind(type,data) 是 bind()的反向操作,从每一个匹配的元素中删除绑定的事件。如果没有参数,则删除所有绑定的事件。

    3 年前
  • 聊一聊call、apply、bind的区别

    我们都知道 都可以改变函数调用的指向。那么它们三者有什么区别,什么时候该用哪个呢? 我们先直接通过代码实例来了解,后面再借助专业文档来解释。 举个🌰 (https://img.javas...

    2 年前
  • 细说apply call和bind

    bind 概述 bind方法是绑定在了Function.prototype上。这个方法会创建一个新的函数,当被调用时,会将其this关键字,设置为一个提供的值。

    2 年前

官方社区

扫码加入 JavaScript 社区