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

Basic tests for location selection ranking on new test domain #644

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

Rosejoycrocker
Copy link
Collaborator

Adds tests for location ranking using the new test domain. Tests that the methods used to rank outcomes always choose the two best sites in the test domain (5 and 6) and never choose the two worst sites (9 and 10). Uses randomised combinations of weightings for 1-6 criteria, including heat stress, wave stress, in coming and out going connectivity, depth and available space for coral. The zoning and priority location criteria will be tested in a different set of tests to be added in a future PR.

The test domain has been altered slightly, as sites 9 and 10 needed some alterations to always be the worst sites for these criteria.

Another test set added tests that sites 5 and 6 are always selected and 9 and 10 never selected for each of the MCDA methods used for site selection.

Closes #642

Comment on lines 76 to 85
DMCDA_vars(domain::Domain, criteria::NamedDimsArray,
site_ids::AbstractArray, leftover_space::AbstractArray, area_to_seed::Float64,
waves::AbstractArray, dhws::AbstractArray)::DMCDA_vars
DMCDA_vars(domain::Domain, criteria::NamedDimsArray, site_ids::AbstractArray,
leftover_space::AbstractArray, area_to_seed::Float64)::DMCDA_vars
DMCDA_vars(domain::Domain, criteria::DataFrameRow, site_ids::AbstractArray,
leftover_space::AbstractArray, area_to_seed::Float64)::DMCDA_vars
DMCDA_vars(domain::Domain, criteria::DataFrameRow, site_ids::AbstractArray,
leftover_space::AbstractArray, area_to_seed::Float64,
waves::AbstractArray, dhw::AbstractArray)::DMCDA_vars
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't formatted correctly?

Comment on lines 226 to 235
A = get_test_decision_matrix(dom)

weights = ADRIA.decision.mcda_normalize(rand(Uniform(0, 1), 6))
n_site_int = 5
site_ids = collect(1:n_sites)
S = hcat(site_ids, S)
site_ids = dom.site_data.site_id
n_sites = length(site_ids)
n_site_int = 5

rankings = Int64[site_ids zeros(Int64, n_sites) zeros(Int64, n_sites)]
rankings = Int64[site_ids zeros(Int64, n_sites) zeros(Int64, n_sites)]

prefsites, s_order = ADRIA.decision.rank_sites!(
S, weights, rankings, n_site_int, mcda_func, 2
)
S = ADRIA.decision.mcda_normalize(A)
S[:, 1] .= A[:, 1]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weird indentation?

Comment on lines 201 to 214
n_sites = 20

S = ADRIA.decision.mcda_normalize(rand(Uniform(0, 1), n_sites, 6))

sum_cover = repeat(sum(dom.init_coral_cover, dims=1), size(scens, 1))
ranks = ADRIA.decision.rank_locations(dom, scens, sum_cover, area_to_seed)
weights = ADRIA.decision.mcda_normalize(rand(Uniform(0, 1), 6))
n_site_int = 5
site_ids = collect(1:n_sites)
S = hcat(site_ids, S)

@test length(ranks.scenarios) == sum(scens.guided .> 0) || "Specified number of scenarios was not carried out."
@test length(ranks.sites) == length(dom.site_ids) || "Ranks storage is not correct size for this domain."
rankings = Int64[site_ids zeros(Int64, n_sites) zeros(Int64, n_sites)]

sel_sites = unique(ranks)
sel_sites = sel_sites[sel_sites.!=0.0]
possible_ranks = collect(Float64, 1:ADRIA.n_locations(dom)+1.0)
prefsites, s_order = ADRIA.decision.rank_sites!(
S, weights, rankings, n_site_int, mcda_func, 2
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weird indentation?

@test all([in(sid, [2, 3]) for sid in pref_seed_sites[pref_seed_sites .> 0]])
@test all([in(sid, [2, 3]) for sid in pref_fog_sites[pref_fog_sites .> 0]])
@test all([in(sid, [2, 3]) for sid in pref_seed_sites[pref_seed_sites .> 0]])
@test all([in(sid, [2, 3]) for sid in pref_fog_sites[pref_fog_sites .> 0]])
end
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorrect indentation?

@ConnectedSystems
Copy link
Collaborator

Double check the formatting for this PR please

@Rosejoycrocker Rosejoycrocker force-pushed the add-mcda-tests branch 2 times, most recently from 9a4056a to a70e292 Compare January 24, 2024 00:04
@Rosejoycrocker Rosejoycrocker force-pushed the add-mcda-tests branch 2 times, most recently from b41bbcb to d2c60d7 Compare February 9, 2024 06:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add tests for rank_sites! with randomised weightings combinations
2 participants