############################################################ # # file: filter.pl # # # # sub filter_connector # # Looks through the set of connections that have been made to the # connector and throws out duplicates (keeping the one with the highest # weight) and those that do not have a weight higher than $CONNECTION_MIN. # # sub filter_connector { local($connector, $layer, $column) = @_; local($con) = $net{$connector, $layer, $column}; chop $con; local(@connections) = split(/:/,$con);# The list of connections + weight local(%w) = (); local($i); local(@wset, $elem); # Look through each connection. for($i = 0; $i <$#connections; $i+=2) { if($parms{"d"} & $CONNECTION_FILTER && 0) { print "Checking connection from " . $connections[$i] . " to -$layer.$column.$connector- (" . $connections[$i+1].").\n"; }; # Check connection strength if(&Abs($connections[$i+1]) > $CONNECTION_MIN) { # Check against connections that have # already been scanned. Makes use of the # fact that non-existant elements in and # associative array will evaluate to 0. if(&Abs($connections[$i+1]) > &Abs($w{$connections[$i]})) { $w{$connections[$i]} = $connections[$i+1]; } elsif($parms{"d"} & $CONNECTION_FILTER) { print "Filtered out connection from " . $connections[$i] . " to -$layer.$column.$connector- because it was a duplicate (" . $connections[$i+1]. " < " . $w{$connections[$i]} . ").\n"; }; } elsif($parms{"d"} & $CONNECTION_FILTER) { print "Filtered out connection from " . $connections[$i] . " to -$layer.$column.$connector- because it was too small (" . $connections[$i+1].").\n"; }; }; # Scan the set of remaining connections (%w) # and rebuild the connection list. @wset = sort(keys %w); $net{$connector, $layer, $column} = ""; foreach $elem (@wset) { $net{$connector, $layer, $column} .= $elem . ":" . $w{$elem} . ":"; } }; # # sub filter_connections # # Scan through each column and filter out redundant connections # and connections that are too small. # sub filter_connections { local($layer); local($i); foreach $layer (@LAYERS) { for($i = 0; $i < $net{"num", $layer}; ++$i) { &filter_connector("sensory connector", $layer, $i); &filter_connector("priming connector", $layer, $i); &filter_connector("support connector", $layer, $i); } }; }; 1;