Blog: GSoC’21 at Red Hen Labs

Ankit Gupta
15 min readMay 23, 2021

--

This blog will get updated with time as the project progresses

Student ID: ankiitgupta7

Hello there!

I am a final-year engineering student from the Indian Institute of Technology, Kharagpur (IIT-KGP). I am very excited to be part of Google Summer of Code 2021 as I have been contributing to open-source since my early years of starting university. You can learn more about me through my personal website. As a student developer, I will be working for Red Hen Labs and this blog is to document my weekly progress on the project that I have proposed to work on. For the project summary listed on the official Google Summer of Code website please follow this link. And please look here for the accepted project proposal.

Project Details

Mentors

Francis Steen (Primary), Maria Hedblom, Mark Turner, Cristóbal Pagán Cánovas, & Javier Valenzuela.

Abstract

The thought experiments by Valentino Braitenberg that lead to the creation of Braitenberg Vehicles (BVs) help us in very robust modeling of basic emotions emerging from simple neuronal wiring. These emotional responses can be utilized in modeling predator-prey behavior in an ecological setup. Here I propose simulating vervet monkeys’ (Cercopithecus aethiops) behavioral aspects, especially how they deal with predators in an ecological setting. Vervet monkeys give acoustically different alarm calls to different predators and hence show signs of semantic communication. I will use my already developed agent-based BV simulation platform in developing this simulation, primarily focusing on the communication aspects in vervets.

Progress Report

I have divided the project into 4 phases to be completed after the coding period begins.

Community Bonding Period (May 17 — June 6, 2021)

  • Started a GitHub repository dedicated specifically for this project. Project GitHub page can be reached out through this link.
  • Attended the Red Hen mass video conference consisting of all the students and mentors.
  • Activated the Case Western Reserve University email to access HPC.
  • Imported my Braitenberg Vehicle development environment to be used for vervet simulation development environment. Changes in this development environment are due in the first week.
  • Pushed a total of 6 commits to this project’s GitHub repository making changes in the code to make the development platform more suited for the simulation plan. Most importantly adding the Field of View feature for agents is crucial for their visual awareness. Also added some more customizations to the simulation user interface.
  • And lastly, even though it is not directly related to the details of the project, I am happy to announce that I recently received confirmation on being awarded a fully-funded MS scholarship along with a living stipend, I will move by August end. So GSoC timeline is fitting quite nicely in this scenario too.

Coding Period Begins (June 07, 2021)

Phase 1: Setting up the environment and optimize parameter dependencies

Week 1 (June 07 — June 13)

As per the timeline of plans in my GSoC proposal, I spent this week working on fine details of the simulation development, e.g., working on the environment outlook, how to represent hideout locations, and resource distribution and finalizing the simulation’s parameter dependencies.

More importantly, I had a very fruitful hour-long meeting with Prof. Steen and Maria. Following are the minutes of that meeting,

  • One of the main goals of the simulation should be to efficiently model representational communication through an agent-based model and show how the differential meaning of vervet’s alarm calls is helping in their survival.
  • The simulation development should start with a limited number of variables to have a simple yet accurate representation of the situation in the early stages and then further nuances can be incorporated later on.
  • Got recommended to check out the book, Surfing Uncertainty: Prediction, Action, and the Embodied Mind by Andy Clark.
  • The initial focus to be on hunger vs fear and how the vervets deal with it. Also, to determine the fear factor, we should consider vervets to have a limited memory stack. Hunger level to modeled as a function of energy level (fitness) of a vervet.
  • Each one of the hideouts guarantees a high chance of safety from a particular predator, but safety from the other two types of predator is significantly low.
  • In the early stages of the simulation, the predators are set to be randomly moving across the environment.

Week 2 (June 14 — June 20)

Its been a productive week as I implemented much of the details planned related to the environment, and we have started to get a holistic picture of the vervet simulation looking at the environment. Take a look at the environment below in the present state of development,

Monkeys behaving like Ants for the time being :)

To list this week’s developmental updates,

  • Introduced three different types of stimulus into the environment and modeled the cowardly response of vervets towards them.
  • Programmed appropriate resource representation as well the hideout locations as suggested in the last call.
  • Started working on modeling alarm calls and vervets fleeing to respective hideouts on confronting predators. Would continue to work on this the next week.
  • And most importantly I suppose, I got my second and final dose of the COVID-19 vaccine. Got out of the house after one month and 2nd time in three. :)

Also, I had another productive meeting with Prof. Steen and Prof. Mark Turner, both of whom gave some insightful advice on the next steps of simulation development. Following are some major issues we talked about along with updating them with my progress,

  • Prof. Turner suggesting the need to make the simulation flexible enough to make it useful beyond vervets simulation.
  • Prof. Steen talked about the need for different field of view parameters for vervets in spotting different predators. We also discussed the strategy to represent hideouts and resource distribution.
  • Prof. Steen suggested to not worry about agents running into each other and address the collision issue later. Maybe after completely developing alarm calls and modeling the ecosystem.
  • We also had a brief discussion on limiting the number of agents in the simulation environment.

Phase 2: Modelling direct interaction between vervets and predators

Week 3 (June 21 — June 27)

Like before, I started working on the pending issues, adding some more features to the simulation, and had the usual meeting on Thursday with Professor Steen to discuss the next steps in the simulation development. I will talk one by one about the developmental updates, takeaways from the call, and the next big things on agenda for the upcoming weeks. Currently, the vervets just run from one hideout to another running away from predators.

Weekly Update:

  • Implemented the feature enabling vervets to run into hideouts corresponding to each predator as they become visually aware of a predator.
  • It should be noted that even after the predator goes out of sight, the vervets keep moving for some time (represented by a variable safeTime to be tweaked further as we start modeling foraging) towards the hideout and in the process. If they see another predator they run towards the other appropriate hideout.
  • Added the agent awareness representation feature towards different predators.
  • Tested the simulation in various scenarios, documented the code, and pushed it on the GitHub repository dedicated for this project. Track the changes here.

Minutes of the Meeting:

  • Updated about the latest developments.
  • Prof. Steen suggested to not let any of the predators enter their corresponding hideout.
  • We discussed the situation when the vervet spots multiple predators at a moment and decided that the vervet will take action with respect to the nearest predator.
  • Agreed upon having different values of the predator speed as snakes move much slower than leopard and eagle.
  • Discussed who gives the first alarm call when a predator appears and decided that the first vervet who spots the predator will give the alarm call. Also, the alarm calls will occur at a particular interval specific to each predator. Also, auditory awareness of the alarm calls to be accessible to vervets in the visual awareness radius only, but with 360 degrees spread than 240 degrees in case of visual awareness.
  • Also, discussed the modeling of vervets’ motion as they forage. The vervets will go to the nearest available reserve, explore their surroundings, and move in the direction of maximum reserves. The hunger vs fear factor will kick in after energy levels are introduced later on.
  • Discussed having a toggle button in the UI to switch on and off a particular simulation feature.

Next on Agenda:

  • Modeling hideout safety of vervets.
  • Fixing minor glitches / undesired behaviors in the simulation, developed as of now.
  • Solving the vervet’s dilemma of choosing between reacting to multiple predators.
  • Modeling alarm calls.
  • Modeling energy levels and the foraging strategy.

Phase 3: Restricting interaction and modeling alarm calls

Week 4 (June 28 — July 04)

This week, I worked on many impending minor issues and wrote code for modeling the alarm calls, which are yet fully functional. Had a weekly call as usual with Prof. Steen and Maria as we discussed the developments and impending issues.

Weekly Update:

  • Made changes to stimuli movements preventing them to enter their corresponding vervet refuge locations.
  • Programmed vervets to not get affected by a predator when inside its corresponding refuge.
  • Gave different appropriate movement speed to each predator. Also, assigned different field of view parameters to vervets for each predator.
  • Programmed vervets to make an informed decision about choosing a single nearest predator to react to when facing multiple predators.
  • Programmed alarm calls but facing some issues in getting the desired outcome.

Minutes of the Meeting:

  • Updated about latest developments.
  • Change the “hideout” name to “Refuge”.
  • Agreed on single value radius for auditory awareness.
  • Explained the part of the code where the vervet scans the environment and only responds to the ones which they directly see or get the alarm call. Prof. Steen talked about keeping in mind that vervets awareness come at some cost so that should be kept in mind while modeling energy level.*
  • Keeping a reasonable proportionality between the number of frames vs real-time as well as the number of pixels vs real-distance to make the simulation as realistic as possible.*
  • Limit the number of predators to three, one each.
  • Maria suggested adding a feature in which resources keep popping up in random patches.*

Next on Agenda:

  • Finishing alarm call implementation.
  • Modeling foraging.
  • Implementing energy levels.
  • Modeling Hunger vs Fear.

Week 5 (July 05 — July 11)

This week I continued working on modeling alarm calls in vervet monkeys, which is now successfully implemented. Also, I started working on implementing energy levels as well as modeling fitness and foraging strategy, to eventually boil down to address the issue of Hunger vs Fear. And we had more than an hour-long discussion with Prof. Steen and Maria, where we discussed the details of alarm call implementation and had a thorough discussion about the next things on agenda.

Weekly Update:

  • Completed implementing alarm calls in vervets.
  • Pushed code on the dedicated GitHub repository, changes can be tracked through this commit.
  • Made a simulation workflow of alarm calls and foraging separately which eventually leads to tension between Hunger vs Fear. And as a result of that, the vervet will decide to forage or flee to the refuge area depending on the value of the Hunger parameter or Fear parameter, whichever is higher.
  • Planned the implementation of energy level, foraging strategy, and modeling fear levels.

Minutes of the Meeting:

  • Ran through the timeline of plans in my proposal accepted and turns out at the end of week 5, I am already done with my minimum set of deliverables at the end of week 7 in my original project proposal.
  • Ran a demo of the implemented alarm calls, running special cases of simulations in which alarm calls are more evident. And explained the consequences of alarm calls leading to more areas being influenced due to a predator.
  • Noted a point to better implement the situation when a vervet is alarmed about a leopard and it spots another leopard in the process of fleeing to a leopard refuge.*
  • Maria pointed out the natural need for louder alarm calls for faster predators. Prof. Steen suggested coming back to this after implementing foraging. So another way is to let this optimization be an emergent phenomenon from learning or evolving over time.*
  • Discussed representing alarm calls and the ones who make the call. Also, was recommended to use different color coding of vervets alarmed from direct visual awareness and those from alarms calls. Decided to use circles of auditory awareness radius around the vervets giving alarm calls.
  • Prof. Steen suggested about vervets alarmed by predators being the only source of the fear level. Also, the vervets initial energy levels to be half of the maximum.
  • Vervets moving loses energy. Represent fear level with color, so the white color in the present simulation will get replaced by gradual fading out as fear level decreases. The opportunity cost of vervets for being visually aware is greater than hearing auditory alarm calls.

Next on Agenda:

  • Addressing cases when the vervet faces multiple predators, for whom will it give the alarm?
  • Removing redundant alarm calls in an area at some time.
  • Representing alarm calls and the ones who make the call.
  • Implementing energy level and foraging in absence of predators. And then observe the behavior when predators are present. So here hunger vs fear is to be addressed here.
  • Hunger level and speed of vervets approaching a resource point.*

First Evaluations (July 12 — July 16)

Week 6 (July 12 — July 18)

This entire week, I was on a break as I went home to attend my brother’s marriage in Varanasi. Also, I had to visit my university to vacate my room as well as talk to academic deans to request early access to my final degree. I am currently back in Kolkata, where I am living in a renthouse till I leave for starting my MS in Taipei, Taiwan, sometime in mid-September.

Despite this break, I am still ahead of my proposed timeline by a week. This is because I completed a major feature of Phase 2 during the Community Bonding Period.

I am happy to share that I have passed the first evaluation along with some very encouraging remarks from my mentor. I am grateful for their continued support. As I am back on track now, I am looking forward to finishing the minimum deliverables quickly and start working on advanced issues!

Week 7 (July 19 — July 25)

This week I had a brief call with Maria and Prof. Steen, where I discussed the latest developments and future issues as after implementing alarm calls focus is on modeling foraging.

Minutes of the Meeting:

  • Gave a demo run highlighting the representation of vervets giving alarm calls.
  • Showed the implementation of energy levels of vervets which implicitly decide the value of hunger level.
  • Showed the stark difference in vervet’s responses without the presence of the alarm call feature. This feature can be toggled on and off through a button that I have introduced in the control UI.
  • Discussed foraging strategy of vervets and resource distribution plan. Finalized to use randomized patches instead of the single stretch of the area presently used.

On Agenda:

  • Redesign resource distribution.
  • Implement the foraging strategy of vervets.
  • Introduce fear level to invoke Hunger vs Fear response.
  • Model Hunger vs Fear response.

Phase 4: Handling population growth across generations

Week 8 (July 26 — August 01)

This week marked the successful implementation of one of the most important features of the simulation, i.e., modeling Hunger vs Fear. Along with this, I redesigned resource distribution. Also, implemented the foraging of vervets, which makes this week one of the most productive weeks in terms of getting outcomes.

Apart from working on implementations on the agenda, I had the usual weekly call with Prof. Steen and Maria (Prof. Maria now!) where we discussed the newly implemented functionalities and the next set of developments to follow.

I would also take this opportunity to congratulate Maria on joining as a Tenured Assistant Professor in her home country Sweden.

Minutes of the Meeting:

  • Gave a demo of successfully implemented

- redesigned resource distribution with randomized patches with customizable size and scattering.

- foraging strategy of vervets with respect to given resource distribution.

- fear levels leading to tussle with hunger level which makes the vervets decide whether to flee to refuge or forage food.

  • Discussed keeping the fear level values variable for different types of confrontation with predators.
  • Discussed modeling death by starvation and predation as well as consequences of these on the vervets alive.
  • Prof. Steen said to keep the population growth as an optional feature for the time being.
  • Discussed implementing undifferentiable alarm calls as well as logging the simulation data.

Next on Agenda:

  • Reorganize the agent’s “move” function.
  • Modeling the undifferentiable alarm calls.
  • Modeling agent death by starvation as well as by predation.
  • To be able to save the simulation data as output files.

Week 9 (August 02 — August 08)

With most of the core issues are already implemented, this week I worked on reorganizing the code, modeling death, implementing undifferentiated calls, and fixing some minor bugs.

In this week’s call, I also discovered another core issue to be implemented, i.e., periodic scanning of the environment by vervets and consequences of that.

Minutes of the Meeting:

  • Gave a demo of

- the redesign of the vervet’s “move” function that takes care of vervets’ movement.

- successfully modelled death of vervets by starvation as well as predation.

- the effects due to newly implemented undifferentiable alarm calls.

- new representation of vervets in the simulation. From now on, the brightness of vervet signifies it’s energy level. It is colored grey while foraging and of corresponding predator color when with fear of a predator.

  • Professor Steen suggested implementing periodic scanning of the environment by agents as while scanning, a vervet can’t forage but also loses some bit of energy.
  • We discussed all the data that we need to log that might be useful.

Next on Agenda:

  • Logging data in different parameter conditions. To start with we would need cumulative death overtime by starvation, predation, and also by each type of predator. Along with all these, we may check on the average energy/fear/hunger level of the agents.
  • Implement periodic scans by agents.
  • Make the death representation last for some perceptible number of frames.
  • Implement energy level and death in predators.
  • Modeling population growth of agents.

Week 10 (August 09 — August 15)

Being in the final week and hence the obvious showtime, I felt immense pleasure looking at the plots of simulation from the logged data. I got great feedback from Prof. Steen in the week’s call as well as the following email.

Minutes of Meeting:

  • Gave a demo of agent death by starvation as well as predation represented by a filled black circle and a square respectively.
  • Showed the plots of logged data resulting from with and without alarm call conditions.
Death vs FrameCount with 4 Predators each and 120 agents.
Death vs FrameCount with 4 Predators each and 300 agents.
  • Gave a demo of the agent population growth and functioning of the population growth toggle button.
  • Showed the implementation of the predator energy level and death from starvation if they don’t go get a get successful kill within a limited amount of time.
  • Discussed getting the parameter values tuned just right to regenerate the scenario realistically.
  • Prof. Steen gave me a go-ahead to redesign the agent’s “move” function to include periodic scans. I deliberately left implementing it this week as I wanted to be sure of the green signal from Prof. Steen as it will lead to a great deal of tumult in the existing codebase. The proposed simulation flow with periodic scans can be seen below.
Simulation Flow for Agent’s Movement

At the end of the final GSoC weekly call, we realized the need for some more time to give the finishing touches, given the scale of the simulation. With some minor tweaks to the present state of developments, we would go ahead and start mass data logging with a variety of parameter states. As we are mostly concerned with the comparative study of consequences arising in conditions with and without alarm call, the bulk of work to be done now would be to intelligently acquire data suitable for data analysis and come with plausible inferences.

The result obtained so far are already highly encouraging but we would need a lot more logged data to confirm our claim and maybe add something that even we didn’t expect. I will be on a week break to take care of my VISA processing but would return next week to continue working on this software simulation project to run some experiments after we are done with the tweaks.

I am listing the following yet to be implemented deveopments before we draw curtain to the project and publish our results.

  • Implementing the periodic scan feature of agents.
  • Logging cumulative distance travelled by each agent overtime.
  • Having a toggle button for opting out data logging or to only log data.
  • To discuss tuning all the parameters to a reasonable value. I will make list of all the crucial parameters that decide the fate of the simulation.
  • Having a monkey type outline of the agent instead of the currently shown insect like look.
  • Letting agent move as per the resultant velocity while they see a predator, resulting from avoiding the predator and fleeing to the refuge.
  • Develop a data logging system that saves simulation data in batches with varying conditions, i.e., simulation parameters.
  • Draw plots from these data and draw appropriate conclusion.

Final Evaluations (August 16 — August 30)

* indicates the feature is postponed to be developed at a later stage of development.

--

--

Ankit Gupta

PhD Student of Computer Science & Engineering at Michigan State University (Fall'23 - present). IIT-KGP Alumnus (Engineering UG, Batch of 2021).