AI-Pathfinding-OptimizeMultiple

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

        - http://www.cpantesters.org/cpan/report/f631b3e2-03b5-11e6-b1a3-5205ef11d1c8
        - Thanks also to the example code in
        https://metacpan.org/pod/Exception::Class .
    - Add Test::Kwalitee::Extra.

v0.0.12     2015-03-26
    - Add the stats_factors option to the
    lib/AI/Pathfinding/OptimizeMultiple.pm constructor.
        - Contains some factors to normalise the iters of specific scans.
    - Add the --stats-factors option to ::CmdLine.
    - Allow to customise the --total-iterations-limit using
    $ENV{FC_SOLVE_RANGE_ITERS_LIMIT} .

v0.0.11     2014-03-29
    - Move the external-deps-using release tests to xt/ instead of t/
        - Better Kwalitee.
        - Thanks to "ether" on #distzilla for the insights on fixing it.

v0.0.10     2014-03-28
    - Convert to the Test::CPAN::Changes Dist-Zilla plugin.

lib/AI/Pathfinding/OptimizeMultiple.pm  view on Meta::CPAN


    my $UNSOLVED_NUM_MOVES_CONSTANT = 64 * 1024 * 1024;

    my $last_avg = $UNSOLVED_NUM_MOVES_CONSTANT;

FLARES_LOOP:
    while ( my $q_more = $self->_get_next_quota() )
    {
        $iters_quota += $q_more;

        # Next number of iterations for each scan x scan combination.
        my $next_num_iters = (
            ( $ones_constant x $flares_num_iters ) + (
                PDL::MatrixOps::identity( $self->_get_num_scans() ) *
                    $iters_quota
            )
        );

        # print "\$next_num_iters = $next_num_iters\n";

        my $iters = $self->_scans_data()->slice(":,:,0");

lib/AI/Pathfinding/OptimizeMultiple.pm  view on Meta::CPAN

                    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;
    }

=head1 DESCRIPTION

This CPAN distribution implements the algorithm described here:

=over 4

=item * L<https://groups.google.com/group/comp.ai.games/msg/41e899e9beea5583?dmode=source&output=gplain&noredirect>

lib/AI/Pathfinding/OptimizeMultiple.pm  view on Meta::CPAN

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

=head2 $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.

=head2 $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.

=head2 my $status = $calc_meta_scan->get_final_status()

Returns the status as string:

=over 4

=item * "solved_all"

lib/AI/Pathfinding/OptimizeMultiple.pm  view on Meta::CPAN

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

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

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

=head2 my $n = $calc_meta_scan->get_total_iters()

Returns the total iterations count so far.

=head2 BUILD()

Moo leftover. B<INTERNAL USE>.

=head1 SEE ALSO

=over 4

=item * L<Freecell Solver|http://fc-solve.shlomifish.org/>

lib/AI/Pathfinding/OptimizeMultiple/DataInputObj.pm  view on Meta::CPAN

        ? ( "--variant", $args->{'variant'} )
        : ()
    );

    return [
        qw(freecell-solver-fc-pro-range-solve),
        $min_board,
        $max_board,
        "20",
        @variant,
        '--total-iterations-limit',
        ( $ENV{FC_SOLVE_RANGE_ITERS_LIMIT} // 100000 ),
        '--binary-output-to',
        "data/$id.data.bin",
        @$argv,
        @fc_num,
    ];
}

sub time_scan
{

lib/AI/Pathfinding/OptimizeMultiple/IterState.pm  view on Meta::CPAN

        join( ",", ":", $self->_scan_idx(), ( ("(0)") x ( @dims - 2 ) ) ) );
}

sub update_total_iters
{
    my $state = shift;

    # $r is the result of this scan.
    my $r = $state->idx_slice();

    # Add the total iterations for all the states that were solved by
    # this scan.
    $state->_main()
        ->_add_to_total_iters(
        PDL::sum( ( ( $r <= $state->_quota() ) & ( $r > 0 ) ) * $r ) );

    # Find all the states that weren't solved.
    my $indexes = PDL::which( ( $r > $state->_quota() ) | ( $r < 0 ) );

    # Add the iterations for all the states that have not been solved
    # yet.
    $state->_main()
        ->_add_to_total_iters( $indexes->nelem() * $state->_quota() );

    # Keep only the states that have not been solved yet.
    $state->_main()
        ->_scans_data(
        $state->_main()->_scans_data()->dice( $indexes, "X" )->copy() );
}

lib/AI/Pathfinding/OptimizeMultiple/Scan.pm  view on Meta::CPAN

=head2 $self->mark_as_used()

Mark the scan as used.

=head2 $self->is_used()

Returns whether the scan was used.

=head2 $scan->data_file_path()

Returns the path to the data file of the scan, where the numbers of iterations
per board are stored.

=for :stopwords cpan testmatrix url bugtracker rt cpants kwalitee diff irc mailto metadata placeholders metacpan

=head1 SUPPORT

=head2 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.

lib/AI/Pathfinding/OptimizeMultiple/ScanRun.pm  view on Meta::CPAN


__END__

=pod

=encoding UTF-8

=head1 NAME

AI::Pathfinding::OptimizeMultiple::ScanRun - running scan_idx for certain
iterations.

=head1 VERSION

version 0.0.17

=head1 SYNOPSIS

    printf "Run %s for %d iterations.\n",
        $scans[$scan_alloc->scan_idx], $scan_alloc->iters;

=head1 DESCRIPTION

A class for scan iterations.

=head1 SLOTS

=head2 $scan_run->scan_idx()

The index of the scan (not the ID/name).

=head2 $scan_run->iters()

Number of iterations it ran.

=head1 METHODS

=head2 my $copy = $scan_run->clone()

Clones the scan.

=head1 SEE ALSO

L<AI::Pathfinding::OptimizeMultiple> .

lib/AI/Pathfinding/OptimizeMultiple/SimulationResults.pm  view on Meta::CPAN

A class for simulation results.

=head1 SUBROUTINES/METHODS

=head2 $scan_run->status()

The status.

=head2 $scan_run->total_iters()

The total iterations count so far.

=head2 my $aref = $self->scan_runs()

An array reference of L<AI::Pathfinding::OptimizeMultiple::ScanRun> .

=head2 $self->get_total_iters()

Returns the total iterations.

=head2 $self->get_status()

Returns the status.

=head1 SEE ALSO

L<AI::Pathfinding::OptimizeMultiple> , L<AI::Pathfinding::OptimizeMultiple::ScanRun> .

=head1 AUTHOR



( run in 1.450 second using v1.01-cache-2.11-cpan-71847e10f99 )