File Coverage

blib/lib/Sim/OPT/Takechance.pm
Criterion Covered Total %
statement 72 537 13.4
branch 0 86 0.0
condition n/a
subroutine 24 28 85.7
pod 0 3 0.0
total 96 654 14.6


line stmt bran cond sub pod time code
1             package Sim::OPT::Takechance;
2             # Copyright (C) 2014-2015 by Gian Luca Brunetti and Politecnico di Milano.
3             # This is "Sim::OPT::Takechance", a program that can produce efficient search structures for block coordinate descent given some initialization blocks (subspaces).
4             # Its strategy is based on making a search path more efficient than the average randomly chosen ones, by selecting the search moves
5             # so that (a) the search wake is fresher than the average random ones and (b) the search moves are more novel than the average random ones.
6             # The rationale for the selection of the seach path is explained in detail (with algorithms) in my paper at the following web address: http://arxiv.org/abs/1407.5615 .
7              
8 1     1   7 use v5.14;
  1         3  
  1         32  
9             # use v5.20;
10 1     1   3 use Exporter;
  1         2  
  1         42  
11 1     1   6 use parent 'Exporter'; # imports and subclasses Exporter
  1         2  
  1         8  
12              
13 1     1   68 use vars qw( $VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS );
  1         1  
  1         52  
14 1     1   4 use Math::Trig;
  1         1  
  1         137  
15 1     1   4 use Math::Round;
  1         2  
  1         42  
16 1     1   4 use List::Util qw[ min max reduce shuffle];
  1         1  
  1         51  
17 1     1   4 use List::MoreUtils qw(uniq);
  1         1  
  1         4  
18 1     1   287 use List::AllUtils qw(sum);
  1         1  
  1         43  
19 1     1   3 use Statistics::Basic qw(:all);
  1         1  
  1         5  
20 1     1   409 use IO::Tee;
  1         2  
  1         44  
21 1     1   5 use Set::Intersection;
  1         2  
  1         59  
22 1     1   7 use List::Compare;
  1         1  
  1         24  
23 1     1   4 use Data::Dumper;
  1         2  
  1         64  
24             #$Data::Dumper::Indent = 0;
25             #$Data::Dumper::Useqq = 1;
26             #$Data::Dumper::Terse = 1;
27 1     1   7 use Data::Dump qw(dump);
  1         1  
  1         57  
28 1     1   4 use feature 'say';
  1         2  
  1         52  
29             #use feature qw(postderef);
30             #no warnings qw(experimental::postderef);
31             #use Sub::Signatures;
32             #no warnings qw(Sub::Signatures);
33             #no strict 'refs';
34 1     1   4 no strict;
  1         1  
  1         34  
35 1     1   3 no warnings;
  1         5  
  1         35  
36              
37 1     1   4 use Sim::OPT;
  1         4  
  1         25  
38 1     1   4 use Sim::OPT::Morph;
  1         1  
  1         19  
39 1     1   4 use Sim::OPT::Sim;
  1         1  
  1         12  
40 1     1   13 use Sim::OPT::Retrieve;
  1         0  
  1         18  
41 1     1   3 use Sim::OPT::Report;
  1         1  
  1         16  
42 1     1   3 use Sim::OPT::Descend;
  1         7  
  1         6971  
43              
44             our @ISA = qw(Exporter); # our @adamkISA = qw(Exporter);
45             #%EXPORT_TAGS = ( DEFAULT => [qw( &opt &prepare )]); # our %EXPORT_TAGS = ( 'all' => [ qw( ) ] );
46             #@EXPORT_OK = qw(); # our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
47              
48             @EXPORT = qw( takechance ); # our @EXPORT = qw( );
49             $VERSION = '0.05';
50              
51             #########################################################################################
52             # HERE FOLLOWS THE CONTENT OF "Takechance.pm", Sim::OPT::Takechance
53             #########################################################################################
54              
55             sub takechance
56             {
57 0 0   0 0   if ( not ( @ARGV ) )
58             {
59 0           $toshell = $main::toshell;
60 0           $tee = new IO::Tee(\*STDOUT, ">>$toshell"); # GLOBAL ZZZ
61 0           say $tee "\n#Now in Sim::OPT::Takechance.\n";
62 0           $configfile = $main::configfile; #say "dump(\$configfile): " . dump($configfile);
63 0           @sweeps = @main::sweeps; #say "dump(\@sweeps): " . dump(@sweeps);
64 0           @varinumbers = @main::varinumbers; #say $tee "dump(\@varinumbers): " . dump(@varinumbers);
65 0           @mediumiters = @main::mediumiters;
66 0           @rootnames = @main::rootnames; #say "dump(\@rootnames): " . dump(@rootnames);
67 0           %vals = %main::vals; #say "dump(\%vals): " . dump(%vals);
68 0           @caseseed = @main::caseseed; #say $tee "dump(INTAKE\@caseseed): " . dump(@caseseed);
69 0           @chanceseed = @main::chanceseed; #say $tee "dump(INTAKE\@chanceseed): " . dump(@chanceseed);
70 0           @chancedata = @main::chancedata; #say $tee "dump(INTAKE\@chancedata): " . dump(@chancedata);
71 0           @pars_tocheck = @main::pars_tocheck; #say $tee "dump(INTAKE\@pars_tocheck): " . dump(@pars_tocheck);
72 0           $dimchance = $main::dimchance; #say $tee "dump(INTAKE\$dimchance): " . dump($dimchance);
73            
74 0           $mypath = $main::mypath; #say TOSHELL "dumpINDESCEND(\$mypath): " . dump($mypath);
75 0           $exeonfiles = $main::exeonfiles; #say TOSHELL "dumpINDESCEND(\$exeonfiles): " . dump($exeonfiles);
76 0           $generatechance = $main::generatechance;
77 0           $file = $main::file;
78 0           $preventsim = $main::preventsim;
79 0           $fileconfig = $main::fileconfig; #say TOSHELL "dumpINDESCEND(\$fileconfig): " . dump($fileconfig); # NOW GLOBAL. TO MAKE IT PRIVATE, FIX PASSING OF PARAMETERS IN CONTRAINTS PROPAGATION SECONDARY SUBROUTINES
80 0           $outfile = $main::outfile;
81 0           $target = $main::target;
82            
83 0           $report = $main::report;
84 0           $simnetwork = $main::simnetwork;
85            
86             #open ( OUTFILE, ">>$outfile" ) or die "Can't open $outfile: $!";
87             #open ( TOSHELL, ">>$toshell" ) or die "Can't open $toshell: $!";
88             #$tee = new IO::Tee(\*STDOUT, ">>$toshell"); # GLOBAL ZZZ
89            
90             #say TOSHELL "dump(\$repfile): " . dump($repfile);
91 0           %dowhat = %main::dowhat;
92              
93 0           @themereports = @main::themereports; #say "dumpTakechance(\@themereports): " . dump(@themereports);
94 0           @simtitles = @main::simtitles; #say "dumpTakechance(\@simtitles): " . dump(@simtitles);
95 0           @reporttitles = @main::reporttitles;
96 0           @simdata = @main::simdata;
97 0           @retrievedata = @main::retrievedata;
98 0           @keepcolumns = @main::keepcolumns;
99 0           @weights = @main::weights;
100 0           @weightsaim = @main::weightsaim;
101 0           @varthemes_report = @main::varthemes_report;
102 0           @varthemes_variations = @vmain::arthemes_variations;
103 0           @varthemes_steps = @main::varthemes_steps;
104 0           @rankdata = @main::rankdata; # CUT ZZZ
105 0           @rankcolumn = @main::rankcolumn;
106 0           @reporttempsdata = @main::reporttempsdata;
107 0           @reportcomfortdata = @main::reportcomfortdata;
108 0           @reportradiationenteringdata = @main::reportradiationenteringdata;
109 0           @report_loadsortemps = @main::report_loadsortemps;
110 0           @files_to_filter = @main::files_to_filter;
111 0           @filter_reports = @main::filter_reports;
112 0           @base_columns = @main::base_columns;
113 0           @maketabledata = @main::maketabledata;
114 0           @filter_columns = @main::filter_columns;
115 0           @pars_tocheck = @main::pars_tocheck; #say $tee "BEGINNING dump(\@pars_tocheck): " . dump(@pars_tocheck);
116             }
117             else
118             {
119 0           my $file = $ARGV[0];
120 0           require $file;
121             }
122            
123 0           my %res;
124             my %lab;
125 0           my $countcase = 0;
126 0           my @caseseed_ = @caseseed;
127 0           my @chanceseed_ = @chanceseed;
128 0           foreach my $case (@caseseed_) # In a $casefile one or more searches are described. Here one or more searches are fabricated.
129             {
130            
131             #say $tee "BEGINNING dump(\@varinumbers): " . dump(@varinumbers);
132 0           my @tempvarinumbers = @varinumbers; ###ZZZ
133 0           foreach my $elt ( keys %{ $varinumbers[$countcase] } ) # THIS STRIPS AWAY THE PARAMETERS THAT ARE NOT CONTAINED IN @pars_tocheck.
  0            
134             {
135 0 0         unless ( $elt ~~ @{ $pars_tocheck[$countcase] } )
  0            
136             {
137 0           delete ${ $tempvarinumbers[$countcase] }{$elt};
  0            
138             }
139             }
140             #say $tee "BEGINNING AFTER \tempvarinumbers " . dump(@tempvarinumbers);
141            
142 0           my $testfile = "$mypath/$file-testfile-$countcase.csv"; #say $tee "dump(INTAKE\$testfile): " . dump($testfile);
143 0 0         open (TEST, ">>$testfile") or die;
144 0           my @blockrefs = @{$case}; #say $tee "dump(INTAKE\@blockrefs): " . dump(@blockrefs);
  0            
145 0           my (@varnumbers, @newvarnumbers, @chance, @newchance, @shuffledchanceelms);
146 0           my @chancerefs = @{$chanceseed_[$countcase]}; #say $tee "dump(INTAKE\@chancerefs): " . dump(@chancerefs);
  0            
147            
148 0           my %varnums = Sim::OPT::getcase(\@varinumbers, $countcase); #say TOSHELL "dumpIN---(\%varnums): " . dump(%varnums);
149 0           my @variables;
150 0 0         if ( not (@{$pars_tocheck->[$countcase]}) )
  0            
151             {
152 0           @variables = sort { $a <=> $b } keys %varnums; #say $tee "dump(INTAKE1\@variables): " . dump(@variables);
  0            
153             }
154             else
155             {
156 0           @variables = sort { $a <=> $b } @{ $pars_tocheck[$countcase] }; #say $tee "dump(INTAKE2\@variables): " . dump(@variables);
  0            
  0            
157             }
158 0           my $numberof_variables = scalar(@variables); #say $tee "dump(INTAKE\$numberof_variables): " . dump($numberof_variables);
159            
160 0           my $blocklength = $chancedata[$countcase][0]; #say $tee "dump(INTAKE\$blocklength): " . dump($blocklength);
161 0           my $blockoverlap = $chancedata[$countcase][1]; #say $tee "dump(INTAKE\$blockoverlap): " . dump($blockoverlap);
162 0           my $numberof_sweepstoadd = $chancedata[$countcase][2]; #say $tee "dump(INTAKE\$numberof_sweepstoadd): " . dump($numberof_sweepstoadd);
163 0           my $numberof_seedblocks = scalar(@blockrefs); #say $tee "dump(INTAKE\$numberof_seedblocks): " . dump($numberof_seedblocks);
164 0           my $totalnumberof_blocks = ( $numberof_seedblocks + $numberof_sweepstoadd ); #say $tee "dump(INTAKE\$totalnumberof_blocks): " . dump($totalnumberof_blocks);
165 0           my (@caserefs_alias, @chancerefs_alias);
166 0           my $countbuild = 1;
167 0           while ( $countbuild <= $numberof_sweepstoadd )
168             {
169 0           say $tee "#######################################################################
170             ADDING \$countbuild $countbuild";
171            
172 0           my $countchance = 1;
173 0           while ($countchance <= $dimchance)
174             {
175 0           say $tee"EXPLORING CHANCE, TIME \$countchance $countchance \$countbuild $countbuild";
176 0           my %lab;
177 0           my ($beginning, @shuffledchanceres, @shuffledchanceelms, @overlap);
178 0           my $semaphore = 0;
179 0           my $countshuffle = 1;
180             sub _shuffle_
181             {
182 0     0     say $tee "#######################################################################
183             SHUFFLING NUMBER $countshuffle, \$countbuild $countbuild \$countchance $countchance";
184 0           @shuffledchanceelms = ();
185 0           @overlap = ();
186 0           @shuffledchanceres = shuffle(@variables); #say $tee "dump(INBUILD\@shuffledchanceres): " . dump(@shuffledchanceres);
187             ######@shuffledchanceres = ( 1, 2, 3, 4, 5);#####
188 0           push (@shuffledchanceelms, @shuffledchanceres, @shuffledchanceres, @shuffledchanceres ); #say $tee "dump(INTAKE\@shuffledchanceelms): " . dump(@shuffledchanceelms);
189 0           $beginning = int(rand($blocklength-1) + $numberof_variables); #say $tee "dump(INBUILD\$beginning): " . dump($beginning);
190 0           my $endblock = ( $beginninng + $blocklength ); #say $tee "dump(INBUILD\$endblock): " . dump($endblock);
191             #my @shuffledchanceslice = sort { $a <=> $b } (uniq(@shuffledchanceelms[$beginninng..$endblock])); say $tee "dump(INBUILD\@shuffledchanceslice): " . dump(@shuffledchanceslice); # my @shuffledchanceslice = @shuffledchanceelms[$beginning..$endblock] ;
192 0           @caserefs_alias = @blockrefs; #say $tee "dump(INBUILD\@caserefs_alias): " . dump(@caserefs_alias);
193 0           @chancerefs_alias = @chancerefs; #say $tee "dump(INBUILD\@chancerefs_alias): " . dump(@chancerefs_alias);
194 0           my @pastsweepblocks = Sim::OPT::fromopt_tosweep_simple( { casegroup => [@caserefs_alias], chancegroup => [@chancerefs_alias] } ); say $tee "dumpXX(INBUILD-AFTER\@pastsweepblocks): " . dump(@pastsweepblocks);
  0            
195              
196 0           push (@caserefs_alias, [ $beginning, $blocklength ]); #say $tee "dump(INBUILD-AFTER\@caserefs_alias): " . dump(@caserefs_alias);
197 0           push (@chancerefs_alias, [ @shuffledchanceelms ]); #say $tee "dump(INBUILD-AFTER\@chancerefs_alias): " . dump(@chancerefs_alias);
198            
199 0           my $pastbeginning = $chancerefs_alias[ $#chancerefs_alias -1 ][ 0] ;
200 0 0         if ( scalar(@chancerefs_alias) <= 1 )
201             {
202 0           $pastbeginning eq "";
203             }
204            
205 0           my $pastendblock;
206 0 0         if ($pastbeginning)
207             {
208 0           $pastendblock = ( $pastbeginning + $blocklength );
209             }
210             else
211             {
212 0           $pastendblock eq "";
213             }
214             #say $tee "dump(INBUILD-AFTER\$pastbeginning): " . dump($pastbeginning);
215             #say $tee "dump(INBUILD-AFTER\$pastendblock): " . dump($pastendblock);
216            
217 0           my @slice = @{ $chancerefs_alias[$#chancerefs_alias] }[ $beginning..( $beginning + $blocklength -1 ) ]; #say $tee "dump(INTAKE\@slice): " . dump(@slice);
  0            
218 0           my @pastslice = @{ $chancerefs_alias[ $#chancerefs_alias -1 ] }[ $pastbeginning..( $pastbeginning + $blocklength -1 ) ]; #say $tee "dump(INTAKE\@pastslice): " . dump(@pastslice);
  0            
219 0           my $lc = List::Compare->new(\@slice, \@pastslice);
220 0           my @intersection = $lc->get_intersection; #say $tee "dump(INBUILD\@intersection): " . dump(@intersection);
221            
222             #my $res = Sim::OPT::checkduplicates( { slice => \@slice, sweepblocks => \@pastsweepblocks } ); say $tee "dumpXX(INBUILD\$res): " . dump($res);
223            
224 0 0         if ( scalar( @intersection ) == $blockoverlap ) { $semaphore = 1; }
  0            
225            
226 0 0         if ( not ( $semaphore == 1 ) )
227             {
228 0           say $tee "NOT HIT. \$countshuffle: $countshuffle.";
229 0           $countshuffle++;
230 0           &_shuffle_;
231             }
232             else
233             {
234 0           return (\@shuffledchanceres, \@shuffledchanceelms);
235 0           say $tee "HIT. \$countshuffle: $countshuffle.";
236             }
237             }
238 0           my @result = _shuffle_;
239 0           @shuffledchanceres = @{$result[0]};
  0            
240 0           @shuffledchanceelms = @{$result[1]};
  0            
241 0           say $tee "EXITING SHUFFLE WITH \@shuffledchanceres: @shuffledchanceres, \@shuffledchanceelms, @shuffledchanceelms";
242 0           $lab{$countcase}{$countbuild}{$countchance}{case} = \@caserefs_alias; #say $tee "dump(OUTBUILD\$lab{$countcase}{$countbuild}{$countchance}{case}): " . dump($lab{$countcase}{$countbuild}{$countchance}{case});
243 0           my @thiscase = @{ $lab{$countcase}{$countbuild}{$countchance}{case} }; #say $tee "dump(OUTBUILD\@thiscase): " . dump(@thiscase);
  0            
244            
245 0           $lab{$countcase}{$countbuild}{$countchance}{chance} = \@chancerefs_alias; #say $tee "dump(OUTBUILD\$lab{$countcase}{$countbuild}{$countchance}{chance}): " . dump($lab{$countcase}{$countbuild}{$countchance}{chance});
246 0           my @thischance = @{ $lab{$countcase}{$countbuild}{$countchance}{chance} }; #say $tee "dump(OUTBUILD\@thischance): " . dump(@thischance);
  0            
247 0           say $tee "dump(OUTBUILD\%lab): " . dump(%lab);
248            
249             ################################
250             #> HERE THE CODE FOLLOWS FOR THE CALCULATION OF HEURISTIC INDICATORS MEASURING THE EFFECTIVENESS OF A SEARCH STRUCTURE FOR SEARCH.
251            
252 0           my $countfirstline = 0;
253            
254 0           my ( $totalsize, $totaloverlapsize, $totalnetsize, $commonalityflow, $totalcommonalityflow,
255             $cumulativecommonalityflow, $localcommonalityflow, $addcommonalityflow, $remembercommonalityflow,
256             $cumulativecommonalityflow, $localrecombinationratio, $heritageleft, $heritagecentre,
257             $heritageright, $previousblock, $flatoverlapage, $rootexpoverlapage, $expoverlapage,
258             $flatweightedoverlapage, $overlap, $iruif, $stdcommonality, $stdrecombination, $stdinformation,
259             $stdfatminus, $stdshadow, $localrecombinalityminusratio,
260             $localrecombinalityratio, $localrenewalratio, $infminusflow, $cumulativeinfminusflow, $totalinfminusflow, $infflow,
261             $cumulativeinfflow, $totalinfflow, $infoflow, $cumulativeinfoflow, $totalinfoflow,
262             $refreshment, $refreshmentminus, $n_basketminus, $n_unionminus, $n_basket, $n_union,
263             $recombination_ratio, $proportionhike, $iruifflow, $cumulativeiruif, $totaliruif,
264             $commonalityflowproduct, $commonalityflowenhanced, $commonalityflowproductenhanced,
265             $cumulativecommonalityflowproduct, $cumulativecommonalityflowenhanced, $cumulativecommonalityflowproductenhanced,
266             $averageageexport, $cumulativeage, $refreshratio, $flowratio, $cumulativeflowratio, $flowageratio,
267             $cumulativeflowageratio, $shadowexport, $modiflow, $cumulativemodiflow, $cumulativehike, $cumulativerefreshment,
268             $refreshmentperformance, $refreshmentsize, $cumulativerefreshmentperformance, $refreshmentvolume, $IRUIF, $mmIRUIF, $averageage,
269             $otherIRUIF, $othermmIRUIF, $mmresult, $mmregen, $score, $sumnovelty,$urr,$IRUIFnovelty,$IRUIFurr,
270             $IRUIFnoveltysquare,$IRUIFurrsquare,$IRUIFnoveltycube,$IRUIFurrcube );
271            
272 0           my ( @commonalities, @commonalitiespe, @recombinations, @informations, @localcommonances, @commonanceratios,
273             @groupminus, @unionminus, @group, @union, @basketminusnow, @unionminus, @basketnow, @union, @basketageexport,
274             @basketlast, @newbasket, @valuebasket, @otherbasket, @basketcount, @finalbasket, @mmbasketresult, @mmbasketregen,
275             @pastjump, @pastbunch, @resbunches, @scores );
276            
277             #>
278             ######################
279            
280 0           my $countblock = 0;
281 0           my $countblk = 0;
282 0           my $countblockplus1 = 1;
283 0           foreach my $blockref (@caserefs_alias)
284             {
285 0           say $tee "################################################################
286             NOW DEALING WITH BLOCK $countblockplus1, \$countbuild $countbuild, \$countchance $countchance";
287 0           my @blockelts = @{$blockref}; #say $tee "dump(INBLOCKS\@blockelts): " . dump(@blockelts);
  0            
288 0           my @presentblockelts = @blockelts;
289 0           my $chanceref = $chancerefs_alias[$countblk]; #say $tee "dump(INBLOCK\$chanceref): " . dump($chanceref);
290 0           my @chanceelts = @{$chanceref}; #say $tee "dump(INBLOCKS\@chanceelts): " . dump(@chanceelts);
  0            
291            
292             #############################################
293             #>
294              
295 0           my $attachment = @blockelts[0]; #say $tee "dump(INBLOCK1\$attachment): " . dump($attachment); ###BEWARE. THE VARIABLES @blockelts AND @pastblockelts IN THIS MODULE ARE NOT THE SAME USED IN Sim::OPT.
296             # ANALOGUES OF THE LATTER VARIABLES ARE HERE CALLED @presentslice AND @pastslice.
297 0           my $activeblock = @blockelts[1]; #say $tee "dump(INBLOCK1\$activeblock): " . dump($activeblock);
298 0           my $zoneend = ( $numberof_variables - $activeblock ); #say $tee "dump(INBLOCK1\$zoneend): " . dump($zoneend);
299 0           my ( $pastattachment, $pastactiveblock, $pastzoneend );
300 0           my $viewextent = $activeblock;
301 0           my ( @zoneoverlaps, @meanoverlaps, @zoneoverlapextent, @meanoverlapextent );
302 0           my $countops = 1;
303 0           my $counter = 0;
304 0           while ($countops > 0)
305             {
306 0           my @pastblockelts = @{$blockrefs[$countblk - $countops]};
  0            
307 0 0         if ($countblk == 0) { @pastblockelts = ""; }
  0            
308 0           $pastattachment = $pastblockelts[0]; #say $tee "dump(INBLOCK1\$pastattachment): " . dump($pastattachment);
309 0           $pastactiveblock = $pastblockelts[1]; #say $tee "dump(INBLOCK1\$pastactiveblock): " . dump($pastactiveblock);
310 0           $pastzoneend = ( $numberof_variables - $pastactiveblock ); #say $tee "dump(INBLOCK1\$pastzoneend): " . dump($pastzoneend);
311 0           my @presentslice = @chanceelts[ $attachment..($attachment+$activeblock-1) ]; #say $tee "dump(INBLOCK1\@presentslice): " . dump(@presentslice);
312 0           my @pastslice = @chanceelts[ $pastattachment..($pastattachment+$pastactiveblock-1) ]; #say $tee "dump(INBLOCK1\@pastslice): " . dump(@pastslice);
313 0           my $lc = List::Compare->new(\@presentslice, \@pastslice);
314 0           my @intersection = $lc->get_intersection; #say $tee "dump(INBLOCK1\@intersection): " . dump(@intersection);
315 0           my $localoverlap = scalar(@intersection); #say $tee "dump(INBLOCK1\$localoverlap): " . dump($localoverlap);
316 0           push (@meanoverlapextent, $localoverlap); #say $tee "dump(INBLOCK1\@meanoverlapextent): " . dump(@meanoverlapextent);
317 0           my $overlapsum = 0;
318 0           for ( @meanoverlapextent ) { $overlapsum += $_; }
  0            
319 0           $overlap = $overlapsum ; #say $tee "dump(INBLOCK1\$overlap): " . dump($overlap);
320 0 0         if ($countblk == 0) { $overlap = 0; }
  0            
321 0           $countops--;
322 0           $counter++;
323             }
324            
325             #if ("yesgo" eq "yesgo")
326             {
327 0           my $countops = 2;
  0            
328 0           my $counter = 0;
329 0           my ( @zoneoverlaps, @meanoverlaps, @zoneoverlapextent, @meanoverlapextent, @basketminus );
330 0           while ($countops > 1)
331             {
332 0           my @pastblockelts = @{$blockrefs[$countblk - $countops]}; #say $tee "dump(INBLOCK2\@pastblockelts): " . dump(@pastblockelts);
  0            
333 0           $pastattachment = $pastblockelts[0]; #say $tee "dump(INBLOCK2\$pastattachment): " . dump($pastattachment);
334 0           $pastactiveblock = $pastblockelts[1]; #say $tee "dump(INBLOCK2\$pastactiveblock): " . dump($pastactiveblock);
335 0           $pastzoneend = ( $numberof_variables - $pastactiveblock ); #say $tee "dump(INBLOCK2\$pastzoneend): " . dump($pastzoneend);
336 0           my @presentslice = @chanceelts[ $attachment..($attachment+$activeblock-1) ]; #say $tee "dump(INBLOCK2\@presentslice): " . dump(@presentslice);
337 0           my @pastslice = @chanceelts[ $pastattachment..($pastattachment+$pastactiveblock-1) ]; #say $tee "dump(INBLOCK2\@pastslice): " . dump(@pastslice);
338 0           my $lc = List::Compare->new(\@presentslice, \@pastslice);
339 0           my @intersection = $lc->get_intersection; #say $tee "dump(INBLOCK2\@intersection): " . dump(@intersection);
340 0           push (@basketminus, @intersection); #say $tee "dump(INBLOCK2\@basketminus): " . dump(@basketminus);
341 0           $stdfatminus = stddev(@basketminus); #say $tee "dump(INBLOCK2\$stdfatminus): $stdfatminus";
342 0           my $localoverlap = scalar(@intersection); #say $tee "dump(INBLOCK2\$localoverlap): " . dump($localoverlap);
343 0           my $localoverlapextent = $localoverlap; #say $tee "dump(INBLOCK2\$localoverlapextent): " . dump($localoverlapextent);
344 0           push (@meanoverlapextent, $localoverlap); #say $tee "dump(INBLOCK2\@meanoverlapextent): " . dump(@meanoverlapextent);
345 0           my $overlapsum = 0;
346 0           for ( @meanoverlapextent ) { $overlapsum += $_; }
  0            
347 0           $overlapminus = ($overlapsum ); #say $tee "dump(INBLOCK2\$overlapminus): " . dump($overlapminus);
348 0           @basketminusnow = @basketminus;
349 0           $countops--;
350 0           $counter++;
351             }
352             }
353 0           @unionminus = uniq(@basketminusnow); #say $tee "ZONE2OUT: \$countcase: $countcase, \$countbuild: $countbuild, \$countchance: $countchance, \$countblk:$countblk, \$countops: $countops, \$counter: $counter, \@unionminus: @unionminus\n";
354 0           $n_basketminus = scalar(@basketminusnow); #say $tee "dump(INBLOCK2\$n_basketminus): " . dump($n_basketminus);
355 0           $n_unionminus = scalar (@unionminus); #say $tee "dump(INBLOCK2\$n_unionminus): " . dump($n_unionminus);
356 0 0         if ( $n_unionminus == 0) {$n_unionminus = 1;}; #say $tee "dump(INBLOCK2-IFZERO\$n_unionminus): " . dump($n_unionminus);
  0            
357 0 0         if ( $n_basketminus == 0) {$n_basketminus = 1;}; #say $tee "dump(INBLOCK2-IFZERO\$n_basketminus): " . dump($n_basketminus);
  0            
358 0           $refreshmentminus = ( ( $n_unionminus / $n_basketminus ) ); #say $tee "dump(INBLOCK2\$refreshmentminus): $refreshmentminus";
359            
360             #if ("yesgo" eq "yesgo")
361             {
362 0           my ( @zoneoverlaps, @meanoverlaps, @zoneoverlapextent, @meanoverlapextent, @zoneoverlapweightedextent, @meanoverlapweightedextent);
  0            
363 0           my $countops = 1;
364 0           my ( $flatoverlapsum, $expoverlapsum, $flatweightedoverlapsum, $expweightedoverlapsum, $averageage );
365 0           my $counter = 0;
366 0           my $countage = $numberof_variables;
367 0           my ( @basket, @basketage, @freshbasket, @basketnow );
368 0           while ($countops < $numberof_variables)
369             {
370 0           my @pastblockelts = @{$blockrefs[$countblk - $countops]}; #say $tee "dump(INBLOCK3\@pastblockelts): " . dump(@pastblockelts);
  0            
371 0           $pastattachment = $pastblockelts[0]; #say $tee "dump(INBLOCK3\$pastattachment): " . dump($pastattachment);
372 0           $pastactiveblock = $pastblockelts[1]; #say $tee "dump(INBLOCK3\$pastactiveblock): " . dump($pastactiveblock);
373 0           $pastzoneend = ( $numberof_variables - $pastactiveblock ); #say $tee "dump(INBLOCK3\$pastzoneend): " . dump($pastzoneend);
374 0           my @pastslice = @chanceelts[ $pastattachment..($pastattachment+$pastactiveblock-1) ]; #say $tee "dump(INBLOCK3\@pastslice): " . dump(@pastslice);
375             #@pastslice = Sim::OPT::_clean_ (\@pastslice); say $tee "dump(INBLOCK3\@pastslice): " . dump(@pastslice);
376 0           my @otherslice = @pastslice;
377            
378 0           foreach $int (@pastslice)
379             {
380 0 0         if ($int)
381             {
382 0           $int = "$int" . "-" . "$countops";
383             }
384             }
385            
386 0 0         if ($countops <= $numberof_variables)
387             {
388 0           push (@basket, @pastslice);
389             }
390             #@basket = Sim::OPT::_clean_ (\@basket);
391 0           @basket = sort { $a <=> $b } @basket;
  0            
392             #say $tee "dump(INBLOCK3\@basket): " . dump(@basket);
393            
394 0 0         if ($countops <= $numberof_variables)
395             {
396 0           push (@otherbasket, @otherslice);
397             }
398             #@otherbasket = Sim::OPT::_clean_ (\@otherbasket);
399 0           @otherbasket = sort { $a <=> $b } @otherbasket;
  0            
400             #say $tee "dump(INBLOCK3\@otherbasket): " . dump(@otherbasket);
401            
402 0           @newbasket = @basket;
403 0           @basketnow = @newbasket;
404 0           @transferbasket = @basketnow;
405 0           my @presentslice = @chanceelts[ $attachment..($attachment+$activeblock-1) ]; #say $tee "dump(INBLOCK3\@presentslice): " . dump(@presentslice);
406 0           @activeblk = @presentslice; #say $tee "dump(INBLOCK3\@activeblk): " . dump(@activeblk);
407 0           $countops++;
408 0           $counter++;
409 0           $countage--;
410             }
411             } #say $tee "ZONE3: \$countcase: $countcase, \$countbuild: $countbuild, \$countchance: $countchance, \$countblk:$countblk, \$countops: $countops, \$counter: $counter, \$countage: $countage, \@transferbasket: @transferbasket\n";
412              
413 0           my @integralslice = @shuffledchanceelms[ ($numberof_variables) .. (($numberof_variables * 2) - 1) ]; #say $tee "AFTERZONE \$countcase: $countcase, \$countbuild: $countbuild, \$countchance: $countchance, \$numberof_variables: $numberof_variables, \@variables: @variables, \@shuffledchanceres: @shuffledchanceres, \@shuffledchanceelms: @shuffledchanceelms, \@integralslice-->: @integralslice";
414             #my @integralslice = sort { $a <=> $b } @integralslice;
415 0           my @valuebasket;
416 0           foreach my $el (@integralslice)
417             {
418 0           my @freshbasket;
419 0           foreach my $elm (@transferbasket)
420             {
421 0           my $elmo = $elm;
422 0           $elmo =~ s/(.*)-(.*)/$1/;
423 0 0         if ($el eq $elmo)
424             {
425 0           push (@freshbasket, $elm);
426             }
427             }
428 0           @freshbasket = sort { $a <=> $b } @freshbasket; #say $tee "AFTERZONE \@freshbasket: @freshbasket"; say $tee " \$countcase: $countcase, \$countbuild: $countbuild, \$countchance: $countchance, \$countblk:$countblk";
  0            
429            
430 0           my $winelm = $freshbasket[0];
431 0           push (@valuebasket,$winelm); #say $tee "AFTERZONE \@valuebasket: @valuebasket"; say $tee "AFTERZONE \@freshbasket: @freshbasket"; say $tee "ZONE2OUT: \$countcase: $countcase, \$countbuild: $countbuild, \$countchance: $countchance, \$countblk:$countblk";
432            
433 0           foreach my $elt (@integralslice)
434             {
435 0           foreach my $elem (@valuebasket)
436             {
437 0 0         unless ($elem eq "")
438             {
439 0           my $elmo = $elem;
440 0           $elmo =~ s/(.*)-(.*)/$1/;
441 0 0         if ($elmo ~~ @integralslice)
442             {
443             ;
444             }
445             else
446             {
447 0 0         if ($countblk > $$numberof_variables) { my $eltinsert = "$elmo" . "-" . "$numberof_variables"; }
  0            
448 0           else { my $eltinsert = "$elmo" . "-" . "$countblk";}
449 0           push (@valuebasket, $eltinsert);
450             } #say $tee "AFTERZONE INTERMEDIATE \@valuebasket: @valuebasket";
451             }
452             }
453             }
454             }
455 0           @valuebasket = sort { $a <=> $b } @valuebasket;
  0            
456             #say $tee "AFTERZONE FINAL \@valuebasket: @valuebasket"; say $tee " \$countcase: $countcase, \$countbuild: $countbuild, \$countchance: $countchance, \$countblk:$countblk";
457              
458 0           my $sumvalues = 0;
459 0           my @finalbasket;
460 0           foreach my $el (@valuebasket)
461             {
462 0           my $elmo = $el;
463 0           $elmo =~ s/(.*)-(.*)/$2/;
464 0           $sumvalues = $sumvalues + $elmo;
465 0           push (@finalbasket, $elmo);
466            
467             } #say $tee "POST AFTERZONE \@finalbasket: @finalbasket\n";
468            
469 0           my ( @presentblockelts, @pastblockelts, @presentslice, @pastslice, @intersection, @presentjump, @presentbunch, @resbunch
470             # @pastminusblockelts, @pastminusslice, @intersectionminus,
471             );
472            
473 0 0         if ($countblk > 1)
474             {
475 0           @pastblockelts = @{$blockrefs[$countblk - 1]}; #say $tee "BEYOND1 @pastblockelts-->: @pastblockelts"; say $tee "AFTERZONE \@freshbasket: @freshbasket"; say $tee " \$countcase: $countcase, \$countbuild: $countbuild, \$countchance: $countchance, \$countblk:$countblk";
  0            
476 0           @pastminusblockelts = @{$blockrefs[$countblk - 2]}; #say $tee "BEYOND1 @pastminusblockelts-->: @pastminusblockelts"; say $tee "AFTERZONE \@freshbasket: @freshbasket"; say $tee " \$countcase: $countcase, \$countbuild: $countbuild, \$countchance: $countchance, \$countblk:$countblk";
  0            
477             # @presentblockelts = @{$blockrefs[$countblk]}; # THERE IS ALREADY: @blockelts;
478             #say $tee "BEYOND1 \@presentblockelts-->: @presentblockelts";
479 0           $pastattachment = $pastblockelts[0]; #say $tee "BEYOND1 \$pastattachment-->: $pastattachment";
480 0           $pastactiveblock = $pastblockelts[1]; #say $tee "BEYOND1 \$pastactiveblock: $pastactiveblock";
481 0           $pastzoneend = ( $numberof_variables - $pastactiveblock ); #say $tee "BEYOND1 \$pastzoneend-->: $pastzoneend";
482             #my $pastminusattachment = $pastminusblockelts[0]; say $tee "BEYOND1 \$pastminusattachment-->: $pastminusattachment";############ ZZZZ UNNEEDED
483             #my $pastminusactiveblock = $pastminusblockelts[1]; say $tee "BEYOND1 \$pastminusactiveblock $pastminusactiveblock";############ ZZZZ UNNEEDED
484             #my $pastminuszoneend = ( $numberof_variables - $pastminusactiveblock ); say $tee "BEYOND1 \$pastminuszoneend-->: $pastminuszoneend";############ ZZZZ UNNEEDED
485 0           @pastslice = @chanceelts[ $pastattachment..($pastattachment + $pastactiveblock-1) ]; #say $tee "BEYOND1 \@pastslice-->: @pastslice";
486 0           @pastslice = sort { $a <=> $b } @pastslice; #say $tee "BEYOND1-ORDERED \@pastslice-->: @pastslice";
  0            
487             #@pastminusslice = = @chanceelts[ $pastminusattachment..($pastminusattachment + $pastminusactiveblock-1) ]; say $tee "BEYOND1 \@pastsminuslice-->: @pastsminuslice";############ ZZZZ UNNEEDED
488             #@pastsminuslice = sort { $a <=> $b } @pastminusslice; say $tee "BEYOND1-ORDERED \@pastsminuslice-->: @pastsminuslice";############ ZZZZ UNNEEDED
489 0           @presentslice = @chanceelts[ $attachment..($attachment + $activeblock-1) ]; #say $tee "BEYOND1 \@presentslice-->: @presentslice";
490 0           @presentslice = sort { $a <=> $b } @presentslice; #say $tee "BEYOND1-ORDERED \@presentslice-->: @presentslice";
  0            
491 0           my $lc = List::Compare->new(\@presentslice, \@pastslice);
492 0           @intersection = $lc->get_intersection; #say $tee "dump(INBLOCK2\@intersection): " . dump(@intersection);
493             #my $lc2 = List::Compare->new(\@pastslice, @pastminusslice);############ ZZZZ UNNEEDED
494             #@intersectionminus = $lc2->get_intersection; say $tee "dump(INBLOCK2\@intersectionminus): " . dump(@intersectionminus);############ ZZZZ UNNEEDED
495            
496 0           my $counter = 0;
497 0           foreach my $presentelm (@presentslice)
498             {
499 0           my $pastelm = $pastslice[$counter];
500 0           my $joint = "$pastelm" . "-" . "$presentelm";
501 0           push (@resbunch, $joint);
502 0           $counter++;
503             }
504            
505             #@resbunch = Sim::OPT::_clean_ (\@resbunch);
506 0           say $tee "BEYOND AFTERCLEAN: \@resbunch: @resbunch";
507            
508 0           push (@resbunches, [@resbunch]);
509            
510             #@resbunches = Sim::OPT::_clean_ (\@resbunches);
511 0           say $tee "BEYOND1 AFTERCLEAN Dumper(\@resbunches:) " . Dumper(@resbunches) ;
512            
513 0           my @presentbunch = @{$resbunches[0]};
  0            
514             #@presentbunch = Sim::OPT::_clean_ (\@presentbunch);
515 0           say $tee "BEYOND1 AFTERCLEAN: \@presentbunch: @presentbunch";
516            
517 0           my $countthis = 0;
518 0           foreach my $elm (@resbunches)
519             {
520 0 0         unless ($countthis == 0)
521             {
522 0           my @pastbunch = @{$elm};
  0            
523 0           my $lc = List::Compare->new(\@presentbunch, \@pastbunch);
524 0           my @intersection = $lc->get_intersection; #say $tee "BEYOND1 \@intersection: @intersection";
525            
526 0           push ( @scores, scalar(@intersection) ); #say $tee "BEYOND1 INSIDE: \@scores @scores";
527             }
528 0           $countthis++;
529             }
530            
531             #@scores = Sim::OPT::_clean_ (\@scores);
532 0           say $tee "BEYOND1 OUTSIDE AFTERCLEAN \@scores: @scores";
533            
534 0           $score = Sim::OPT::max(@scores); #say $tee "BEYOND1 \$score: $score";
535 0           my $newoccurrences = $activeblock - $score; #say $tee "BEYOND1 \$newoccurrences: $newoccurrences";
536 0           say $tee "BEYOND1 \$numberof_variables $numberof_variables\n";
537 0           $novelty = $newoccurrences / $numberof_variables ; #say $tee "BEYOND1 \$novelty: $novelty\n"; # NSM, Novelty of the Search Move
538             # my $novelty = ($steps ** $newoccurrences) / ($steps ** $numberof_variables ); #say $tee "BEYOND1 \$countcase: $countcase, \$countbuild: $countbuild, \$countchance: $countchance, \$countblk: $countblk, \$novelty: $novelty\n"; # NSM, Novelty of the Search Move
539             }
540 0           my ($averageage, $n1_averageage);
541 0 0         if ($numberof_variables != 0)
542             {
543 0           $averageage = ( $sumvalues / $numberof_variables ); #say $tee "BEYOND2 \$averageage: $averageage"; say $tee "AFTERZONE \@freshbasket: @freshbasket"; say $tee " \$countcase: $countcase, \$countbuild: $countbuild, \$countchance: $countchance, \$countblk:$countblk";
544             }
545 0           else { print "IT WAS ZERO AT DENOMINATOR OF \$averageage.\n"; }
546            
547 0 0         if ($averageage != 0)
548             {
549 0           $n1_averageage = 1 / $averageage; #say $tee "BEYOND \$n1_averageage-->: $n1_averageage"; # FSW, Freshness of the Search Wake
550             }
551            
552 0           my $urr = ($n1_averageage * $novelty);
553             # my $urr = ($n1_averageage * $sumnovelty ) ** ( 1 / 2 ); # ALTERNATIVE.
554 0           say $tee "BEYOND2 \$urr-->: $urr"; # URR, Usefulness of Recursive Recombination say $tee "AFTERZONE \@freshbasket: @freshbasket"; say $tee "ZONE2OUT: \$countcase: $countcase, \$countbuild: $countbuild, \$countchance: $countchance, \$countblk:$countblk";
555            
556 0           my $stddev = stddev(@finalbasket);
557 0 0         if ($stddev == 0) {$stddev = 0.0001;}
  0            
558 0           my $n1_stddev = 1 / $stddev;
559 0           my $mix = $averageage * $stddev;
560            
561 0 0         if ($mix != 0)
562             {
563 0           $result = 1 / $mix; #say $tee "BEYOND2 \$result-->: $result";
564             }
565 0           else { print "IT WAS ZERO AT DENOMINATOR OF \$mix."; }
566            
567 0           push (@mmbasketresult, $result); #say $tee "BEYOND2 \@mmbasketresult-->: @mmbasketresult";
568 0           $mmresult = mean(@mmbasketresult); #say $tee "BEYOND2 \$mmresult-->: $mmresult";
569 0           $regen = $n1_averageage; #say $tee "BEYOND2 \$regen-->: $regen";
570 0           push (@mmbasketregen, $regen); #say $tee "BEYOND2 \@mmbasketregen-->: @mmbasketregen";
571 0           $mmregen = mean(@mmbasketregen); #say $tee "BEYOND2 \$mmregen-->: $mmregen\n";
572              
573             #say $tee "sequence:$countcase,\$countblk:$countblk,\@valuebasket:@valuebasket,\@finalbasket:@finalbasket,averageage:$averageage,\$stddev:$stddev,\$mix:$mix,\$result:$result,\$mixsize:$mixsize,\$regen:$regen,\$score:$score,novelty:$novelty,\$urr-->: $urr\n\n";
574             ##################################################################################################################################################
575            
576             #say
577             #REPORTFILE
578             #$tee "sequence:$countcase,\$countblk:$countblk,\@valuebasket:@valuebasket,\@finalbasket:@finalbasket,averageage:$averageage,\$stddev:$stddev,\$mix:$mix,\$result:$result,\$mixsize:$mixsize,\$regen:$regen,\$score:$score,\$novelty:$novelty,\$urr-->: $urr\n\n";
579            
580             # END CALCULATION OF THE LOCAL SEARCH AGE.
581             #################################################################################################################
582             #################################################################################################################
583            
584             ###my $steps = Sim::OPT::getstepsvar($elt, $countcase, \@varinumbers);
585              
586 0           $varsnum = ( $activeblock + $zoneend); #say $tee "BEYOND3 \$varsnum: $varsnum";
587 0           $limit = ($attachment + $activeblock + $zoneend); #say "BEYOND \$limit: $limit";
588 0           $countafter = 0;
589 0           $counterrank = 0;
590 0           $leftcounter = $attachment; #say $tee "BEYOND3 \$leftcounter: $leftcounter";
591 0           $rightcounter = ($attachment + $activeblock); #say "BEYOND \$rightcounter: $rightcounter";
592            
593             #say $tee "BEYOND3 dump(\@varinumbers): " . dump(@varinumbers);
594             #say $tee "BEYOND3 AFTER tempvarinumbers " . dump(@tempvarinumbers);
595            
596 0           $countfirstline = 0;
597            
598 0 0         if ($countblk > 0) { $antesize = Sim::OPT::givesize(\@pastslice, $countcase, \@varinumbers); } #say $tee "BEYOND3 \$antesize: $antesize";
  0            
599            
600 0           $postsize = Sim::OPT::givesize(\@presentslice, $countcase, \@varinumbers); #say $tee "BEYOND3 \$postsize: $postsize";
601 0           $localsize = $postsize + $antesize; #say $tee "BEYOND3 \$localsize: $localsize\n";
602            
603 0 0         if ($countblk == 0)
604             {
605 0           $localsize = $postsize;
606 0           $localsizeproduct = $postsize;
607             }
608            
609 0           $localsizeproduct = $postsize * $antesize; #say $tee "BEYOND3 \$localsizeproduct " . dump($localsizeproduct);
610            
611 0           $overlapsize = Sim::OPT::givesize(\@intersection, $countcase, \@tempvarinumbers); #say $tee "BEYOND3 \@intersection @intersection, \$overlapsize $overlapsize";
612             ###$overlapsize = ($steps ** $overlap); say $tee "BEYOND3 \$overlapsize $overlapsize";###DDD
613            
614 0 0         if ($overlap == 0) {$overlapsize = 1;}
  0            
615            
616             #if ( ( $countcase == 0) and ($countblk == 0) )
617             #{
618             # print
619             # #OUTFILEWRITE #TABLETITLES
620             # $tee "\$countcase,\$countblk,\$attachment,\$activeblock,\$zoneend,\$pastattachment,\$pastactiveblock,\$pastzoneend,\$antesize,\$postsize,\$overlap,\$overlapsize,\$overlapminus,\$overlapminussize,\$overlapsum,\$overlapsumsize,\$localsize,\$localnetsize,\$totalsize,\$totaloverlapsize,\$totalnetsize,\$commonalityratio,\$commonality_volume,\$commonalityflow,\$recombinationflow,\$informationflow,\$cumulativecommonalityflow,\$cumulativerecombinationflow,\$cumulativeinformationflow,\$totalcommonalityflow,\$totalrecombinationflow,\$totalinformationflow,\$addcommonalityflow,\$addrecombinationflow,\$addinformationflow,\$recombinalityminusflow,\$cumulativerecombinalityminusflow,\$totalrecombinalityminusflow,\$recombinalityflow,\$cumulativerecombinalityflow,\$totalrecombinalityflow,\$renewalflow,\$cumulativerenewalflow,\$totalrenewalflow,\$infoflow,\$cumulativeinfoflow,\$totalinfoflow,\$refreshmentminus,\$recombination_ratio,\$proportionhike,\$hike,\$refreshment,\$infflow,\$cumulativeinfflow,\$totalinfflow,\$iruiflow,\$cumulativeiruif,\$totaliruif,\$averageageexport,\$cumulativeage,\$stdage,\$refreshratio,\$averageagesize,\$flowratio,\$cumulativeflowratio,\$flowageratio,\$cumulativeflowageratio,\$modiflow,\$cumulativemodiflow,\$refreshmentsize,\$refreshmentperformance,\$cumulativerefreshmentperformance,\$refreshmentvolume,\$IRUIF,\$mmIRUIF,\$IRUIFvolume,\$mmIRUIFvolume,\$hikefactor,\$otherIRUIF,\$othermmIRUIF,\$otherIRUIFvolume,\$othermmIRUIFvolume,\$averageage,\$steddev,\$mix,\$result,\$mixsize,\$regen,\$n1_averageage,\$n1_stddev,\$n1_averageagesize,\$mmresult,\$mmregen,\$novelty,\$urr,\$IRUIFnovelty,\$IRUIFurr,\$IRUIFnoveltysquare,\$IRUIFurrsquare,\$IRUIFnoveltycube,\$IRUIFurrcube";
621             #}
622            
623 0 0         if ($countblk == 0)
624             {
625 0           $antesize = 0;
626 0           $overlap = 0;
627 0           $overlapsize = 0;
628             #$overlapminus = 0; ############ ZZZZ UNNEEDED
629             #$overlapminussize = 0; ############ ZZZZ UNNEEDED
630             }
631            
632             #if ($overlapminussize == 0) {$overlapminussize = 1;} ############ ZZZZ UNNEEDED
633 0 0         if ($overlapsize == 0){$overlapsize = 1;}
  0            
634 0 0         if ($totaloverlapsize == 0){$totaloverlapsize = 1;} ############ ZZZZ UNNEEDED?
  0            
635            
636            
637             #$overlapminussize = Sim::OPT::givesize(\@intersectionminus, $countcase, \@varinumbers); say $tee "BEYOND3 \$overlapsize $overlapsize"; ############ ZZZZ UNNEEDED
638             #$overlapminussize = ($steps ** $overlapminus); ############ ZZZZ UNNEEDED
639            
640             #if ($overlapminussize == 0){$overlapminussize = 1;} ############ ZZZZ UNNEEDED
641             #$overlapsum = ($overlapsize / $overlapminussize ); ############ ZZZZ UNNEEDED
642            
643             #$overlapsumsize = ($steps ** $overlapsum); ########## ZZZZ UNNEEDED
644            
645            
646             #if ($countblk == 0) {$overlapsumsize = 1;} ############ ZZZZ UNNEEDED
647            
648 0           $localnetsizeproduct = ( $localsizeproduct - $overlapsize );
649 0 0         if ($localnetsizeproduct == 0) {$localnetsizeproduct = 1;}
  0            
650            
651 0 0         if ($totalsize == 0){$totalsize = 1;}
  0            
652            
653 0           $localnetsize = ( $localsize - $overlapsize ); # OK
654 0 0         if ($localnetsize == 0) {$localnetsize = 1;}
  0            
655 0           $totalsize = $totalsize + $postsize; # OK
656            
657 0           $totaloverlapsize = $totaloverlapsize + $overlapsize; #OK
658 0           $totalnetsize = ($totalsize - $totaloverlapsize); # OK
659 0 0         if ($totalnetsize == 0) { $localcommonalityratio = 0; }
  0            
660            
661             #$refreshratio = $overlapsize/$overlapminussize; ############ ZZZZ UNNEEDED
662            
663 0 0         if ($countblk == 0)
    0          
664             {
665              
666 0           $localcommonalityratio = 1; #
667 0           $localiruifratio = 1; # THIS IS THE COMMONALITY OF THE SHADOW AT TIME STEP - 2.
668             }
669             elsif ($countblk > 0)
670             {
671 0 0         if ( ( ( $antesize * $postsize) ** (1/2)) != 0)
672             {
673 0           $localcommonalityratio = ( $overlapsize/ ( ( $antesize * $postsize) ** (1/2))); #say $tee "BEYOND4 \$localcommonalityratio: $localcommonalityratio"; #OK
674             }
675 0           else { print $tee "IT WAS ZERO AT DENOMINATOR OF \$localcommonalityratio.\n"; }
676            
677 0 0         if ( ( ( $antesize * $postsize) ** (1/2)) != 0)
678             {
679 0           $localiruifratio = ( $overlapminussize / ( ( $antesize * $postsize) ** (1/2)) ); #say $tee "BEYOND4 \$localiruifratio: $localiruifratio"; ############ ZZZZ UNNEEDED # THIS IS THE COMMONALITY OF THE SHADOW AT TIME STEP - 2.
680             }
681 0           else { print $tee "IT WAS ZERO AT DENOMINATOR OF \$localiruifratio.\n"; }
682             }
683              
684 0 0         if ($totalnetsize > 0)
685             {
686 0           $commonalityratio = ( $totaloverlapsize / $totalnetsize ); #OK
687             }
688 0           $commonality_volume = ($totalnetsize * $commonalityratio); #OK
689            
690 0 0         if ($countblk == 0)
    0          
691             {
692 0           $commonalityflow = $postsize ** (1/3) ; #OK
693 0           $iruiflow = $postsize ** (1/3) ; #OK
694             }
695             elsif ($countblk > 0)
696             {
697 0           $commonalityflow = ( $commonalityflow * $localcommonalityratio * $postsize) ** (1/3) ; #say $tee "BEYOND4 \$commonalityflow: $commonalityflow"; #OK # CF, Commonality Flow
698             #$iruiflow = ( $iruifflow * (($localiruifratio * $postsize) ** (1/3))); ############ ZZZZ UNNEEDED
699             }
700              
701 0           push (@commonalities, $commonalityflow);#
702 0           $stdcommonality = stddev(@commonalities);#
703 0           $cumulativecommonalityflow = ($cumulativecommonalityflow + $commonalityflow ); #say $tee "BEYOND4 \$cumulativecommonalityflow: $cumulativecommonalityflow"; #OK # CCF, Cumulative Commonality FLow
704 0           $IRUIFurrsquare = $IRUIFurrsquare + ( $totalnetsize * ( ( $urr ) ** 2 ) ); #say $tee "BEYOND4 \$totalnetsize $totalnetsize, \$urr $urr--->>> \$IRUIFurrsquare: $IRUIFurrsquare"; #OK # IRUIF, Indicator of Recursive Usefulness of the Information Flow
705             #$cumulativeiruif = ($cumulativeiruif + $iruifflow ); say $tee"BEYOND4 \$cumulativeiruif: $cumulativeiruif"; # ############ ZZZZ UNNEEDED
706            
707             #if ($countblk == 0) { print OUTFILEWRITE "\n"; }
708            
709             #print OUTFILEWRITE "$countcase,$countblk,$attachment,$activeblock,$zoneend,$pastattachment,$pastactiveblock,$pastzoneend,$antesize,$postsize,$overlap,$overlapsize,$overlapminus,$overlapminussize,$overlapsum,$overlapsumsize,$localsize,$localnetsize,$totalsize,$totaloverlapsize,$totalnetsize,$commonalityratio,$commonality_volume,$commonalityflow,$recombinationflow,$informationflow,$cumulativecommonalityflow,$cumulativerecombinationflow,$cumulativeinformationflow,$totalcommonalityflow,$totalrecombinationflow,$totalinformationflow,$addcommonalityflow,$addrecombinationflow,$addinformationflow,$recombinalityminusflow,$cumulativerecombinalityminusflow,$totalrecombinalityminusflow,$recombinalityflow,$cumulativerecombinalityflow,$totalrecombinalityflow,$renewalflow,$cumulativerenewalflow,$totalrenewalflow,$infoflow,$cumulativeinfoflow,$totalinfoflow,$refreshmentminus,$recombination_ratio,$proportionhike,$hike,$refreshment,$infflow,$cumulativeinfflow,$totalinfflow,$iruiflow,$cumulativeiruif,$totaliruif,$averageageexport,$cumulativeage,$stdage,$refreshratio,$averageagesize,$flowratio,$cumulativeflowratio,$flowageratio,$cumulativeflowageratio,$modiflow,$cumulativemodiflow,$refreshmentsize,$refreshmentperformance,$cumulativerefreshmentperformance,$refreshmentvolume,$IRUIF,$mmIRUIF,$IRUIFvolume,$mmIRUIFvolume,$hikefactor,$otherIRUIF,$othermmIRUIF,$otherIRUIFvolume,$othermmIRUIFvolume,$averageage,$steddev,$mix,$result,$mixsize,$regen,$n1_averageage,$n1_stddev,$n1_averageagesize,$mmresult,$mmregen,$novelty,$urr,$IRUIFnovelty,$IRUIFurr,$IRUIFnoveltysquare,$IRUIFurrsquare,$IRUIFnoveltycube,$IRUIFurrcube\n";
710 0           say $tee "RESULPLOT: \$countcase:$countcase,\$countblk:$countblk,\$countbuild:$countbuild,\$countchance:$countchance,\$attachment:$attachment,
711             \$activeblock:$activeblock,\$zoneend:$zoneend,\$pastattachment:$pastattachment,\$pastactiveblock:$pastactiveblock,\$pastzoneend:$pastzoneend,
712             \$antesize:$antesize,\$postsize:$postsize,\$overlap:$overlap,\$overlapsize:$overlapsize,\$overlapminus:$overlapminus,
713             \$overlapminussize:$overlapminussize,\$overlapsum:$overlapsum,\$overlapsumsize:$overlapsumsize,\$localsize:$localsize,
714             \$localnetsize:$localnetsize,\$totalsize:$totalsize,\$totaloverlapsize:$totaloverlapsize,\$totalnetsize:$totalnetsize,
715             \$commonalityratio:$commonalityratio,\$commonality_volume:$commonality_volume,\$commonalityflow:$commonalityflow,
716             \$cumulativecommonalityflow:$cumulativecommonalityflow,\$n1_averageage:$n1_averageage,\$novelty:$novelty,\$urr:$urr,
717             \$IRUIFurrsquare:$IRUIFurrsquare,\$cumulativeiruif:$cumulativeiruif";
718            
719 0           $res{$countcase}{$countbuild}{$countchance}{$countblk}{IRUIF} = $IRUIFurrsquare;
720 0           $res{$countcase}{$countbuild}{$countchance}{$countblk}{commonality} = $cumulativecommonalityflow;
721 0           $res{$countcase}{$countbuild}{$countchance}{$countblk}{novelty} = $novelty;
722 0           $res{$countcase}{$countbuild}{$countchance}{$countblk}{totalnetsize} = $totalnetsize;
723 0           $res{$countcase}{$countbuild}{$countchance}{$countblk}{freshness} = $n1_averageage;
724 0           $res{$countcase}{$countbuild}{$countchance}{$countblk}{urr} = $urr;
725 0           $res{$countcase}{$countbuild}{$countchance}{$countblk}{newblockrefs} = \@caserefs_alias;
726 0           $res{$countcase}{$countbuild}{$countchance}{$countblk}{newchance} = \@chancerefs_alias;
727            
728             #>
729             ####################################################
730            
731             #print TEST "\$countchance,$countchance,\$countbuild,$countbuild,\$countblockplus1,$countblockplus1,\$countblk,$countblk,\$countcase,$countcase,\$IRUIFurrsquare,$IRUIFurrsquare\n";
732              
733 0           $countblk++;
734 0           $countblock++;
735 0           $countblockplus1++;
736             }
737            
738 0           $countchance++;
739             }
740            
741             sub getmax
742             {
743 0     0 0   my @IRUIFcontainer;
744 0           my $countc = 1;
745 0           while ( $countc <= $dimchance )
746             {
747 0           push (@IRUIFcontainer, $res{$countcase}{$countbuild}{$countc}{$#caserefs_alias}{IRUIF}); #say $tee "POST-IN\@IRUIFcontainer " . dump(@IRUIFcontainer);
748 0           $countc++;
749             }
750 0           my $maxvalue = Sim::OPT::max(@IRUIFcontainer); #say $tee "POST-IN\$maxvalue " . dump($maxvalue);
751 0           return ($maxvalue);
752             }
753 0           my $maxvalue = getmax; #say $tee "POST-OUT\$maxvalue " . dump($maxvalue);
754            
755             sub pick
756             {
757 0     0 0   my $maxvalue = shift;
758 0           my ($beststruct, $bestchance);
759 0           my $countc = 1;
760 0           while ( $countc <= $dimchance )
761             {
762             #say $tee "POST-IN2\$maxvalue " . dump($maxvalue);
763             #say $tee "POST-IN2\$res{\$countcase}{\$countbuild}{\$countc}{ \$#caserefs_alias } " . dump($res{$countcase}{$countbuild}{$countc}{ $#caserefs_alias });
764 0 0         if( $res{$countcase}{$countbuild}{$countc}{ $#caserefs_alias }{IRUIF} == $maxvalue )
765             {
766 0           $beststruct = $res{$countcase}{$countbuild}{$countc}{ $#caserefs_alias }{newblockrefs}; #say $tee "FOUND-INWHILE\$beststruct " . dump($beststruct);
767 0           $bestchance = $res{$countcase}{$countbuild}{$countc}{ $#caserefs_alias }{newchance}; #say $tee "FOUND-INWHILE\$bestchance " . dump($bestchance);
768 0           last;
769             }
770 0           $countc++;
771             }
772 0           return ($beststruct, $bestchance);
773             }
774 0           my @arr = pick($maxvalue);
775 0           $beststruct = $arr[0]; say $tee "POST\$beststruct " . dump($beststruct);
  0            
776 0           $bestchance = $arr[1]; say $tee "POST\$bestchance " . dump($bestchance);
  0            
777            
778 0           say $tee "PRE\@blockrefs " . dump(@blockrefs);
779 0           @blockrefs = @$beststruct; say $tee "POST\@blockrefs " . dump(@blockrefs);
  0            
780 0           say $tee "PRE\@chancerefs " . dump(@chancerefs);
781 0           @chancerefs = @$bestchance; say $tee "POST\@chancerefs " . dump(@chancerefs);
  0            
782 0           say $tee "\$res " . dump(%res);
783 0           $chanceseed_[$countcase] = $bestchance; say $tee "POST\@chanceseed_ " . Dumper(@chanceseed_);
  0            
784 0           $caseseed_[$countcase] = $beststruct; say $tee "POST\@caseseed_ " . Dumper(@caseseed_);
  0            
785 0           @sweeps_ = Sim::OPT::fromopt_tosweep( casegroup => \@caseseed_, chancegroup => \@chanceseed_ ); say $tee "POST\@sweeps_ " . Dumper(@sweeps_);
  0            
786 0           close TEST;
787 0           close CASEFILE_PROV;
788 0           close CHANCEFILE_PROV;
789            
790 0           $countbuild++;
791             }
792 0           $countcase++;
793             }
794 0           return (\@sweeps_, \@caseseed_, \@chanceseed_ );
795             }
796              
797             1;
798              
799             __END__