Add reconstruction unit tests#128
Add reconstruction unit tests#128sebastianrowan wants to merge 17 commits intoUSACE:reconstruction-lifecyclefrom
Conversation
HenryGeorgist
left a comment
There was a problem hiding this comment.
This was great. im asking you to remove files from the commit history that are not directly needed for the tests. i think that there are about 12 files currently included in this, we probably need only about 3 or 4 files total for this to be complete. lets make sure we only are changing those (to minimize our chances for accidentally checking in something we dont want to change)
structures/structures_test.go
Outdated
| t2 := time.Date(1984, time.Month(1), 11, 0, 0, 0, 0, time.UTC) // reconstruction from event 1 should be 50% complete at this time | ||
| d2.SetArrivalTime(t2) | ||
|
|
||
| events := []hazards.HazardEvent{d1, d2} |
| if err != nil { | ||
| panic(err) | ||
| } | ||
| fmt.Printf("Damage was %3.2f. Expected: %3.2f\n", dmgout, expectedDmgs[idx]) |
|
@HenryGeorgist I think I have removed all the edits to files that aren't involved in this PR. |
|
@HenryGeorgist this implementation now keeps track of structure/content values and the overall damage level throughout the series of events. When a new event arrives, we first calculate how much of the total damage (not just from the previous event) has been repaired since the last event ended. Then we calculate loss by applying the damage function to the adjusted structure value. Finally we calculate reconstruction time and completion date based on the total current damage state not just the loss from the current event. |
|
|
||
| events := []hazards.ArrivalDepthandDurationEvent{d5, d1, d2, d3, d4} | ||
|
|
||
| addMulti := &hazards.ArrivalDepthandDurationEventMulti{Events: events} //need to use the pointer reference because methods on MultiHazardEvent require pointers |
There was a problem hiding this comment.
@HenryGeorgist will this be a problem? The Increment() and ResetIndex() methods on the MultiHazardEvent have to use pointers to be able to modify the index value of the struct.
trying to send addMulti to Compute() without the & means it doesn't satisfy the MultiHazardEvent interface.
There was a problem hiding this comment.
either an instance will implement all the methods or the pointer will implement all the methods. So if you have to have a pointer on one then you have to have a pointer on all methods. An alternative: func (h ArrivalDepthAndDurationEvent) Index() ArrivalDepthAndDurationEvent where the interface would have to be Index() MultiHazard
This PR adds two functions to the
structuresmodule.computeConsequencesWithReconstruction()calculates the number of days to complete construction on a damaged structure and includes this in the resultTestComputeConsequencesWithReconstruction()computeConsequencesMulti()calculates the number of days and final date to complete reconstruction for an array of hazard events.TestComputeConsequencesMulti()