Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GUI: Make randomisation options available to more algs #947

Merged
merged 2 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 21 additions & 10 deletions lib/Biodiverse/Randomise.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1020,6 +1020,10 @@ sub compare_cluster_calcs_per_node {
sub get_common_rand_metadata {
my $self = shift;

my $subset_parameters = $self->get_metadata_get_rand_structured_subset;
my $group_props_parameters = $self->get_group_prop_metadata;
my $tree_shuffle_parameters = $self->get_tree_shuffle_metadata;

my @common = (
bless ({
name => 'save_checkpoint',
Expand Down Expand Up @@ -1049,14 +1053,15 @@ sub get_common_rand_metadata {

#@common = (); # override until we allow some args to be overridden on subsequent runs.
push @common, (
bless ({
@$subset_parameters,
{
name => 'labels_not_to_randomise',
label_text => 'Labels to not randomise',
type => 'text',
default => '',
tooltip => 'List of labels to not randomise, one per line',
}, $parameter_metadata_class),
bless ({
},
{
name => 'build_randomised_trees',
label_text => 'Build randomised tree outputs',
type => 'boolean',
Expand All @@ -1066,8 +1071,14 @@ sub get_common_rand_metadata {
=> 'Rebuild any tree structures such as '
. 'cluster and region grower analyses. '
. 'These can be slow, so this is off by default.',
}, $parameter_metadata_class),
},
$group_props_parameters,
$tree_shuffle_parameters,
);
for (@common) {
next if blessed $_;
bless $_, $parameter_rand_metadata_class;
}

return wantarray ? @common : \@common;
}
Expand All @@ -1092,13 +1103,13 @@ This is applied after the multiplier parameter so you have:
END_TOOLTIP_ADDN
;

my $subset_parameters = $self->get_metadata_get_rand_structured_subset;
my $group_props_parameters = $self->get_group_prop_metadata;
my $tree_shuffle_parameters = $self->get_tree_shuffle_metadata;
# my $subset_parameters = $self->get_metadata_get_rand_structured_subset;
# my $group_props_parameters = $self->get_group_prop_metadata;
# my $tree_shuffle_parameters = $self->get_tree_shuffle_metadata;
my $common_metadata = $self->get_common_rand_metadata;

my @parameters = (
@$subset_parameters,
# @$subset_parameters,
{name => 'richness_multiplier',
type => 'float',
default => 1,
Expand All @@ -1113,8 +1124,8 @@ END_TOOLTIP_ADDN
tooltip => $tooltip_addn,
box_group => 'Richness constraints',
},
$group_props_parameters,
$tree_shuffle_parameters,
# $group_props_parameters,
# $tree_shuffle_parameters,
@$common_metadata,
);
for (@parameters) {
Expand Down
10 changes: 6 additions & 4 deletions lib/Biodiverse/Randomise/CurveBall.pm
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ END_PROGRESS_TEXT


if ($attempts == $max_swap_attempts) {
say "[RANDOMISE] rand_curveball: max attempts theshold "
say "[RANDOMISE] rand_curveball: max attempts threshold "
. "$max_swap_attempts reached.";
}
elsif ($moved_pairs >= $non_zero_mx_cells) {
Expand All @@ -233,9 +233,11 @@ END_PROGRESS_TEXT
}
say "[RANDOMISE] rand_curveball: ran $swap_count swaps across "
. "$attempts attempts for basedata $name with $n_labels labels and "
. "$n_groups groups.\n"
. "[RANDOMISE] Swapped $moved_pairs of the $non_zero_mx_cells group/label "
. "elements at least once.\n";
. "$n_groups groups";
if ($moved_pairs > 0) {
say "[RANDOMISE] Swapped $moved_pairs of the $non_zero_mx_cells group/label "
. "elements at least once.\n";
}

# now we populate a new basedata
my $new_bd = $self->get_new_bd_from_gp_lb_hash (
Expand Down
Loading