Monitoring Variables

Monitoring Variables — How to monitor variables using CpgMonitor

Monitoring

It's often useful to monitor a specific property in the network and output or collect the values of this property at each time step. Although you can quite easily do this manually by getting the property you want to monitor from some object in your network and at each timestep get its value (see Making a Network), a special class is included in the library that makes it easier to manage and retrieve property values values while running the network.

Using a CpgMonitor is quite straightforward. You first construct a new CpgMonitor using cpg_monitor_new, providing the network, object and property to monitor during simulation. Once constructed, the monitor will automatically collect property values at each simulation step. To retrieve the values of the property at any time, you can use cpg_monitor_get_data. If you want to resample the data at specific times, you can use the convenience function cpg_monitor_get_data_resampled.