示例#1
0
def pack_single_pallet(permut_layers, rest_layers, pallet):
    pack_sequence = 1
    pack_height = 0

    articles_to_pack = list()

    for layer in permut_layers+rest_layers:
        pack_height += layer[0]['Article']['Height']
        #if pack_height > pallet['Dimensions']['MaxLoadHeight']:
        #    break
        for article in layer:
            article['PackSequence'] = pack_sequence
            article['PlacePosition']['Z'] = pack_height
            articles_to_pack.append(article)
            pack_sequence += 1

    return get_packlist_dict(pallet, articles_to_pack)
示例#2
0
文件: main.py 项目: ryankane/pallet
def pack_single_pallet(layers, pallet):
  pack_sequence = 1
  pack_height = 0

  articles_to_pack = list()

  for layer in layers:
    max_height = get_max_height(layer)
    pack_height += max_height
    for article in layer:
      article['PackSequence'] = pack_sequence
      height_diff = max_height - article['Article']['Height']
      article['PlacePosition']['Z'] = pack_height - height_diff
      articles_to_pack.append(article)
      pack_sequence += 1

  return get_packlist_dict(pallet, articles_to_pack)
示例#3
0
def pack_single_pallet(layers, pallet):
    pack_sequence = 1
    pack_height = 0

    articles_to_pack = list()

    for layer in layers:
        max_height = get_max_height(layer)
        pack_height += max_height
        for article in layer:
            article['PackSequence'] = pack_sequence
            height_diff = max_height - article['Article']['Height']
            article['PlacePosition']['Z'] = pack_height - height_diff
            articles_to_pack.append(article)
            pack_sequence += 1

    return get_packlist_dict(pallet, articles_to_pack)
示例#4
0
def evaluate_multi_pallet(packlist):
    pallets = packlist['Response']['PackList']['PackPallets']['PackPallet']

    article_lists = [ pallet['Packages']['Package'] for pallet in pallets ]

    scores = list()
    for pallet, articles_to_pack in zip(pallets, article_lists):
        partial_packlist = get_packlist_dict(pallet, articles_to_pack)
        tmp_fh, tmp = tempfile.mkstemp()
        tmp_order_fh, tmp_order = tempfile.mkstemp()
        dicttoxmlfile(partial_packlist, tmp)
        dicttoxmlfile(get_order_dict(pallet, articles_to_pack), tmp_order)
        scores.append(libpallet.evaluate(tmp_order, tmp, sys.argv[3]))
        os.close(tmp_fh)
        os.close(tmp_order_fh)
        os.remove(tmp)
        os.remove(tmp_order)

    return sum(scores)/len(scores)
示例#5
0
# TODO: care for possible rests

# TODO: enumerate all possible combinations of layers

score_max = 0.0

import copy

for layers in list_of_layerlists:
    for layer_order in itertools.permutations(layers):
        pack_sequence = 1
        pack_height = 0
        articles_to_pack = list()

        for layer in layer_order:
            pack_height += layer[0]['Article']['Height']
            for article in layer:
                article['PackSequence'] = pack_sequence
                article['PlacePosition']['Z'] = pack_height
                articles_to_pack.append(article)
                pack_sequence += 1

        dicttoxmlfile(get_packlist_dict(pallet, articles_to_pack), sys.argv[2]+".tmp")

        score = float(subprocess.check_output("../palletandtruckviewer-3.0/palletViewer -o "
            +sys.argv[1]+" -p "+sys.argv[2]
            +".tmp -s ../icra2011TestFiles/scoreAsPlannedConfig1.xml --headless | grep Score", shell=True).split(' ')[1].strip())
        print score
        if score > score_max:
            shutil.move(sys.argv[2]+".tmp", sys.argv[2])
示例#6
0
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Sisyphus.  If not, see <http://www.gnu.org/licenses/>.

import ctypes, sys
from util import xmlfiletodict, get_packlist_dict, dicttoxmlfile, get_order_dict
import os

if len(sys.argv) != 2:
    print "usage:", sys.argv[0], "packlist.xml"
    exit(1)

packlist = xmlfiletodict(sys.argv[1])

pallets = packlist['Response']['PackList']['PackPallets']['PackPallet']

if not isinstance(pallets, list):
    sys.stderr.write("this is not a multi-pallet packlist\n")
    exit(1)

article_lists = [pallet['Packages']['Package'] for pallet in pallets]

scores = list()
for i, (pallet, articles_to_pack) in enumerate(zip(pallets, article_lists)):
    partial_packlist = get_packlist_dict(pallet, articles_to_pack)
    dicttoxmlfile(partial_packlist, sys.argv[1] + "_" + str(i) + ".xml")
    partial_order = get_order_dict(pallet, articles_to_pack)
    dicttoxmlfile(partial_order, sys.argv[1] + "_order_" + str(i) + ".xml")
示例#7
0
if len(sys.argv) != 3:
    print "usage:", sys.argv[0], "packlist.xml scoring.xml"
    exit(1)

libpallet = ctypes.cdll.LoadLibrary("./libpallet.so.0.0.0")
libpallet.evaluate.restype = ctypes.c_double

packlist = xmlfiletodict(sys.argv[1])

pallets = packlist["Response"]["PackList"]["PackPallets"]["PackPallet"]

article_lists = [pallet["Packages"]["Package"] for pallet in pallets]

scores = list()
for pallet, articles_to_pack in zip(pallets, article_lists):
    partial_packlist = get_packlist_dict(pallet, articles_to_pack)
    tmp_fh, tmp = tempfile.mkstemp()
    tmp_order_fh, tmp_order = tempfile.mkstemp()
    dicttoxmlfile(partial_packlist, tmp)
    dicttoxmlfile(get_order_dict(pallet, articles_to_pack), tmp_order)
    scores.append(libpallet.evaluate(tmp_order, tmp, sys.argv[2]))
    os.close(tmp_fh)
    os.close(tmp_order_fh)
    os.remove(tmp)
    os.remove(tmp_order)
    # print tmp_order, tmp
print scores

print sum(scores) / len(scores)