Beispiel #1
0
 def fitness_e(particle):
     if not args.nerror:
         return -float('inf')
     globals()['Ftimes'] += args.nerror
     for i in range(len(args.cameras)):
         x, h, d, beta = particle[4 * i: 4 * (i + 1)]
         if d < lut[i].bounds[0] or d > lut[i].bounds[1]:
             return -float('inf')
         modify_camera(ex.model, args.cameras[i][0], lut[i],
             x, h, d, beta)
     original_pose = {}
     for obj in [ex.tasks[args.task].mount.name] + [c[0] for c in args.cameras]:
         original_pose[obj] = ex.model[obj].pose
     perf = []
     for i in range(args.nerror):
         for obj in original_pose:
             if obj in ex.model.cameras:
                 ex.model[obj].set_absolute_pose(gaussian_yz_pose_error(original_pose[obj], *args.cerror))
             else:
                 ex.model[obj].set_absolute_pose(gaussian_pose_error(original_pose[obj], *args.terror))
         coverage = ex.model.range_coverage(ex.tasks[args.task], transport)
         perf.append(ex.model.performance(ex.tasks[args.task], coverage=coverage))
     for obj in original_pose:
         ex.model[obj].set_absolute_pose(original_pose[obj])
     return sum(perf) / float(args.nerror)
Beispiel #2
0
if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument('-C', '--cerror', dest='cerror', type=float,
        nargs=2, default=(0.0, 0.0))
    parser.add_argument('-T', '--terror', dest='terror', type=float,
        nargs=2, default=(0.0, 0.0))
    parser.add_argument('-n', '--number', dest='number', type=int, default=1)
    parser.add_argument('datafile')
    args = parser.parse_args()

    result = pickle.load(open(args.datafile, 'r'))
    ex, lut = load_model(result['args'].modelfile, result['args'].cameras, result['args'].fnumber)

    for c, camera in enumerate(result['args'].cameras):
        modify_camera(ex.model, camera[0], lut[c], *(result['best'][4 * c: 4 * (c + 1)]))

    original_pose = {}
    for obj in [ex.tasks[result['args'].task].mount.name] + [c[0] for c in result['args'].cameras]:
        original_pose[obj] = ex.model[obj].pose
    perf = []
    for i in range(args.number):
        for obj in original_pose:
            if obj in ex.model.cameras:
                ex.model[obj].set_absolute_pose(gaussian_yz_pose_error(original_pose[obj], *args.cerror))
            else:
                ex.model[obj].set_absolute_pose(gaussian_pose_error(original_pose[obj], *args.terror))
        coverage = ex.model.range_coverage(ex.tasks[result['args'].task], RangeModel.LinearTargetTransport)
        perf.append(ex.model.performance(ex.tasks[result['args'].task], coverage=coverage))
    print('Nominal Performance: %g' % result['F'][-1])
    print('Average Performance: %g' % (sum(perf) / float(len(perf))))