view release on metacpan or search on metacpan
}
if (ctx->thresh.max >= 0) {
struct LK *lk;
if (GIMME_V == G_ARRAY) {
SV **start, **end;
XSprePUSH;
start = SP+1;
for (lk = ctx->links.arr[ctx->thresh.max]; lk; lk = lk->link) {
AV *arr;
/* only count transitions */
if (lk->link && lk->link->i == lk->i)
continue;
av_push(arr, newSViv(lk->j));
XPUSHs(sv_2mortal(newRV_noinc((SV *)arr)));
}
/* reverse the stack */
end = SP;
while (start < end) {
SV *tmp = *start;
*start++ = *end;
*end-- = tmp;
}
}
else {
j = 0;
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Spiffy.pm view on Meta::CPAN
my $used = {};
$bases_map->{$class} = [grep {not $used->{$_}++} @bases];
}
my %code = (
sub_start =>
"sub {\n",
set_default =>
" \$_[0]->{%s} = %s\n unless exists \$_[0]->{%s};\n",
init =>
" return \$_[0]->{%s} = do { my \$self = \$_[0]; %s }\n" .
inc/Spiffy.pm view on Meta::CPAN
? '[]'
: (ref($default) eq 'HASH' and not keys %$default )
? '{}'
: default_as_code($default);
my $code = $code{sub_start};
if ($args->{-init}) {
my $fragment = $args->{-weak} ? $code{weak_init} : $code{init};
$code .= sprintf $fragment, $field, $args->{-init}, ($field) x 4;
}
$code .= sprintf $code{set_default}, $field, $default_string, $field
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/DistanceMatrix.pm view on Meta::CPAN
my $distances = [];
for (my $i = 0; $i < $n; $i++) {
# This initialization is required to prevent 'undef' at [0,0],
$distances->[$i] ||= [];
# Diagonal or full matrix?
my $start = $self->mode =~ /full/i ? 0 : $i+1;
for (my $j = $start; $j < $n; $j++) {
# Use a pointer, then determine if it's row-major or col-major order
# Swap i and j if lower diagonal (default)
my $ref = $self->mode =~ /lower/i ?
\$distances->[$j][$i] : \$distances->[$i][$j];
# Callback function provides the distance
view all matches for this distribution
view release on metacpan or search on metacpan
third parties under the terms of this General Public License (except
that you may choose to grant warranty protection to some or all
third parties, at your option).
c) If the modified program normally reads commands interactively when
run, you must cause it, when started running for such interactive use
in the simplest and most usual way, to print or display an
announcement including an appropriate copyright notice and a notice
that there is no warranty (or else, saying that you provide a
warranty) and that users may redistribute the program under these
conditions, and telling the user how to view a copy of this General
possible use to humanity, the best way to achieve this is to make it
free software which everyone can redistribute and change under these
terms.
To do so, attach the following notices to the program. It is safest to
attach them to the start of each source file to most effectively convey
the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) 19yy <name of author>
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) 19xx name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
view all matches for this distribution
view release on metacpan or search on metacpan
third parties under the terms of this General Public License (except
that you may choose to grant warranty protection to some or all
third parties, at your option).
c) If the modified program normally reads commands interactively when
run, you must cause it, when started running for such interactive use
in the simplest and most usual way, to print or display an
announcement including an appropriate copyright notice and a notice
that there is no warranty (or else, saying that you provide a
warranty) and that users may redistribute the program under these
conditions, and telling the user how to view a copy of this General
possible use to humanity, the best way to achieve this is to make it
free software which everyone can redistribute and change under these
terms.
To do so, attach the following notices to the program. It is safest to
attach them to the start of each source file to most effectively convey
the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) 19yy <name of author>
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) 19xx name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
view all matches for this distribution
view release on metacpan or search on metacpan
2009-07-26 <jmerelo@localhost.localdomain>
* lib/Algorithm/Evolutionary.pm (import): 0.69_1 fixed some
problems with missing prerrequisites in the test programs, and
some copy/paste stuff left from creating new modules. 0.70 starts
with the intention of finally having a GUI.
2009-07-24 <jmerelo@localhost.localdomain>
* lib/Algorithm/Evolutionary.pm: 0.68 was shortlived, but 0.69
more or less the same. 0.69 included missing file and fixed some
docs errors; 0.69_1 starts with the same objective, let's see how
it ends.
2009-07-24 Juan Julian Merelo Guervos <jmerelo@geneura.ugr.es>
* TODO: 0.68 ends with several new test functions added (Trap,
ECC), and finally a multiobjective evolutionary algorithm, not
very good, but in working order.
2009-03-29 <jmerelo@localhost.localdomain>
* lib/Algorithm/Evolutionary.pm: 0.68 starts with the usual
cosmetic changes to the documentation.
* Added "rough consensus" utility as well as a "convergence
terminator", which checks whether a part of the population has
converged. Upgraded to 0.67. Already!
view all matches for this distribution
view release on metacpan or search on metacpan
2009-07-26 <jmerelo@localhost.localdomain>
* lib/Algorithm/Evolutionary.pm (import): 0.69_1 fixed some
problems with missing prerrequisites in the test programs, and
some copy/paste stuff left from creating new modules. 0.70 starts
with the intention of finally having a GUI.
2009-07-24 <jmerelo@localhost.localdomain>
* lib/Algorithm/Evolutionary.pm: 0.68 was shortlived, but 0.69
more or less the same. 0.69 included missing file and fixed some
docs errors; 0.69_1 starts with the same objective, let's see how
it ends.
2009-07-24 Juan Julian Merelo Guervos <jmerelo@geneura.ugr.es>
* TODO: 0.68 ends with several new test functions added (Trap,
ECC), and finally a multiobjective evolutionary algorithm, not
very good, but in working order.
2009-03-29 <jmerelo@localhost.localdomain>
* lib/Algorithm/Evolutionary.pm: 0.68 starts with the usual
cosmetic changes to the documentation.
* Added "rough consensus" utility as well as a "convergence
terminator", which checks whether a part of the population has
converged. Upgraded to 0.67. Already!
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/Evolutionary/Individual/Bit_Vector.pm view on Meta::CPAN
}
=head2 Atom
Sets or gets the value of the n-th character in the string. Counting
starts at 0, as usual in Perl arrays.
=cut
sub Atom: lvalue {
my $self = shift;
view all matches for this distribution
view release on metacpan or search on metacpan
examples/breeding_perls.pl view on Meta::CPAN
selection => 'roulette',
replacement => 'rank',
parents_per_gen => 2,
size => 200,
callback => \&callback,
)->start;
sub callback {
my $p = shift;
if ($p->best_fit->fitness == $TARGET) {
view all matches for this distribution
view release on metacpan or search on metacpan
examples/cleanup_directory.pl view on Meta::CPAN
# There should be no need to call this script ordinarily.
# When the Algorithm::KMeans module creates new cluster files,
# it automatically delete all previously created such files.
# Such files are named ClusterX.dat for X starting with X = 0.
# The files __temp_* are created by the visualization script.
# However, when the program terminates properly, it should
# automatically delete those files.
view all matches for this distribution
view release on metacpan or search on metacpan
c[i] = 0 ;
p[i] = src[j] ; /* p[i] */
}
/*
* construct coeffs. recursively. We know c[k] = 1 (implicit)
* and start P_0 = x - p_0, then at each stage multiply by
* x - p_i generating P_i = x P_{i-1} - p_i P_{i-1}
* After k steps we are done.
*/
c[k-1] = p[0] ; /* really -p(0), but x = -x in GF(2^m) */
for (i = 1 ; i < k ; i++ ) {
fec_initialized = 1 ;
}
/*
* This section contains the proper FEC encoding/decoding routines.
* The encoding matrix is computed starting with a Vandermonde matrix,
* and then transforming it into a systematic matrix.
*/
struct fec_parms {
int k, n ; /* parameters of the code */
retval->k = k ;
retval->n = n ;
retval->enc_matrix = NEW_GF_MATRIX(n, k);
tmp_m = NEW_GF_MATRIX(n, k);
/*
* fill the matrix with powers of field elements, starting from 0.
* The first row is special, cannot be computed with exp. table.
*/
tmp_m[0] = 1 ;
for (col = 1; col < k ; col++)
tmp_m[col] = 0 ;
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Test/More.pm view on Meta::CPAN
}
sub _is_module_name {
my $module = shift;
# Module names start with a letter.
# End with an alphanumeric.
# The rest is an alphanumeric or ::
$module =~ s/\b::\b//g;
return $module =~ /^[a-zA-Z]\w*$/ ? 1 : 0;
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Module/AutoInstall.pm view on Meta::CPAN
my $makeflags = $CPAN::Config->{make_install_arg} || '';
$CPAN::Config->{make_install_arg} =
join( ' ', split( ' ', $makeflags ), 'UNINST=1' )
if ( $makeflags !~ /\bUNINST\b/ and eval qq{ $> eq '0' } );
# don't show start-up info
$CPAN::Config->{inhibit_startup_message} = 1;
# set additional options
while ( my ( $opt, $arg ) = splice( @config, 0, 2 ) ) {
( $args{$opt} = $arg, next )
if $opt =~ /^force$/; # pseudo-option
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/Functional/BFS.pm view on Meta::CPAN
my $bfs = Algorithm::Functional::BFS->new
(
adjacent_nodes_func => $some_func,
victory_func => $some_other_func,
);
# Get a list (ref) of all the routes from your start node to the node(s)
# that satisfy the victory condition.
my $routes_ref = $bfs->search($start_node);
=head1 METHODS
=cut
lib/Algorithm/Functional/BFS.pm view on Meta::CPAN
evaluates to true if and only if the node satisfies the victory condition
of this search.
Optional parameters:
include_start_node:
If this is a true value, then the start node is a candidate for the
victory condition. That is, if the start node matches the victory
condition, then a single route will be returned by the search algorithm,
and that route will contain only the start node.
one_result:
If this is a true value, then the search stops after a single route is
found, instead of searching for all the routes that satisfy the victory
condition at the depth of the first route.
lib/Algorithm/Functional/BFS.pm view on Meta::CPAN
my %self =
(
adjacent_nodes_func => $opts{adjacent_nodes_func},
victory_func => $opts{victory_func},
include_start_node => $opts{include_start_node},
one_result => $opts{one_result},
);
bless(\%self, $class);
}
=head2 search($start_node)
Perform a breadth-first-search from the specified node until the depth at
which at least one node satisfies the victory condition.
Returns an array ref of routes. Each route is an array ref of the nodes
that are along the route from the start node to the node at which the
victory condition was satisfied. Because this implementation works on
cyclic graphs, multiple routes may be returned (and, indeed, multiple
nodes at the same depth level may satisfy the victory condition). If the
"one_result" option was passed to the constructor, then only one route
will be returned, but it will still be encapsulated in another array ref.
=cut
sub search
{
my ($self, $start_node) = @_;
confess 'Start node must be defined' unless $start_node;
# Short circuit if the start node matches the victory condition.
return [ [ $start_node ] ] if
$self->{include_start_node} && $self->{victory_func}->($start_node);
# Quick-to-read list of nodes we've already seen.
my %seen = ( $start_node => 1 );
# All the routes we've taken so far that are still valid. This list
# is used more-or-less like a queue.
my @candidates = ( [ $start_node ] );
# The final route list result.
my @results;
# Iterate until we have results or no candidates are left.
view all matches for this distribution