コード例 #1
0
def evaluate_single_pallet(packlist):
    tmp_fh, tmp = tempfile.mkstemp()
    dicttoxmlfile(packlist, tmp)
    result = libpallet.evaluate(sys.argv[1], tmp, sys.argv[3])
    os.close(tmp_fh)
    os.remove(tmp)
    return result
コード例 #2
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)
コード例 #3
0
ファイル: generateOrder.py プロジェクト: ryankane/pallet
def generateOrder(filename, length, width, partitions):
  layers = homogeneousLayers(length, width, partitions)
  order = {
    'Message' : {
      'PalletInit' : { 
        'Pallets' : {
          'Pallet' : {
            'PalletNumber' : 1,
            'Description' : '%dx%d'%(length,width),
            'Dimensions' : {
              'Length' : length,
              'Width' : width,
              'MaxLoadHeight' : 9999,
              'MaxLoadWeight' : 99999,
            },
            'Overhang' : {
              'Length' : 0,
              'Width' : 0,
            },
            'SecurityMargins' : {
            'Length' : 0,
            'Width' : 0,
            },
          },
        },
      },
      'Order' : {
        'ID' : 1,
        'Description' : 'Homogeneous Layers',
        'Restrictions' : {
          'FamilyGrouping' : False,
          'Ranking' : False,
        },
        'OrderLines' : generateOrderLines(layers)
      }
    }
  }

  dicttoxmlfile(order, filename)
コード例 #4
0
ファイル: generateOrder.py プロジェクト: Ash0311/pallet
def generateOrder(filename, length, width, partitions):
    layers = homogeneousLayers(length, width, partitions)
    order = {
        'Message': {
            'PalletInit': {
                'Pallets': {
                    'Pallet': {
                        'PalletNumber': 1,
                        'Description': '%dx%d' % (length, width),
                        'Dimensions': {
                            'Length': length,
                            'Width': width,
                            'MaxLoadHeight': 9999,
                            'MaxLoadWeight': 99999,
                        },
                        'Overhang': {
                            'Length': 0,
                            'Width': 0,
                        },
                        'SecurityMargins': {
                            'Length': 0,
                            'Width': 0,
                        },
                    },
                },
            },
            'Order': {
                'ID': 1,
                'Description': 'Homogeneous Layers',
                'Restrictions': {
                    'FamilyGrouping': False,
                    'Ranking': False,
                },
                'OrderLines': generateOrderLines(layers)
            }
        }
    }

    dicttoxmlfile(order, filename)
コード例 #5
0
ファイル: bruteforce.py プロジェクト: josch/sisyphus
# 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
ファイル: height_bins.py プロジェクト: josch/sisyphus
#                             {'Description': pallet['Description'],
#                              'Dimensions': {'Length': pallet['Dimensions']['Length'],
#                                             'MaxLoadHeight': pallet['Dimensions']['MaxLoadHeight'],
#                                             'MaxLoadWeight': pallet['Dimensions']['MaxLoadWeight'],
#                                             'Width': pallet['Dimensions']['Width']},
#                              'Packages': {'Package': []},
#                              'PalletNumber': pallet['PalletNumber']
#                             }
#             )
#             pack_height = layer[0]['Article']['Height']
#             pack_weight = article['Article']['Weight']
#
#         article['PackSequence'] = pack_sequence
#         article['PlacePosition']['Z'] = pack_height
#         pallets[len(pallets)-1]['Packages']['Package'].append(article)
#         pack_sequence += 1
#         #print "barcode:", article['Barcode']
#
# # TODO: are multiple pallets allowed?
# packlist = {'Response':
#                 {'PackList':
#                     {'OrderID': '1',
#                      'PackPallets':
#                         {'PackPallet': pallets
#                         }
#                     }
#                 }
#             }

dicttoxmlfile(packlist, sys.argv[2])
コード例 #7
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")
コード例 #8
0
ファイル: evaluate_multi.py プロジェクト: josch/sisyphus
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)
コード例 #9
0
ファイル: evaluate_multi.py プロジェクト: Ash0311/pallet
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)
コード例 #10
0
ファイル: split_multi.py プロジェクト: josch/sisyphus
# 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")