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

Vector Migration by Genes. Now rebased off of latest. #64

Merged
merged 28 commits into from
Dec 14, 2024

Conversation

stitova-idm
Copy link
Collaborator

@stitova-idm stitova-idm commented Nov 22, 2024

regression tests: https://jenkins.apps.idmod.org/job/EMOD_Builds/job/scons_linux_all_regression/27/
sfts all: https://jenkins.apps.idmod.org/job/EMOD_Builds/job/scons_linux_all_sfts/28/ <-- failing the HIV/SFT/ARTMortalityTable/ARTDuration test: it is marked as "failing" in the hiv_science.json, so I think it's not an actual issue.

…netics files as I've created a separate script to create vector migration files
Copy link
Collaborator

@Bridenbecker Bridenbecker left a comment

Choose a reason for hiding this comment

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

Thank you for your hard work on this and for persevering through this complicated stuff.

The big thing to think about here is limiting the knowledge between objects. The more objects know about each other, the more coupled they become. This can make them difficult to test, reuse, and modify.

Because our emodpy-hiv schedule is borked, we might as well make these changes as well as change the metadata to JsonConfigurable.

BTW. Don't forget about using const reference when you can.

Eradication/IMigrationInfoVector.h Outdated Show resolved Hide resolved
Eradication/Migration.cpp Outdated Show resolved Hide resolved
Eradication/MigrationInfoVector.h Outdated Show resolved Hide resolved
Eradication/IMigrationInfoVector.h Outdated Show resolved Hide resolved
Eradication/VectorPopulation.cpp Show resolved Hide resolved
Eradication/VectorPopulation.cpp Outdated Show resolved Hide resolved
Eradication/VectorPopulation.cpp Outdated Show resolved Hide resolved
Eradication/VectorPopulationIndividual.cpp Outdated Show resolved Hide resolved
Eradication/MigrationInfoVector.cpp Show resolved Hide resolved
Eradication/VectorPopulationIndividual.cpp Show resolved Hide resolved
…9940, 0.999999940, 0.999999940, 0.999999940, 1] and that means there's a chance that things will migrate to the last index if somehow between 0.999999940 and 1 (I had similar issues with fractions migrating because we canculated things backwards from rcd and a very tiny difference ended up with dozens of vectors migrating to a node with migration 0). Now it's [0.333333, 0.666666627, 1, 1, 1, 1, 1, 1]
… resolving the floating point rounding issue by not back-calculating from rate_cdf and just uding the direct rates to figure out fraction traveling.
Copy link
Collaborator

@Bridenbecker Bridenbecker left a comment

Choose a reason for hiding this comment

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

Things are definitely getting better. Thank you for your perseverance.

Eradication/IMigrationInfoVector.h Outdated Show resolved Hide resolved
Eradication/IMigrationInfoVector.h Outdated Show resolved Hide resolved
Eradication/MigrationInfoVector.cpp Show resolved Hide resolved
Eradication/MigrationInfoVector.cpp Outdated Show resolved Hide resolved
Eradication/MigrationInfoVector.h Outdated Show resolved Hide resolved
Eradication/VectorPopulationIndividual.cpp Outdated Show resolved Hide resolved
Eradication/VectorPopulationIndividual.cpp Outdated Show resolved Hide resolved
Eradication/VectorPopulationIndividual.cpp Outdated Show resolved Hide resolved
componentTests/MigrationTest.cpp Outdated Show resolved Hide resolved
componentTests/MigrationTest.cpp Show resolved Hide resolved
stitova-idm and others added 5 commits December 3, 2024 09:43
- Changed the code that read the migration metadata so that it uses the standard JsonConfigurable code.
- Should not change any behavior except maybe error messages

Co-authored-by: Svetlana Titova <[email protected]>
Copy link
Collaborator

@Bridenbecker Bridenbecker left a comment

Choose a reason for hiding this comment

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

I think this looks great. Thank you for your hard work on this.

virtual void ConfigInterpolationType( const Configuration* config ) override { /* don't need to check it */ };
virtual void ConfigMigrationType( const Configuration* config, MigrationType::Enum& file_migration_type ) override { /* don't need to get it */ };
virtual void CheckMigrationType( const Configuration* config, const MigrationType::Enum file_migration_type ) override { /* don't need to check it */ };
virtual void ConfigDatavalueCount( const Configuration* config ) override;
Copy link
Collaborator

Choose a reason for hiding this comment

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

to be clear, you could put all of these parameters in two methods: one for configuring and one for checking. It doesn't have to be two methods for each parameter. The main idea is to use inheritance to change the configuration.

Eradication/Migration.cpp Outdated Show resolved Hide resolved
MigrationType::Enum file_migration_type = MigrationType::NO_MIGRATION; // default because needs to default to something coherent
ConfigMigrationType( config, file_migration_type );
ConfigInterpolationType( config );
ConfigDatavalueCount( config );
Copy link
Collaborator

Choose a reason for hiding this comment

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

I say this below, but you could just have one method that configures these three parameters and one method that checks them.

std::string offsets_str;
initConfigTypeMap( "NodeOffsets", &offsets_str, MigrationOffsetsData_NodeOffsets_DESC_TEXT );
initConfigTypeMap( "Metadata", m_pMetadata, MigrationOffsetsData_Metadata_DESC_TEXT );

Copy link
Collaborator

Choose a reason for hiding this comment

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

Note that I created two classes:MigrationMetadata and MigrationOffsets because that is the way the JSON was. We could have had one class if we could move all of the parameters that are used to the same level as NodeOffsets. If MetaData was really just comments, then it would be easier on the code. Typically, our code treats a JSON dictionary as an object and the elements of the dictionary as attributes/member variables of the object.

Eradication/MigrationInfoVector.h Show resolved Hide resolved
Eradication/IMigrationInfoVector.h Show resolved Hide resolved
@@ -10,6 +10,7 @@
#include "IdmString.h"
#include "RANDOM.h"
#include "INodeContext.h"
#include "config_params.rc"
Copy link
Collaborator

Choose a reason for hiding this comment

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

The migration data isn't part of config and the descriptions don't really have a home. I put some demographics descriptions somewhere....


std::streamoff offset = (indexGender * gender_size) + (indexAge * age_size) + m_Offsets.at( nodeID );
return offset;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Don't do anything. Just thinking out loud. After watching our videos on coupling and cohesion, I'm wishing this were right next to our code that calculates the expected binary file size. Hmm. It probably shows that it would be better if MigrationMetadata and MigrationOffsets were one class.

m_FileStream.read( reinterpret_cast<char*>(array_id), m_DestinationsPerNode * sizeof(uint32_t) );
m_FileStream.read( reinterpret_cast<char*>(array_rt), m_DestinationsPerNode * sizeof(double) );
m_FileStream.read( reinterpret_cast<char*>(array_id), destinations_per_node * sizeof(uint32_t) );
m_FileStream.read( reinterpret_cast<char*>(array_rt), destinations_per_node * sizeof(double) );
Copy link
Collaborator

Choose a reason for hiding this comment

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

More thought exercise. Assume MigrationMetadata and MigrationOffsets is really one thing. Would it be more cohesive if the "destinations_per_node * sizeof(xxx)" where in this combined class? Hmm.

@@ -15,296 +17,136 @@ namespace Kernel
#define MODIFIER_EQUATION_NAME "Vector_Migration_Modifier_Equation"
#define MAX_DESTINATIONS (100) // maximum number of destinations per node in migration file


#define MMV_AlleleCombinations_DESC_TEXT "An array of allele combinations (pairs of alleles) to use for mapping migration rates to in the migration binary file. Depends on GenderDataType=VECTOR_MIGRATION_BY_GENETICS."
Copy link
Collaborator

Choose a reason for hiding this comment

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

did you want to put this in config_params.rc?

@stitova-idm stitova-idm merged commit ff0669f into EMOD-Hub:main Dec 14, 2024
1 check passed
@stitova-idm stitova-idm deleted the gh_4979_updated branch December 14, 2024 01:32
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.

2 participants