Esempio n. 1
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)
Esempio n. 2
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")
Esempio n. 3
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)
Esempio n. 4
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)
Esempio n. 5
0
# 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")