HIGHLIGHT hook to self scheduling or trigger attribute - openmpp/openmpp.github.io GitHub Wiki

Home > Model Development Topics > Highlight Topic

Self-scheduling and trigger derived attributes can be very convenient in model code. For example, self_scheduling_int(time) implicitly creates a hidden event which implements an annual calendar clock which updates the attribute.

OpenmM++ takes self-scheduling and trigger attributes to another level by allowing hooks to them.

So, for example, one can do

entity Person {
   hook NewYear, self_scheduling_int(time);
};

to call the model-specific entity function Person::NewYear() when time crosses an integer boundary, without having to explicitly code a clock-like event in model code.

Here's another example which outputs microdata at age 65 using the built-in entity function write_microdata.

entity Person {
   int integer_age = self_scheduling_int(age);
   hook write_microdata, trigger_entrances(integer_age, 65);
};

For a bit more on this, see the Entity Function Hooks wiki topic.

⚠️ **GitHub.com Fallback** ⚠️