use shared library, do not create duplicate permutations, update run.sh
This commit is contained in:
parent
d7627a9294
commit
bb9cebab81
3 changed files with 22 additions and 12 deletions
|
@ -9,6 +9,10 @@ import tempfile
|
||||||
import os
|
import os
|
||||||
import zlib
|
import zlib
|
||||||
import fcntl
|
import fcntl
|
||||||
|
import ctypes
|
||||||
|
|
||||||
|
libpallet = ctypes.cdll.LoadLibrary('./libpallet.so.0.0.0')
|
||||||
|
libpallet.evaluate.restype = ctypes.c_double
|
||||||
|
|
||||||
def evaluate_layers_rests(layers, rests, scores, pallet, result_max):
|
def evaluate_layers_rests(layers, rests, scores, pallet, result_max):
|
||||||
rest_layers = list()
|
rest_layers = list()
|
||||||
|
@ -56,22 +60,23 @@ def evaluate_layers_rests(layers, rests, scores, pallet, result_max):
|
||||||
dicttoxmlfile(packlist, tmp)
|
dicttoxmlfile(packlist, tmp)
|
||||||
|
|
||||||
# ugly, ugly, ugly, ugly hack - dont copy this...
|
# ugly, ugly, ugly, ugly hack - dont copy this...
|
||||||
score = float(subprocess.check_output(sys.argv[3]+" -o "
|
#score = float(subprocess.check_output(sys.argv[3]+" -o "
|
||||||
+sys.argv[1]+" -p "+tmp
|
# +sys.argv[1]+" -p "+tmp
|
||||||
+" -s "+sys.argv[4]+" --headless | grep Score", shell=True).split(' ')[1].strip())
|
# +" -s "+sys.argv[4]+" --headless | grep Score", shell=True).split(' ')[1].strip())
|
||||||
|
score = libpallet.evaluate(sys.argv[1], tmp, sys.argv[3])
|
||||||
if score >= max(scores+[0]):
|
if score >= max(scores+[0]):
|
||||||
result_max[0] = dicttoxmlstring(packlist)
|
result_max[0] = dicttoxmlstring(packlist)
|
||||||
os.remove(tmp)
|
os.remove(tmp)
|
||||||
scores.append(score)
|
scores.append(score)
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
if len(sys.argv) < 6:
|
if len(sys.argv) < 5:
|
||||||
print "usage:", sys.argv[0], "order.xml packlist.xml palletViewer scoring.xml LAYER [LAYER..]"
|
print "usage:", sys.argv[0], "order.xml packlist.xml scoring.xml LAYER [LAYER..]"
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
scores = list()
|
scores = list()
|
||||||
result_max = [None]
|
result_max = [None]
|
||||||
for arg in sys.argv[5:]:
|
for arg in sys.argv[4:]:
|
||||||
layers, rests, pallet = cPickle.loads(zlib.decompress(a2b_base64(arg)))
|
layers, rests, pallet = cPickle.loads(zlib.decompress(a2b_base64(arg)))
|
||||||
evaluate_layers_rests(layers, rests, scores, pallet, result_max)
|
evaluate_layers_rests(layers, rests, scores, pallet, result_max)
|
||||||
|
|
||||||
|
|
15
run.sh
15
run.sh
|
@ -1,11 +1,14 @@
|
||||||
#!/bin/sh -ex
|
#!/bin/sh -ex
|
||||||
|
|
||||||
|
if [ $# -ne 3 ]; then
|
||||||
|
echo usage: $0 order.xml packlist.xml scoring.xml
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
rm -f score_max
|
rm -f score_max
|
||||||
|
|
||||||
VIEWER=../palletandtruckviewer-3.0/palletViewer
|
python bruteforce2.py $1 | xargs --max-procs=4 python bruteforce3.py $1 $2 $3
|
||||||
SCORING=../icra2011TestFiles/scoreAsPlannedConfig1.xml
|
|
||||||
|
|
||||||
python bruteforce2.py $1 \
|
echo palletViewer -o $1 -p $2 -s $3
|
||||||
| sort\
|
|
||||||
| uniq\
|
echo python evaluate.py $1 $2 $3
|
||||||
| xargs --max-procs=4 python bruteforce3.py $1 packlist.xml $VIEWER $SCORING
|
|
||||||
|
|
2
util.py
2
util.py
|
@ -126,6 +126,8 @@ def product_varlength(branch_factor):
|
||||||
for val in range(branch_factor)]
|
for val in range(branch_factor)]
|
||||||
current = current["children"][0]
|
current = current["children"][0]
|
||||||
if (yield current["value"]):
|
if (yield current["value"]):
|
||||||
|
current["parent"]["children"] = [] # only for the icra 2012
|
||||||
|
current = current["parent"] # bruteforce implementation
|
||||||
while True:
|
while True:
|
||||||
if current["parent"]:
|
if current["parent"]:
|
||||||
current["parent"]["children"].pop(0)
|
current["parent"]["children"].pop(0)
|
||||||
|
|
Loading…
Reference in a new issue