-
Notifications
You must be signed in to change notification settings - Fork 23
869 default values of agegroupgotoschoolwork abm parameters #973
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
Merged
dabele
merged 6 commits into
main
from
869-default-values-of-agegroupgotoschoolwork-abm-parameters
Apr 29, 2024
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b3a38ab
Add function set_multiple() to custom_index_array.h and update AgeGro…
khoanguyen-dev 5518d12
Add setting for AgeGroupGotoWork in TestPerson.quarantine
khoanguyen-dev 64f0baf
Merge branch 'main' into 869-default-values-of-agegroupgotoschoolwork…
khoanguyen-dev 49f51b0
Add setting for AgeGroupGotoSchoo/Work in examples and simulations
khoanguyen-dev ca30881
Merge branch 'main' into 869-default-values-of-agegroupgotoschoolwork…
khoanguyen-dev 6777fda
Add tests for set_multiple()
khoanguyen-dev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| /* | ||
| * Copyright (C) 2020-2024 MEmilio | ||
| * | ||
| * Authors: Daniel Abele | ||
| * Authors: Daniel Abele, Khoa Nguyen | ||
| * | ||
| * Contact: Martin J. Kuehn <[email protected]> | ||
| * | ||
|
|
@@ -323,6 +323,18 @@ class CustomIndexArray | |
| return (Eigen::Index)flatten_index(index, m_dimensions); | ||
| } | ||
|
|
||
| /** | ||
| * @brief Set multiple entries to the same value. | ||
| * @param indices A list of indices to be set to the same value. | ||
| * @param value The value to set. | ||
| */ | ||
| void set_multiple(const std::vector<typename CustomIndexArray<Typ, Tags...>::Index>& indices, const Typ& value) | ||
| { | ||
| for (const auto& index : indices) { | ||
| m_y[get_flat_index(index)] = value; | ||
| } | ||
| } | ||
|
|
||
| private: | ||
| // Random Access Iterator for CustomIndexArray | ||
| // To Do: As of Eigen 3.4, this is not needed anymore, | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| /* | ||
| * Copyright (C) 2020-2024 MEmilio | ||
| * | ||
| * Authors: Daniel Abele | ||
| * Authors: Daniel Abele, Khoa Nguyen | ||
| * | ||
| * Contact: Martin J. Kuehn <[email protected]> | ||
| * | ||
|
|
@@ -380,3 +380,48 @@ TEST(CustomIndexArray, resize_one_dimension) | |
| ASSERT_EQ(array.size().indices, std::make_tuple(Tag0{3}, Tag1{2})); | ||
| ASSERT_EQ(array.numel(), 6); | ||
| } | ||
|
|
||
| // Additional test for checking the set_multiple functionality | ||
| TEST(CustomIndexArray, setMultiple_validIndices) { | ||
| using ArrayType = mio::CustomIndexArray<int, Dim1, Dim2>; | ||
| // Initialize with zeros | ||
| ArrayType array({mio::Index<Dim1>(3), Dim2::Count}, 0); | ||
|
|
||
| // Define indices to set | ||
| std::vector<ArrayType::Index> indices = { | ||
| {mio::Index<Dim1>(0), Dim2::Male}, | ||
| {mio::Index<Dim1>(2), Dim2::Female} | ||
| }; | ||
|
|
||
| // Set these indices to 42 | ||
| array.set_multiple(indices, 42); | ||
|
|
||
| // Verify that the correct indices have been updated | ||
| EXPECT_EQ((array[{mio::Index<Dim1>(0), Dim2::Male}]), 42); | ||
| EXPECT_EQ((array[{mio::Index<Dim1>(2), Dim2::Female}]), 42); | ||
|
|
||
| // Verify that other indices are unchanged | ||
| EXPECT_EQ((array[{mio::Index<Dim1>(0), Dim2::Female}]), 0); | ||
| EXPECT_EQ((array[{mio::Index<Dim1>(1), Dim2::Male}]), 0); | ||
| EXPECT_EQ((array[{mio::Index<Dim1>(1), Dim2::Female}]), 0); | ||
| EXPECT_EQ((array[{mio::Index<Dim1>(2), Dim2::Male}]), 0); | ||
| } | ||
|
|
||
| TEST(CustomIndexArray, setMultiple_emptyIndices) { | ||
| using ArrayType = mio::CustomIndexArray<int, Dim1, Dim2>; | ||
| // Initialize with fives | ||
| ArrayType array({mio::Index<Dim1>(2), Dim2::Count}, 5); | ||
|
|
||
| // Empty vector of indices | ||
| std::vector<ArrayType::Index> indices; | ||
|
|
||
| // Attempt to set multiple indices to 42 | ||
| array.set_multiple(indices, 42); | ||
|
|
||
| // Verify that all entries remain unchanged | ||
| for (int age = 0; age < 2; ++age) { | ||
| for (int gender = 0; gender < static_cast<int>(Dim2::Count); ++gender) { | ||
| EXPECT_EQ((array[{mio::Index<Dim1>(age), static_cast<Dim2>(gender)}]), 5); | ||
| } | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.