Solution using Native Erl
There is a paper from Raftery et al from 2017 called "A new control strategy for high thermal mass radiant systems": https://escholarship.org/uc/item/5tz4...
This paper implements a Model Predictive Controller in EMS (Erl) natively. This might be a good starting point.
Resources including example IDFs etc are available at http://radiant.cbe.berkeley.edu/resou....
Using E+ v9.3.0+: the Python API
Since then, E+ actually implemented a Python API. See https://nrel.github.io/EnergyPlus/api...
It would be definitely easier to implement this using this Python API instead of using the built-in Erl language for EMS. Python packages such as simple-pid might be a great help to avoid reinventing the wheel.