AI-SimulatedAnnealing
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
t/annealing_tests.t view on Meta::CPAN
given ($exception->get_type()) {
when ($Text::BSV::Exception::FILE_NOT_FOUND) {
say STDERR "$DQ$bsv_file_path$DQ is not a valid file path.";
exit(1);
}
when ($Text::BSV::Exception::IO_ERROR) {
say STDERR "Couldn't open $DQ$bsv_file_path$DQ for reading.";
exit(1);
}
when ($Text::BSV::Exception::INVALID_DATA_FORMAT) {
say STDERR "Invalid BSV data: " . $exception->get_message();
exit(1);
}
default {
say STDERR $exception->get_message();
exit(1);
} # end when
} # end given
} # end if
# Generate a list of distances for each probability from the data in the
# BSV file:
my $field_names = $bsv_file_reader->get_field_names();
my @mapped_distances; # indexes 2-5 = Probability constants;
# values = references to number arrays
for my $p (2..5) {
$mapped_distances[$p] = [];
} # next $p
unless ($field_names->[0] eq "Time"
&& $field_names->[1] =~ /$Probability::ONE_FIFTH\z/s
&& $field_names->[2] =~ /$Probability::ONE_FOURTH\z/s
&& $field_names->[3] =~ /$Probability::ONE_THIRD\z/s
&& $field_names->[4] =~ /$Probability::ONE_HALF\z/s) {
die "ERROR: The input file does not contain market-distance data in "
. "the expected format.\n";
} # end unless
while ($bsv_file_reader->has_next()) {
my $record;
my $dex;
eval {
$record = $bsv_file_reader->get_record();
};
if ($EVAL_ERROR) {
given ($EVAL_ERROR->get_type()) {
when ($Text::BSV::Exception::INVALID_DATA_FORMAT) {
die "ERROR: Invalid BSV data: "
. $EVAL_ERROR->get_message() . $LF;
}
default {
die "ERROR: " . $EVAL_ERROR->get_message() . $LF;
} # end when
} # end given
} # end if
$dex = $record->{"Time"} - 3;
unless ($dex >= 0
&& $dex <= scalar($mapped_distances[$Probability::ONE_FIFTH])) {
die "ERROR: The input file does not contain market-distance data "
. "in the expected format.\n";
} # end unless
for my $p (2..5) {
push @{ $mapped_distances[$p] }, $record->{$field_names->[6 - $p]};
} # next $p
} # end while
unless (scalar @{ $mapped_distances[$Probability::ONE_FIFTH] } == 61) {
die "ERROR: The input file does not contain the expected number of "
view all matches for this distributionview release on metacpan - search on metacpan
( run in 0.974 second using v1.00-cache-2.02-grep-82fe00e-cpan-4673cadbf75 )