The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

AI::Pathfinding::OptimizeMultiple - optimize path finding searches for a large set of initial conditions (for better average performance).

VERSION

version 0.0.17

SYNOPSIS

    use AI::Pathfinding::OptimizeMultiple

    my @scans =
    (
        {
            name => "first_search"
        },
        {
            name => "second_search",
        },
        {
            name => "third_search",
        },
    );

    my $obj = AI::Pathfinding::OptimizeMultiple->new(
        {
            scans => \@scans,
            num_boards => 32_000,
            optimize_for => 'speed',
            scans_iters_pdls =>
            {
                first_search => $first_search_pdl,
                second_search => $second_search_pdl,
            },
            quotas => [400, 300, 200],
            selected_scans =>
            [
                AI::Pathfinding::OptimizeMultiple::Scan->new(
                    id => 'first_search',
                    cmd_line => "--preset first_search",
                ),
                AI::Pathfinding::OptimizeMultiple::Scan->new(
                    id => 'second_search',
                    cmd_line => "--preset second_search",
                ),
                AI::Pathfinding::OptimizeMultiple::Scan->new(
                    id => 'third_search',
                    cmd_line => "--preset third_search",
                ),
            ],
        }
    );

    $obj->calc_meta_scan();

    foreach my $scan_alloc (@{$self->chosen_scans()})
    {
        printf "Run %s for %d iterations.\n",
            $scans[$scan_alloc->scan_idx], $scan_alloc->iters;
    }

DESCRIPTION

This CPAN distribution implements the algorithm described here:

Given statistics on the performance of several game AI searches (or scans) across a representative number of initial cases, find a scan that solves most deals with close-to-optimal performance, by using switch tasking.

SUBROUTINES/METHODS

my $chosen_scans_array_ref = $self->chosen_scans()

Returns the scans that have been chosen to perform the iteration. Each one is a AI::Pathfinding::OptimizeMultiple::ScanRun object.

$calc_meta_scan->calc_meta_scan()

Calculates the meta-scan after initialisation. See here for the details of the algorithm:

http://www.shlomifish.org/lecture/Freecell-Solver/The-Next-Pres/slides/multi-tasking/best-meta-scan/

$self->calc_flares_meta_scan()

This function calculates the flares meta-scan: i.e: assuming that all atomic scans are run one after the other and the shortest solutions of all successful scans are being picked.

$calc_meta_scan->calc_board_iters($board_idx)

Calculates the iterations of the board $board_idx in all the scans.

Returns a hash_ref containing the key 'per_scan_iters' for the iterations per scan, and 'board_iters' for the total board iterations when ran in the scans.

my $status = $calc_meta_scan->get_final_status()

Returns the status as string:

  • "solved_all"

  • "iterating"

  • "out_of_quotas"

my $sim_results_obj = $calc_meta_scan->simulate_board($board_idx, $args)

Simulates the board No $board_idx through the scan. Returns a AI::Pathfinding::OptimizeMultiple::SimulationResults object.

$args is an optional hash reference. It may contain a value with the key of 'chosen_scans' that may specify an alternative scans to traverse.

my $n = $calc_meta_scan->get_total_iters()

Returns the total iterations count so far.

BUILD()

Moo leftover. INTERNAL USE.

SEE ALSO

AUTHOR

Shlomi Fish, http://www.shlomifish.org/ .

ACKNOWLEDGEMENTS

popl from Freenode's #perl for trying to dig some references to an existing algorithm in the scientific literature.

SUPPORT

Websites

The following websites have more information about this module, and may be of help to you. As always, in addition to those websites please use your favorite search engine to discover more resources.

Bugs / Feature Requests

Please report any bugs or feature requests by email to bug-ai-pathfinding-optimizemultiple at rt.cpan.org, or through the web interface at https://rt.cpan.org/Public/Bug/Report.html?Queue=AI-Pathfinding-OptimizeMultiple. You will be automatically notified of any progress on the request by the system.

Source Code

The code is open to the world, and available for you to hack on. Please feel free to browse it and play with it, or whatever. If you want to contribute patches, please send me a diff or prod me to pull from your repository :)

http://github.com/shlomif/fc-solve

  git clone ssh://git@github.com/shlomif/fc-solve.git

AUTHOR

Shlomi Fish <shlomif@cpan.org>

BUGS

Please report any bugs or feature requests on the bugtracker website https://github.com/shlomif/fc-solve/issues

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.

COPYRIGHT AND LICENSE

This software is Copyright (c) 2012 by Shlomi Fish.

This is free software, licensed under:

  The MIT (X11) License