[Paper Review] ModelicaGym
ModelicaGym is a toolbox that integrates Modelica-based dynamic system models with OpenAI Gym to enable reinforcement learning (RL) for optimal control and optimization tasks. By leveraging FMI for model exchange and supporting Q-learning, it enables efficient RL algorithm development and comparison, validated on a Cart-Pole balancing task with parameter sensitivity analysis.
This paper presents ModelicaGym toolbox that was developed to employ Reinforcement Learning (RL) for solving optimization and control tasks in Modelica models. The developed tool allows connecting models using Functional Mock-up Interface (FMI) to OpenAI Gym toolkit in order to exploit Modelica equation-based modeling and co-simulation together with RL algorithms as a functionality of the tools correspondingly. Thus, ModelicaGym facilitates fast and convenient development of RL algorithms and their comparison when solving optimal control problem for Modelica dynamic models. Inheritance structure of ModelicaGym toolbox's classes and the implemented methods are discussed in details. The toolbox functionality validation is performed on Cart-Pole balancing problem. This includes physical system model description and its integration using the toolbox, experiments on selection and influence of the model parameters (i.e. force magnitude, Cart-pole mass ratio, reward ratio, and simulation time step) on the learning process of Q-learning algorithm supported with the discussion of the simulation results.
Motivation & Objective
- To bridge Modelica's equation-based modeling with reinforcement learning via OpenAI Gym.
- To enable fast prototyping and comparison of RL algorithms on dynamic system models.
- To support optimization and control tasks in complex physical systems using RL.
- To validate the toolbox on a benchmark Cart-Pole balancing problem.
- To analyze the influence of key model and RL parameters on learning performance.
Proposed method
- The toolbox uses Functional Mock-up Interface (FMI) to interface Modelica models with the OpenAI Gym environment.
- It implements a Gym-compatible environment wrapper that translates Modelica model states and actions into RL-compatible observations and rewards.
- The system supports Q-learning as the primary RL algorithm for policy learning.
- It enables parameter tuning of model dynamics (e.g., force magnitude, mass ratio) and RL hyperparameters (e.g., reward ratio, time step).
- The inheritance structure of ModelicaGym classes is designed for extensibility and modular integration of new models and algorithms.
- The integration pipeline allows co-simulation of Modelica models within the RL training loop.
Experimental results
Research questions
- RQ1How effectively can ModelicaGym enable RL training on Modelica-based dynamic systems?
- RQ2What is the impact of force magnitude on Q-learning convergence in the Cart-Pole task?
- RQ3How do the Cart-pole mass ratio and simulation time step affect learning stability and performance?
- RQ4How does the reward ratio influence the learning process and final policy quality?
- RQ5To what extent can the toolbox support systematic parameter sensitivity analysis in RL for physical systems?
Key findings
- ModelicaGym successfully enables end-to-end RL training on Modelica models via FMI and OpenAI Gym integration.
- The force magnitude significantly affects learning speed and convergence, with optimal values improving training efficiency.
- The Cart-pole mass ratio influences the difficulty of control, with higher ratios requiring more training steps to stabilize.
- The simulation time step has a notable impact on learning stability, with smaller steps generally yielding more reliable learning.
- The reward ratio plays a critical role in shaping the learning signal, with improper settings leading to suboptimal or unstable policies.
- The toolbox enables systematic exploration of parameter effects, demonstrating its utility for comparative RL studies.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.