Exemple #1
0
def plain_sieve():
    """
    Run a a plain sieve in the full dimension directly.
    """
    description = plain_sieve.__doc__

    args, all_params = parse_args(description,)

    stats = run_all(plain_sieve_kernel, list(all_params.values()),
                    lower_bound=args.lower_bound,
                    upper_bound=args.upper_bound,
                    step_size=args.step_size,
                    trials=args.trials,
                    workers=args.workers,
                    seed=args.seed)

    inverse_all_params = OrderedDict([(v, k) for (k, v) in six.iteritems(all_params)])

    inverse_all_params = OrderedDict([(v, k) for (k, v) in six.iteritems(all_params)])
    stats = sanitize_params_names(stats, inverse_all_params)

    fmt = "{name:50s} :: n: {n:2d}, cputime {cputime:7.4f}s, walltime: {walltime:7.4f}s, |db|: 2^{avg_max:.2f}"
    profiles = print_stats(fmt, stats, ("cputime", "walltime", "avg_max"),
                           extractf={"avg_max": lambda n, params, stat: db_stats(stat)[0]})

    output_profiles(args.profile, profiles)

    if args.pickle:
        pickler.dump(stats, open("plain-sieve-%d-%d-%d-%d.sobj" %
                                 (args.lower_bound, args.upper_bound, args.step_size, args.trials), "wb"))
Exemple #2
0
def bkz_tour():
    """
    Run bkz tours.

    ..  note :: that by default no information is printed.
        To enable set ``--dummy-tracer False`` and ``--verbose``.

    """
    description = bkz_tour.__doc__

    args, all_params = parse_args(
        description,
        bkz__alg="pump_and_jump",
        bkz__blocksizes="40:51:2",
        bkz__pre_blocksize=39,
        bkz__tours=1,
        bkz__extra_dim4free=0,
        bkz__jump=1,
        bkz__dim4free_fun="default_dim4free_fun",
        slide__overlap=1,
        pump__down_sieve=True,
        challenge_seed=0,
        dummy_tracer=False,  # set to control memory
        verbose=False)

    stats = run_all(bkz_kernel,
                    list(all_params.values()),
                    lower_bound=args.lower_bound,
                    upper_bound=args.upper_bound,
                    step_size=args.step_size,
                    trials=args.trials,
                    workers=args.workers,
                    seed=args.seed)

    inverse_all_params = OrderedDict([(v, k)
                                      for (k, v) in six.iteritems(all_params)])
    stats = sanitize_params_names(stats, inverse_all_params)

    fmt = "{name:50s} :: n: {n:2d}, cputime {cputime:7.4f}s, walltime: {walltime:7.4f}s, slope: {slope:1.5f}, |db|: 2^{avg_max:.2f}"
    profiles = print_stats(fmt,
                           stats, ("cputime", "walltime", "slope", "avg_max"),
                           extractf={
                               "avg_max":
                               lambda n, params, stat: db_stats(stat)[0]
                           })

    output_profiles(args.profile, profiles)

    if args.pickle:
        pickler.dump(
            stats,
            open(
                "bkz-%d-%d-%d-%d.sobj" % (args.lower_bound, args.upper_bound,
                                          args.step_size, args.trials), "wb"))
Exemple #3
0
def asvp():
    """
    Run a Workout until 1.05-approx-SVP on matrices with dimensions in ``range(lower_bound, upper_bound, step_size)``.
    """
    description = asvp.__doc__

    args, all_params = parse_args(
        description,
        load_matrix=None,
        verbose=True,
        challenge_seed=0,
        workout__dim4free_dec=3,
    )

    stats = run_all(
        asvp_kernel,
        list(all_params.values()),
        lower_bound=args.lower_bound,
        upper_bound=args.upper_bound,
        step_size=args.step_size,
        trials=args.trials,
        workers=args.workers,
        seed=args.seed,
    )

    inverse_all_params = OrderedDict([(v, k)
                                      for (k, v) in six.iteritems(all_params)])
    stats = sanitize_params_names(stats, inverse_all_params)

    fmt = "{name:50s} :: n: {n:2d}, cputime {cputime:7.4f}s, walltime: {walltime:7.4f}s, flast: {flast:3.2f}, |db|: 2^{avg_max:.2f}"
    profiles = print_stats(
        fmt,
        stats,
        ("cputime", "walltime", "flast", "avg_max"),
        extractf={
            "avg_max": lambda n, params, stat: db_stats(stat)[0]
        },
    )

    output_profiles(args.profile, profiles)

    if args.pickle:
        pickler.dump(
            stats,
            open(
                "svp-challenge-%d-%d-%d-%d.sobj" %
                (args.lower_bound, args.upper_bound, args.step_size,
                 args.trials),
                "wb",
            ),
        )
Exemple #4
0
def svp():
    """
    Run a progressive until exact-SVP is solved.

    The exact-SVP length must have been priorly determined using ./svp_exact_find_norm.py

    """
    description = svp.__doc__

    args, all_params = parse_args(description,
                                  challenge_seed=0,
                                  svp__alg="workout")

    stats = run_all(
        svp_kernel,
        list(all_params.values()),
        lower_bound=args.lower_bound,
        upper_bound=args.upper_bound,
        step_size=args.step_size,
        trials=args.trials,
        workers=args.workers,
        seed=args.seed,
    )

    inverse_all_params = OrderedDict([(v, k)
                                      for (k, v) in six.iteritems(all_params)])
    stats = sanitize_params_names(stats, inverse_all_params)

    fmt = "{name:50s} :: n: {n:2d}, cputime {cputime:7.4f}s, walltime: {walltime:7.4f}s, flast: {flast:3.2f}, |db|: 2^{avg_max:.2f}"
    profiles = print_stats(
        fmt,
        stats,
        ("cputime", "walltime", "flast", "avg_max"),
        extractf={
            "avg_max": lambda n, params, stat: db_stats(stat)[0]
        },
    )

    output_profiles(args.profile, profiles)

    if args.pickle:
        pickler.dump(
            stats,
            open(
                "svp-exact-%d-%d-%d-%d.sobj" %
                (args.lower_bound, args.upper_bound, args.step_size,
                 args.trials),
                "wb",
            ),
        )
Exemple #5
0
def full_sieve():
    """
    Run a a full sieve (with some partial sieve as precomputation).
    """
    description = full_sieve.__doc__

    args, all_params = parse_args(description, challenge_seed=0)

    stats = run_all(
        full_sieve_kernel,
        list(all_params.values()),
        lower_bound=args.lower_bound,
        upper_bound=args.upper_bound,
        step_size=args.step_size,
        trials=args.trials,
        workers=args.workers,
        seed=args.seed,
    )

    inverse_all_params = OrderedDict([(v, k)
                                      for (k, v) in six.iteritems(all_params)])
    stats = sanitize_params_names(stats, inverse_all_params)

    fmt = "{name:50s} :: n: {n:2d}, cputime {cputime:7.4f}s, walltime: {walltime:7.4f}s, |db|: 2^{avg_max:.2f}"
    profiles = print_stats(
        fmt,
        stats,
        ("cputime", "walltime", "avg_max"),
        extractf={
            "avg_max": lambda n, params, stat: db_stats(stat)[0]
        },
    )

    output_profiles(args.profile, profiles)

    if args.pickle:
        pickler.dump(
            stats,
            open(
                "full-sieve-%d-%d-%d-%d.sobj" %
                (args.lower_bound, args.upper_bound, args.step_size,
                 args.trials),
                "wb",
            ),
        )
Exemple #6
0
def hkz():
    """
    Attempt HKZ reduction. 
    """
    description = hkz.__doc__

    args, all_params = parse_args(description,
                                  challenge_seed=0,
                                  pump__down_sieve=True,
                                  pump__down_stop=9999,
                                  saturation_ratio=.8,
                                  pump__prefer_left_insert=10,
                                  workout__dim4free_min=0,
                                  workout__dim4free_dec=15)

    stats = run_all(hkz_kernel,
                    list(all_params.values()),
                    lower_bound=args.lower_bound,
                    upper_bound=args.upper_bound,
                    step_size=args.step_size,
                    trials=args.trials,
                    workers=args.workers,
                    seed=args.seed)

    inverse_all_params = OrderedDict([(v, k)
                                      for (k, v) in six.iteritems(all_params)])
    stats = sanitize_params_names(stats, inverse_all_params)

    fmt = "{name:50s} :: n: {n:2d}, cputime {cputime:7.4f}s, walltime: {walltime:7.4f}s, |db|: 2^{avg_max:.2f}"
    profiles = print_stats(fmt,
                           stats, ("cputime", "walltime", "avg_max"),
                           extractf={
                               "avg_max":
                               lambda n, params, stat: db_stats(stat)[0]
                           })

    output_profiles(args.profile, profiles)

    if args.pickle:
        pickler.dump(
            stats,
            open(
                "hkz-%d-%d-%d-%d.sobj" % (args.lower_bound, args.upper_bound,
                                          args.step_size, args.trials), "wb"))