dams-mcda / Dams-MCDA

Emma Fox R/Shiny Project with a docker server configuration
1 stars 0 forks source link

Normalization issue #104

Closed elbfox closed 5 years ago

elbfox commented 5 years ago

Normalization in WSM miscalculating for Ind_DamsDataMatrix columns: 1 (fish biomass) and 4 (annuitized cost), potentially others. minimization working properly in columns 5, 6, maximization working properly in 2, 3, etc. Column 1 and 4 are not working, to the best of my knowledge.

In the normalization process, Ind_DamsDataMatrix --> Ind_NomalizedMatrix, ALL normalized data values should be between 0 and 1. Column 1 (fish biomass) shows values >1, while column 4 (annuitized cost) does not have enough variation (i.e., all values are too close to 1)

Observed while working in branch: GraphTesting in file WSM_graphs_test.R

elbfox commented 5 years ago

Columns 1 and 4 calculation still isn't working but somehow the others are. Also, this for loop no longer makes sense (see below). Checking to see if the problem exists over the normalization for the 995 'scenarios'.

For individual dam (Ind_* variables) calculation, the issue is a little different. Normalization is currently calculating across all 8 dams...need to rewrite the for loop to focus on normalizing across all decision alternatives for only one dam at a time. This means working in two dimensions by slicing the data differently, row by row (dam by dam) instead of trying to work in 3 dimensions all at once. This got lost along the way of trying to adapt the script to handle the 995 scenarios.

elbfox commented 5 years ago

Just pushed latest changes to WSM_graph_test.R in GraphTesting branch, haven't finished breaking up normalization procedure yet, some "subscript out of bounds" error keeps coming up even though I converted to data frames and am using correct subscripting notation with updated dimensions (2). Could use some help on this, @sythel because the way I'm adjusting the script is inefficient, I just can't think of how else to do it.

sythel commented 5 years ago

cant get branch to run, investigating(fixed)

ended up being setwd calls

How are you running/calling WSM_graph_test.R as I don't see it referenced in code? I assume you are running the file directly?

sythel commented 5 years ago

WSM_graphs_test references WSMResults out of scope

The file also doesn't call the WSM function.

elbfox commented 5 years ago

Yes, I am running the file directly. It's the same file as WSM.R by a new name with a ton of individual dam specific code now added in. It doesn't call the WSM function because I needed to pull it apart to make sure that it was working...the structure for the function is still there, I'm just running it piecewise around the function part.

Perhaps not best practices, but it seemed like the easiest way.

sythel commented 5 years ago

I'm confused by "piecewise around". this line and the following few require WSMResults. what are you using the generate WSMResults? Normally its made inside the function, but as you said its not being used.

elbfox commented 5 years ago

Yes, perhaps that wasn't a good way to describe. I am running it in chunks, excluding line 49 and line 558-559, so WSMResults is still getting assigned its list, and I can call items on the list as long as I skip over the return() statement. Not the fastest, but running the code in chunks lets me step through and print out each matrix at a time to check for errors.

elbfox commented 5 years ago

Ok, I think I solved it. The 'out of bounds' error was because I was still defining rows = 8 (dams) even though I had to subset and then transpose the matrix (making the rows =5 alternatives). So, the problem is now not that the normalization isn't working, it's just inelegant and requires a TON of code which may be problematic (but perhaps not). I'm going to push what I have and continue to work on getting all of the individual dam datasets normalized and weighted for graphing. I'm doing it this way because we want to break out the normalized, weighted results by dam to graph in stacked bar charts, similar to what we had in this version: http://shiny.gsscdev.com/dams_mcda/

sythel commented 5 years ago

You beat me to it. I will continue to look at simplifying the normalization.

elbfox commented 5 years ago

Thank you! I'm going to continue to test graphs in this script, as well as the multi-dam normalization to make sure that one's working the way it should, too. I will hold off for now on adding the individual dam normalization stuff from WSM_graphs_test.R back into the WSM.R script.

sythel commented 5 years ago

fixed in SimplifyNormalization, reopen if needed