Day 04: In-Class Assignment: Practice Collaboration with Git and GitHub#

image credit: chatGPT 4o prompt: “Make an image representing git collaboration and solve_ivp”

Student Identification#

Please do not modify the structure or format of this cell. Follow these steps:

  1. Look for the “YOUR SUBMISSION” section below

  2. Replace [Your Name Here] with your name

  3. If you worked with groupmates, include their names after your name, separated by commas

  4. Do not modify any other part of this cell

Examples:

Single student:  John Smith
Group work:      John Smith, Jane Doe, Alex Johnson

YOUR SUBMISSION (edit this line only):

✅ [Your Name Here]

Note:

  • Keep the “✅” symbol at the start of your submission line

  • Use commas to separate multiple names

  • Spell names exactly as they appear in the course roster

  • This cell has been tagged as “names” - do not modify or remove this tag

Table of Contents#

Learning Goals#

By completing this assignment, you will:

  1. Gain practical experience with collaborative software development using Git and GitHub.

  2. Apply your knowledge of computational modeling to implement and extend a chosen model.

  3. Practice using SciPy’s solve_ivp function for solving differential equations.

  4. Develop skills in data visualization and result interpretation.

  5. Enhance your ability to document code and explain complex systems.

  6. Gain experience in extending existing models and analyzing the implications of these extensions.

Project Options#

Choose one of the following models to implement and extend:

1. SIR (Susceptible, Infected, Recovered) Model#

The SIR model is a fundamental tool in epidemiology for understanding the spread of infectious diseases. It divides a population into three compartments: Susceptible (S), Infected (I), and Recovered (R). This model is widely used to predict the course of epidemics and evaluate intervention strategies.

Equations:

\(\frac{dS}{dt} = -\beta \frac{SI}{N}\)

\(\frac{dI}{dt} = \beta \frac{SI}{N} - \gamma I\)

\(\frac{dR}{dt} = \gamma I\)

Where \(\beta\) is the transmission rate, \(\gamma\) is the recovery rate, and \(N\) is the total population.

2. Predator-Prey Model (Lotka-Volterra equations)#

The Predator-Prey model, also known as the Lotka-Volterra equations, describes the dynamics between two interacting populations: predators and their prey. This model is crucial in ecology for understanding population cycles and the balance of ecosystems.

Equations:

\(\frac{dx}{dt} = \alpha x - \beta xy\)

\(\frac{dy}{dt} = \delta xy - \gamma y\)

Where \(x\) is the prey population, \(y\) is the predator population, and \(\alpha\), \(\beta\), \(\delta\), and \(\gamma\) are parameters describing the interaction.

3. Daley-Kendall Model (Rumor Spreading)#

The Daley-Kendall model simulates the spread of information or rumors through a population. It’s particularly relevant in today’s world of social media and rapid information dissemination. The model categorizes individuals as Ignorants (I), Spreaders (S), and Stiflers (R).

Equations:

\(\frac{dI}{dt} = -\alpha IS\)

\(\frac{dS}{dt} = \alpha IS - \beta S(S+R)\)

\(\frac{dR}{dt} = \beta S(S+R)\)

Where \(I\) are Ignorants, \(S\) are Spreaders, \(R\) are Stiflers, \(\alpha\) is the spreading rate, and \(\beta\) is the stifling rate.

4. Population Growth Model#

The Population Growth model, often represented by the logistic equation, describes how a population changes over time considering limiting factors such as resource availability. This model is fundamental in ecology, biology, and resource management.

Equation (logistic growth):

\(\frac{dN}{dt} = rN(1 - \frac{N}{K})\)

Where \(N\) is the population size, \(r\) is the intrinsic growth rate, and \(K\) is the carrying capacity.

Skeleton code for each model will be provided in separate files. Choose the model that interests you most or aligns best with your research interests!

Today’s Tasks#

For today’s in-class assignment, you will work in groups to implement one of the computational models listed above. Here’s what you need to do:

  1. Form Groups and Choose a Model (5 minutes)

    • Form groups of 3-4 students.

    • Choose one person to be the “project owner”.

    • As a group, select one of the four models to work on.

  2. Set Up the Repository (10 minutes)

    • The project owner should create a new GitHub repository and add group members as collaborators.

    • Other group members should fork and clone the repository.

  3. Divide Tasks (5 minutes)

    • Assign each group member specific functions to implement from the skeleton code.

  4. Implement the Model (40 minutes)

    • Work on your assigned functions.

    • Use git to commit your changes frequently.

    • Push your changes to your fork or branch.

  5. Code Review and Merging (15 minutes)

    • Create pull requests for your implemented functions.

    • Review each other’s code and provide feedback.

    • Merge approved changes into the main branch.

  6. Documentation (5 minutes)

    • Update the README file with a brief project description and usage instructions.

  7. If Time Permits: Extend the Model

    • If you complete the above tasks before the end of class, discuss and begin implementing an extension to your model.

    • This could involve adding a new feature, modifying the equations, or exploring different parameter sets.

Remember to communicate with your team throughout the process and use git/GitHub features like issues for discussion if needed.

Specific Task Instructions#

Follow these steps to complete your chosen project:

  1. Download Skeleton Code (Project Owner)

    • Use curl to download the skeleton code for your chosen model:

      curl -O https://raw.githubusercontent.com/msu-cmse-courses/cmse802-supplemental/main/DailyMaterial/scripts/[ModelName]-model-skeleton.py
      
    • Replace [ModelName] with the appropriate name for your chosen model (e.g., sir, predator-prey, daley-kendall, or population-growth).

  2. Repository Setup (Project Owner)

    • Create a new private GitHub repository named “[ModelName]-GroupXXXX” (XXXX are the first letter of your first names)

    • Initialize with a README.md file. The file should contain the full name of each of you and then explain the chosen model and your planned extension

    • Add the downloaded skeleton code file for your chosen model

    • Add team members as collaborators

  3. Fork and Clone (All team members except Project Owner)

    • Fork the project owner’s repository

    • Clone your fork to your local machine

  4. Branch Creation (All team members)

    • Create a new branch named feature-YourName

    • Switch to your new branch

  5. Code Implementation (Divide these tasks among team members)

    • Implement set_initial_conditions()

    • Implement set_parameters()

    • Implement solve_model() using solve_ivp

    • Implement plot_results()

    • Collaborate on extend_model() and modify other functions as necessary for the extension

  6. Commit and Push (All team members)

    • Stage your changes

    • Commit your changes with descriptive messages

    • Push your branch to your fork (or the main repository for the Project Owner)

  7. Create Pull Requests (All team members except Project Owner)

    • Create a new pull request from your feature-YourName branch to the main branch

    • Provide a clear title and description for your pull request, explaining your contribution

  8. Code Review and Merging (Project Owner)

    • Review each pull request

    • Provide feedback or request changes if necessary

    • Merge approved pull requests into the main branch

  9. Sync and Test (All team members)

    • Once all pull requests are merged, sync your local main branch

    • Test the full implementation to ensure both basic and extended models work as expected

  10. Documentation (All team members)

    • Update the README.md with:

      • Detailed project description, including your chosen extension

      • Mathematical background of the model

      • Usage instructions

      • Sample output and interpretation

    • Add comprehensive comments to the code explaining key parts and your extension

  11. Final Submission

  • Ensure the final code is in the main branch of the original repository

  • Each team member should write a brief reflection on:

    • Their experience with the git workflow

    • The challenges and insights gained from extending the model

    • Potential real-world applications or further extensions of the model

  • Submit the final python script of the model to D2L and include the repository link.

Remember to commit often and communicate with your team throughout the process. Use GitHub’s issues feature if you need to discuss specific points or problems.

Congratulations, you’re done with your in-class assignment!#

Now, you just need to submit this assignment by uploading it to the course Desire2Learn web page for today’s in-class assignment submission folder. (Don’t forget to add all of the appropriate names in the first cell).

© Copyright 2024, Department of Computational Mathematics, Science and Engineering at Michigan State University