Case 1

X-Language Case 1: The Case of Self-Driving Cars

  In order to demonstrate the co-simulation capability of X language under hybrid models, a part of the process based on the actual driving model is simplified and the simplified driving model is modeled using three modules: continuous, discrete, and intelligent body.

Fig. 1 Driving Model Component Structure Diagram

  The model structure of the driving model is shown in Fig. 1, where car1 is a manned car, or understood as "intelligent car", and car2 is an unmanned car, or understood as "non-intelligent car". car1 contains three types of models, namely, the driver module composed of intelligent body models, the car module composed of discrete models, and the power module composed of continuous models. Car1 contains three types of models, namely, driver module composed of intelligent body models, car module composed of discrete models, and power module composed of continuous models. Car2, on the other hand, contains only one discrete model, which is used to interact with car1. In order to show the whole modeling and simulation process based on X language more clearly, the interaction logic and sequence between each model are clearly defined, as shown in Fig. 1. The intelligent body model driver first makes decisions using the trained policies and passes the action results to the discrete model car, the car module passes the driver's actions to the power module to generate feedback on the car's dynamics based on the actions, and finally the car changes its actual position based on the amount of change returned by power, and affects the environment by sending it to the The car changes its actual position according to the changes returned by power, and sends it to the environment to influence the position of car1 in the environment, thus completing a cycle of car1's movement. During this process, the environment also collects the position of car2 and feeds back to car1, so that car1 can actively avoid car2 to prevent accidents. The whole model simulates the system model of driving a car in the real world, which consists of three types of models: continuous, discrete, and intelligent body in X language. In order to show the modeling process based on the X language more clearly than a better simulation of the real scenario, we have rationally simplified the complex dynamics process, the dynamic environment, and the multi-type interaction process.

Fig. 2 Driving top-level model definition diagram

Figure 3 Driving top-level model connection diagram

  For this case, this paper first establishes the top-level model of the whole driving model (including both graphical modeling and textual modeling), which is composed of one driver, two vehicles, one vehicle powertrain module, and one given environment module. The definition diagram of the system design of the whole system as well as the connection diagram are shown in Figures 2 and 3, where the diagram defines the constituent modules of the whole system and the connection diagram defines the connection relationship between the modules. The simulation text of the top-level model of the whole system is given in Fig. 4. After that, this paper models each module in the whole system in detail (including both graphical modeling and textual modeling forms) . For example, Fig. 5 and Fig. 6 describe the structure and behavior of the car module in car1 by designing its definition diagram and state machine diagram, respectively. The simulation text of the car module is given in Fig. 7. Finally, all the simulation texts are interpreted through the X language interpreter for simulation to obtain the simulation results.

Fig. 4 Driving top-level model simulation text

Fig. 5 Definition diagram of car model in car1

Fig. 6 State machine diagram of car model in car1

Fig. 7 Simulation text of the car model in car1

Simulation results

  Based on the above model description, the simulation results of the driving model are visualized as shown in Fig. 2. The three diagrams (a), (b), and (c) represent the three interaction stages that car1 goes through with car2 on the way to the destination, in each interaction car1 stops its current action and waits for car2 to move away before acting again, and figure (d) shows the complete trajectory of car1 from the initial position to the final position. In the simulation results shown in Fig. 2, each step of car1 goes through the t1-t9 interaction process shown in Fig. 1.

(a)(b)

(c)(d)

Fig. 2 Schematic diagram of driving model simulation

  Since the X language emulator is built following DEVS, there is a time advancement process of discrete events during the running of the module, as shown in Figure 3 for the whole system. The horizontal coordinate shown in Figure 3 is the simulation advancement time, while the vertical coordinate represents the transfer order of the output events and external events of the underlying atomic model simulator corresponding to different kinds of models described by the X language, e.g., driver watchfor ext and driver watchfor output represent the external event transfer and output of the atomic model of the driver plan, respectively. function, the process of internal event transfer is included in the process of the output function, which is consistent with the event transfer process of the DEVS atomic model itself.

  From Fig. 3, it can be found that the running order of the whole model is consistent with the modeling order in Fig. 1, reflecting the simulation process of the coupled model consisting of continuous, discrete and intelligent body models. Among them, the power output will exist continuously throughout the simulation and produce interactive behaviors with the car model when the interaction conditions are satisfied. The simulation process of the intelligent body is consistent with the operation of the discrete model due to the nature of its discrete model.

  The driving model case gives the support of X language for continuous, discrete, and intelligent body models from both modeling and simulation perspectives, and demonstrates the modeling process of X language in multi-domain complex models.

Fig. 3 Simulation time advancement of the underlying atomic model of the driving model