Method for running R language and deploying machine learning algorithm in AnyLogic software environment
By building Java projects in AnyLogic software and developing bridging technology, the complexity of integrating R language machine learning in AnyLogic is solved, the prediction capability and performance of simulation models are improved, and the integration of simulation and machine learning is promoted.
Patent Information
- Application Number
- CN202411664984.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-20
- Publication Date
- 2025-04-01
- Estimated Expiration
- 2044-11-20
AI Technical Summary
There are complexities and technical challenges in the effective integration and use of R language machine learning methods in AnyLogic software environment, resulting in limited prediction capabilities and overall performance of simulation models.
Develop dedicated bridging techniques to run R language in AnyLogic and deploy machine learning algorithms by building a project Jar package based on the Java SE platform, defining global variables and parameters, handling debugging and testing logic, and porting project code to AnyLogic software environment.
It realizes running R language in AnyLogic software, improves the prediction capability and overall performance of simulation models, reduces the model's learning and use threshold for modelers to have the ‘simulation simulation + machine learning’ paradigm, and promotes the integration of simulation and machine learning disciplines.
Smart Images

Figure CN119739457A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of simulation and machine learning software development and secondary development, and specifically, relates to a method for running R language and deploying machine learning algorithms in an AnyLogic software environment. Background Art
[0002] Currently, there is no dedicated plugin library that supports running R in AnyLogic, a specific simulation software environment. The main reasons for this are: One is the technical complexity of bridging R and Java and integrating them into AnyLogic software.
[0003] First, the underlying code of the original AnyLogic software is Java, and it is impossible to call, identify, and run R in the software environment without any third-party plug-ins. Input will result in runtime errors, even program crashes, syntax errors, or invisible agents, etc. These errors show the huge difference between R and the simulation-oriented Java language, and also show that there is no way to directly execute R code in the AnyLogic software environment without taking any bridging technology and plug-in measures.
[0004] Therefore, given the complexity and difficulty of bridging between different assembly languages, API interface compatibility, and data structure matching, almost no developers are willing to invest in research and development.
[0005] The second is the huge differences in user groups and application fields between AnyLogic software and R language.
[0006] The current AnyLogic software is mainly a third-paradigm simulation and digital twin software, while the R language is mainly a fourth-paradigm data mining and machine learning tool. AnyLogic software adopts a high-priced license sales strategy, mainly targeting high-end commercial customers, which directly leads to the fact that AnyLogic is still impossible to be as well-known and popular as mathematical software such as MATLAB to this day, and is still in a community ecology of niche software. The R language is an open-source, free, and highly recognizable academic software and programming language. Therefore, there are huge differences in their user groups and application fields. There are few cross-technical talents and integrated R&D needs in the two fields, and there is not enough community ecological support and R&D funding.
[0007] CN202311765205.4 discloses a method for AnyLogic to interact with Python reinforcement learning algorithms. The underlying language for deploying reinforcement learning algorithms in AnyLogic software is Python, and the information framework for RL experiments is built based on the internal library Pypeline that has been developed and provided by AnyLogic, and various methods encapsulated using the Alpyne library. This is essentially an application integration innovation or a use process innovation. Both the Pypeline library (provided by Tyler Wolfe-Adam) and the Alpyne library (provided by Tyler Wolfe-Adam) are plug-in libraries that have been released and promoted internationally. The Pypeline library was developed by Tyler Wolfe-Adam, Chief AI Project Support Specialist at AnyLogic’s North American headquarters. It is an API library plug-in specifically for AnyLogic to interact with Python. It can connect to the locally installed Python, assist in using Python libraries, and call functions such as reinforcement learning, data processing, and data display. It can be said that the Pypeline library is not only a major technological leap in AnyLogic model development, but also provides unlimited creative possibilities for R&D teams that pursue efficiency and innovation.
[0008] However, the Pypeline library still does not solve the following important problems: First, the Python language is bridged using the Pypeline library for deploying machine learning or reinforcement learning in AnyLogic simulation models. This cannot be executed directly in AnyLogic, but is indirectly executed by compatible platforms (such as Alpyne, Pathmind, or Bonsai). The operation process is complicated and the threshold for use is high.
[0009] Second, for machine learning or reinforcement learning tasks, the learning curve of Python is usually steeper than that of R, and the rate of return is also lower. On the one hand, Python's syntax is more complex than R, and more codes are required to achieve the same functions as R, while R is more intuitive to use and more suitable for rapid prototyping. On the other hand, from the perspective of the language ecosystem and community support, R has more unified tools and packages for statistical analysis and machine learning, as well as more centralized learning resource support, and many models and methods have been encapsulated into easy-to-use functions. However, many of Python's libraries and frameworks in the field of machine learning have different uses and practices. Users need to master a lot of basic knowledge to use different Python libraries and frameworks, and the size of Python libraries and frameworks is often much larger than the corresponding function libraries of R, which affects its popularity. Summary of the invention
[0010] The technical problem to be solved by the present invention is to provide a method for running R language and deploying machine learning algorithms in the AnyLogic software environment. The method overcomes the complexity and technical challenges of effectively integrating and using R language machine learning methods in AnyLogic, and improves the predictive ability and overall performance of the simulation model.
[0011] To solve the above technical problems, the technical solution adopted by the present invention is: a method for running R language and deploying machine learning algorithms in AnyLogic software environment, comprising the following steps: S1. Build a Jar package of the project based on the Java SE platform to carry the sub-packages and their interrelationships of the methods for running R language and deploying machine learning algorithms in the AnyLogic software environment; S2. Build the main project package to define global variables and parameters, centralize debugging and testing logic, and provide a centralized entry point for potential future modifications and extensions; The main package of the project includes two first-level sub-packages, namely the first-level sub-package and the second-level sub-package: the first-level sub-package includes several core Java classes, which are composed of two second-level sub-packages, one of which is used for statistical simulation, sample generation and data analysis, and the other is used to handle various exceptions that may occur when Java and R languages interact; the second-level sub-package is used to provide themes, styles and format management for R language drawings in the Java environment for simulation; S3, porting the project code data constructed in steps S1 and S2 to the AnyLogic software environment, and using AnyLogic software to package the active objects contained in the project into a plug-in library that complies with the AnyLogic software communication specification, and exporting the plug-in library to the AnyLogic software in the form of an independent Jar package; S4, inserting the exported plug-in library into AnyLogic IDE for testing and use; S5. Conduct R code pre-experiments in the R language environment, and bridge the AnyLogic environment with the mainstream machine learning packages of the R language through the first-level sub-packages to build a paradigm ecosystem for the new research method of "machine learning + simulation".
[0012] The present invention provides a method for running R language and deploying machine learning algorithms in the AnyLogic software environment, which has the following beneficial effects: 1. This invention promotes the disciplinary integration and paradigm innovation of the third paradigm of simulation represented by AnyLogic software and the fourth paradigm of machine learning and data mining in the era of big data (R language machine learning); the simulation of the third paradigm often relies on physical laws and empirical models, while the data-driven approach of the fourth paradigm emphasizes analysis and mining based on data rather than rules. This combination can improve the accuracy and predictability of simulation while ensuring the reliability of the model and utilizing the enriched information of big data; simulation can be tested and verified before actual implementation, and machine learning can evaluate uncertainty through probabilistic models. The combination of the two can further reduce the cost and risk of projecting experimental scenarios into reality; traditional simulation methods often have difficulty capturing the complex nonlinear relationships in the real world, while machine learning can effectively handle these complex nonlinear relationships, making the simulation results closer to the real situation.
[0013] 2. The present invention improves the model development efficiency of the new simulation paradigm with machine learning features represented by AnyLogic software; the underlying language of AnyLogic software is Java, but in fact Java is not good at algorithmic tasks of machine learning and reinforcement learning, especially compared with Python and R; compared with Java, Python and R both have a large and active machine learning ecosystem, and although Java also has a small number of machine learning libraries (such as Weka and Deeplearning4j, etc.), its overall ecology is relatively weak, the update speed is slow, and it lacks rich resources and support like Python and R, which limits the development efficiency of models with high performance requirements for machine learning; Python and R have rich machine learning libraries and frameworks, such as Scikit-learn, TensorFlow, Keras, PyTorch (Python) and caret, randomForest, mlr3verse, tidymodels (R) libraries, etc., which provide advanced and user-friendly APIs for rapid development and experiments; in contrast, Java has a small number of machine learning libraries, which are relatively low-level in design, require more code to complete the same task, and have relatively low development efficiency.
[0014] 3. The present invention has successfully developed a dedicated bridging technology for the simulation-oriented Java language in AnyLogic, overcoming the integration complexity problems between high-level assembly languages regarding operating environment and interface design, and greatly reducing the learning and use threshold for modelers of the new paradigm of "simulation + machine learning".
[0015] 4. The present invention makes it possible to use R language in AnyLogic’s Java language environment through assembly language bridging technology, and then with the help of R language’s powerful machine learning capabilities, the inherent capabilities of simulation modeling in the fields of predictive optimization and digital twins are magnified; machine learning expands the data-driven intelligence level of traditional simulation models, and can continuously update the model’s prediction parameters based on real-time data to improve the accuracy of forecasts; machine learning can discover potential laws in data that traditional methods have not yet identified, generate new hypotheses or theories, and affect the operation of simulation models in the form of parameter transfer, thereby enhancing the simulation model’s data analysis, mining, and prediction capabilities, improving the paradigm dimension of simulation, and expanding the boundaries of digital twin insight.
[0016] 5. This invention introduces R language machine learning into the AnyLogic simulation modeling environment. Based on R’s community support, ecosystem, development efficiency, and learning resources, AnyLogic simulation has nearly unlimited scalability and upgradeability.
[0017] 6. The method and plug-in library provided by the present invention can be deployed locally without relying on the Internet, that is, a simulation model with the characteristics of the new machine learning paradigm can be quickly built in AnyLogic software in an offline manner, which meets the data confidentiality requirements of units such as the military and special administrative law enforcement departments. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] The present invention will be further described below in conjunction with the accompanying drawings and embodiments: Figure 1 It is the dependency interaction diagram between the classes and methods of each sub-package of the plug-in library; Figure 2 The potential mechanisms of combining simulation with machine learning and typical ways to deploy the new AnyLogic paradigm; Figure 3 The detailed editing interface of the new library and the software copyright information of the ALRcaller plug-in; Figure 4 3D reconstruction of the physical model of the hangar reinforcement and maintenance support scene for a certain type of aircraft; Figure 5 An aviation maintenance simulation framework with machine learning features in R language; Figure 6 Provide real-time parameter feedback and scene 3D animation for the operation of the smart fighter bunker maintenance support system; Figure 7 Provide performance evaluation indicators and visualization for the operation of the smart fighter bunker maintenance support system; Figure 8 To strengthen the 3D model and state diagram parameter settings of the aircraft fort intelligent body; Fig. 9 3D model and state diagram parameter settings for maintenance personnel agents; Fig.10 To optimize the number of decision trees and the characteristic curve of the misclassification rate of the random forest model based on out-of-bag observations before the experiment; Fig.11 The experimental results of the first stage optimization of the 4-parameter random forest model based on the OptQuest engine; Fig.12 Experimental results for the second stage optimization of the 4-parameter random forest model based on the OptQuest engine. DETAILED DESCRIPTION
[0019] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.
[0020] Embodiment 1: A method to run R language and deploy machine learning algorithms in AnyLogic software environment, the steps are as follows: S1. Build a Jar package for a project based on the Java SE platform. The dependency interaction diagram within the package is as follows: Figure 1 As shown, the specific decomposition steps are as follows: S11. Complete the download and installation of the Java toolkit and configure the Java environment variables in the control panel; S12. Build a Jar package based on the Java SE platform. In this embodiment, the Java toolkit (JDK) is downloaded and installed in the Win10 environment, and the Java environment variables are configured in the control panel so that Java is global and can run in any file directory; a Jar package of the JDK 22 version development core and JRE 8U421 operating environment based on the Java SE platform is built, the project name is ALRcaller, the package name is edu.ctgu.sh-alrcaller-1.0.1.jar, and EclipseJee 2023-12 version software is used as a development tool.
[0021] The Jar package is used to carry the sub-program packages and their interrelationships of the method of running R language and deploying machine learning algorithms in the AnyLogic software environment, serving as the carrier of the method proposed in this patent.
[0022] S2. Build the main project package to define global variables and parameters, centralize debugging and testing logic, and provide a centralized entry point for potential future modifications and extensions.
[0023] The main package of the project includes two first-level sub-packages, namely the first-level sub-package and the second-level sub-package. The first-level sub-package includes several core Java classes, including CodeUtils, EventHandler, Globals, JavaObject, RCaller, RCode, ROutputParser, RPlotViewer and RstreamHandler. Among them: The CodeUtils class provides the main methods that support the interaction between Java and R languages, especially methods for data transfer and conversion, and methods for generating or processing code snippets, enabling modelers to generate directly executable R code in a Java environment.
[0024] The EventHandler class provides the main methods for processing interactive messages between Java and R languages and managing the output streams of both, allowing Java to communicate with R languages effectively.
[0025] The Globals class provides R language configuration and constant support in the Java environment, so that you can more flexibly and conveniently manage R language-related environment settings, version information, and graphic themes when calling R language in Java.
[0026] The JavaObject class provides Java property processing and R code generation, using specific methods to convert the fields of Java objects into R code.
[0027] The RCaller class provides methods for executing R scripts, parsing R output, and redirecting R output, which greatly expands the capabilities of AnyLogic software and its Java code in data analysis and machine learning, and opens up a new paradigm for simulation research.
[0028] The RCode class provides methods for dynamically building and executing R language codes, and supports various functions necessary for R language machine learning, such as data transmission, drawing, and package management.
[0029] The ROutputParser class provides methods for extracting and processing data from R language output. It can parse numerical data in R language output and obtain structured document information, and supports dynamic updating of files.
[0030] The RPlotViewer class provides methods to display R language generated graphics in Java, as a graphical user interface (GUI) window, showing high-level graphics generated by R language in Java.
[0031] The RStreamHandler class provides methods for processing input streams of R language calls in the Java environment, reading data from the input stream and passing it to the registered event handlers, and implementing complex message processing logic.
[0032] The first-level sub-package consists of two second-level sub-packages, one of which is used for statistical simulation, sample generation, and data analysis, and the other is used to handle various exceptions that may occur when Java and R languages interact.
[0033] In this embodiment, the main package RCMain of the ALRcaller project is constructed, which is mainly used to define global variables and parameters, centrally process debugging and testing logic, and provide a centralized entry point for potential future modifications and extensions.
[0034] The main package RCMain includes two first-level sub-packages: ALRcaller and ALGraphics. The first-level sub-package ALRcaller integrates several core Java classes and provides a series of efficient, flexible and powerful functions, aiming to achieve seamless interaction and integration between Java and R languages for simulation.
[0035] The two second-level sub-packages of the first-level sub-package ALRcaller are the first-level sub-package and the second-level sub-package, which are ALStatistics and ALException respectively.
[0036] The second-level subpackage ALStatistics of the first-level subpackage ALRcaller is mainly used for statistical simulation, sample generation, and data analysis. This second-level subpackage provides a seamless integration, allowing users to create more complex and generalized probability simulation experiments and perform data analysis, or test the effectiveness of statistical methods, making statistical analysis in the AnyLogic environment more convenient and powerful with the support of the R language.
[0037] The second-level subpackage ALException of the first-level subpackage ALRcaller is mainly used to handle various exceptions that may occur during the interaction between Java and R languages; this second-level subpackage enables modelers to capture and handle specific errors to ensure that problems that arise during the interaction with R can be handled gracefully in the Java environment, thereby improving the robustness of the overall program and user experience.
[0038] The second first-level subpackage ALGraphics is mainly used to provide theme, style and format management for R language drawing in the Java environment for simulation; this subpackage provides users with a flexible way to present graphics, which greatly expands the drawing function of Java due to the support of R language. The specific operations of building this package are as follows: In Eclipse IDE 2023-12, click "File→New→Project→JavaProject" to prepare for creating a Java project. The "New Java Project-Create a Java Project" dialog box pops up, and type "ALRcaller" in the Project Name. Use the default configuration to complete the project creation, and click "Finish" to create the project from scratch. In the Java project of ALRcaller, use the method of "File→New→Other→Package" to first create the hierarchical structure of each sub-package, where: the main package of the project is RCMain, which is mainly used to define global variables and parameters, centrally handle debugging and testing logic, and provide a centralized entry point for potential future modifications and extensions; the main package RCMain includes two first-level sub-packages, ALRcaller and ALGraphics, and two second-level sub-packages, ALStatistics and ALException, under the ALRcaller sub-package. Among them, the construction steps of the first-level sub-package are: 1) Construct the CodeUtils class to provide the main methods that support the interaction between Java and R, especially the methods of data transfer and conversion, and the methods of generating or processing code snippets, so that modelers can generate code that can be directly executed in R in the Java environment; The constructed CodeUtils class contains main functional functions such as addDoubleArray(StringBuffer, String, doublell,boolean): void and addIntArray(StringBuffer, String, int[], boolean): void, and has the foundation and interface for functional expansion.
[0039] 2) Construct the EventHandler class to provide the main methods for processing interactive messages between Java and R and managing the output streams of both, so that Java can communicate with R effectively; The constructed EventHandler class depends on the Java basic class java.io.OutputStream, including main functions such as getO(): OutputStream, messageReceived(String, String): void and setO(OutputStream): void, and has the basis and interface for functional expansion.
[0040] 3) Build the Globals class to provide R language configuration and constant support in the Java environment, so that when calling R language in Java, it is more flexible and convenient to manage R language related environment settings, version information, and graphic themes; The constructed Globals class depends on the two subclasses of ALGraphics, DefaultTheme and GraphicsTheme. It contains major functions such as Globals() and detect_current_rscript(), and has the foundation and interface for functional expansion.
[0041] 4) Build the JavaObject class to provide Java property processing and R code generation, and use specific methods to convert the fields of Java objects into R code; The constructed JavaObject class depends on the Java basic class java.lang.reflect.Field, contains main functions such as produceRCode(boolean): String, and has the basis and interface for function extension.
[0042] 5) Building the RCaller class to provide methods for a series of key functions such as executing R scripts, parsing R output, and redirecting R output, greatly expanding the capabilities of AnyLogic software and its Java code in data analysis and machine learning; The constructed RCaller class depends on Java basic classes such as java.io.BufferedWriter, java.io.File, and the ALGraphics subpackage. It also depends on ALException's ExecutionException, ParseException and other classes. It contains main functional functions such as getCranRepos(): String, getRCode(): RCode, runAndReturnResult(String): void, and has the foundation and interface for functional expansion.
[0043] 6) Build the RCode class to provide methods for dynamically building and executing R code, supporting various functions necessary for R machine learning, such as data transmission, drawing, and package management; The constructed RCode class depends on Java basic classes such as java.io.File, java.io.IOException, and the GraphicsType subclass of ALGraphics. It includes main functions such as R_require(String): void, addRCode(String): void, and has the basis and interface for functional extension.
[0044] 7) Build the ROutputParser class to provide methods for extracting and processing data from R language output. It can parse numerical data in R language output and obtain structured document information, and support dynamic update of files. The constructed ROutputParser class depends on Java basic classes such as java.io.File, java.io.IOException, etc., and on Java interface classes such as org.w3c.dom.Document, org.w3c.dom.Node, etc. It also depends on the ALException subpackage, which includes main functional functions such as getAsDoubleArray(String) : double[], getDocument() : Document, and has the foundation and interface for functional expansion.
[0045] 8) Build the RPlotViewer class to provide methods for displaying graphics generated by R language in Java. As a graphical user interface (GUI) window, it can display high-level graphics generated by R language in Java; The constructed RPlotViewer class depends on Java basic classes such as java.awt.Graphics, javax.swing.ImageIcon, etc., and includes main functions such as getImg(): ImageIcon and setImg(ImageIcon): void, and has the basis and interface for functional expansion.
[0046] 9) Build the RStreamHandler class and provide methods for processing the input stream of calling the R language in the Java language environment, read data from the input stream and pass it to the registered event handler, and implement complex message processing logic; The constructed RStreamHandler class relies on Java basic classes such as java.io.BufferedReader, java.io.InputStream, etc., and contains main functional functions such as isAlive(): boolean and setStream(InputStream): void. It is mainly used to: read input stream data, identify and log it; add a new handler to the event handler list so that it can be called when a message is received; check whether the processing thread is still running and feedback the current status of the thread; set a shutdown signal to determine and control whether the run() method loop continues, etc.; and has the foundation and interface for functional expansion.
[0047] The construction steps of the first and second level subpackage ALStatistics are: 1) Configure the operating environment and main parameters of the first and second-level sub-packages, including the ALRcaller.Rcaller (RCaller class) dependency that implements the parsing, execution, and output of R scripts, and the ALRcaller.Rcode (RCode class) dependency that provides a method for dynamically building R language codes.
[0048] 2) Set the main functional functions of the secondary sub-package ALStatistics of the sub-package ALRcaller, mainly to set the functional functions of the RandomNumberGenerator(RCaller) program block, including, for example: the randomBeta(int, double, double): double[] function for generating Beta distributed random numbers, the randomBinom(int, int, double): double[] function for generating Bernoulli distributed random numbers, etc.
[0049] The construction steps of the second level subpackage ALException are: 1) Configure the operating environment and main parameters of the second-level sub-package, including the superclass java.lang.Exception (JDK base package) that can be coded to solve Java exceptions as a dependency; 2) Set up the main functions of the second level subpackage, including, for example, the ExecutionException(String) function that provides a descriptive message when creating an exception and passes this message, the ParseException(String) function that provides a descriptive message for parsing the exception, and the RscriptExecutableNotFoundException(String) function that provides a detailed message about the Rscript executable file not being found.
[0050] The second-level subpackage ALGraphics is used to provide themes, styles, and format management for R language drawing in the Java environment for simulation. The construction steps of the second-level subpackage are as follows: 1) Configure the operating environment and main parameters of the second-level subpackage, including the JDK base package java.awt.Color, which provides classes and interfaces for managing and manipulating colors, as a dependency; 2) Set the main function of the second-level subpackage, including, for example, the generateRCode() : String function for generating the corresponding R language code according to the current color and line width, and the getAxisColor() : Color function for returning the current axis color.
[0051] S3, transplant the project code data constructed in steps S1 and S2 into the AnyLogic software environment, use AnyLogic software to package the active objects contained in the project into a plug-in library that complies with the AnyLogic software communication specification, and export the plug-in library to AnyLogic software. The decomposition steps are as follows: S31: Transplant the project into the AnyLogic software environment, convert all main packages, first-level sub-packages, and second-level sub-packages into "agent types" in the AnyLogic environment, and transfer the Java classes under each sub-package into the corresponding agent types; complete the construction of the structure and content of the Java package in steps S1 to S2 in the AnyLogic environment, and click "Build Model (F7)" in the menu bar to confirm that all codes are compiled correctly; S32. In the AnyLogic development environment, select the top-level ALRcaller.alp model in the Project column, click "File → New → Library", and fill in the corresponding information of the dedicated library in the pop-up "New AnyLogic Library" dialog box, that is, fill in "ALRcaller Library" in the "Name" and fill in "A library for running R code in AnyLogic software to deploy Machine Learning and Deep Reinforcement Learning in simulation experiments." in the "Description". After clicking "Finish", the Project column will generate a "Library" type icon and display the name "ALRcaller Library", and then the detailed editing interface of the library will pop up, as shown in the figure below. Figure 3 ; S33. Continue to fill in information and improve interaction in the detailed editing interface of the new library; upload the library icon specified to appear in the panel in the "Panel", which is divided into two formats: 16×16pix and 32×32pix; design the line drawings of the corresponding icons according to the functional characteristics of the respective modules of RCMain, ALRcaller, ALStatistics, ALException and ALGraphics, and use the special website for icon production to assist in generating icons in the required format, such as: https: / / favicon.io, and finally upload the two formats of icons corresponding to the above five important modules from the local path; In the "Export" module of the new library's detailed editing interface, select "Export Library" to complete the export of the professional library that complies with the communication specifications of AnyLogic 8.9.0 and above. The file is named edu.ctgu.sh-alrcaller-1.0.1.jar.
[0052] S4. Insert the exported plug-in library into AnyLogic IDE for testing and use. In the AnyLogic software environment, click "Panel → (+Add) → Manage Library", and the library adding interface will pop up. Click "Add", and the file "Open" interface will pop up. Select edu.ctgu.sh-alrcaller-1.0.1.jar in the set local path (the saving path is preferably a full English path). After selection, click "Open → OK". At this time, the library file has been added to the library list. Click "OK" in the library adding interface to complete the import of the ALRcaller library; restart the AnyLogic software to ensure that the setting changes can be correctly recognized and the plug-in installation can be correctly loaded.
[0053] S5. Conduct R code pre-experiments in the R language environment, and bridge the AnyLogic environment with the mainstream machine learning packages of the R language through the first-level sub-packages to build the paradigm ecology and main technical forms of the new research method of "machine learning + simulation", such as Figure 2 The decomposition steps are as follows: S51, perform paper assumptions on the algorithm model, and then install the required R language packages through the install.packages() function image in the R 4.3.2 version of RGui (64-bit); S52: In the RGui graphical user interface or RStudio integrated development environment (IDE), reference the installed R language package to conduct preliminary experiments on the R language machine learning algorithm to achieve the expected experimental results; S53: In AnyLogic software, complete the migration of the pre-experimental R language code to the Java environment, mainly using the function statement form of code.addRCode("R language code") to add the R script to the simulation environment. For some complex R codes (especially R codes with double quotes ""), consider using Java escape characters "\" to process the code to avoid coding syntax errors.
[0054] S6. Use the plug-in library in conjunction with AnyLogic’s native libraries (e.g., process modeling library, material handling library, pedestrian library, rail library, road traffic library, fluid library, and system dynamics library) to seamlessly connect intelligent algorithms with simulations and achieve the paradigm shift resulting from the fusion of the third paradigm and the fourth paradigm. The decomposition steps are as follows: S61. Use the nested mode of "R script function + conditional trigger event" or "native library function block + R script parameter transfer" to organically integrate the machine learning methods carried by the R language into simulation methods based on discrete events, system dynamics and intelligent agents. Machine learning methods include reinforcement learning, supervised learning, semi-supervised learning and unsupervised learning.
[0055] S62. Use the delay time value predicted by the R language machine learning method at the delay time of the Delay or Service component of the process modeling library; use the queue capacity predicted by the R language machine learning method at the capacity of the Queue component of the process modeling library; use the storage capacity predicted by the R language machine learning method at the capacity of the Pipeline component of the fluid library, etc.
[0056] Embodiment 2: This example demonstrates the process of calling the calculation results of the algorithms and functions of the R language in the AnyLogic environment by the ALRcaller plug-in library independently developed by this team, and controlling the logic and behavior of the intelligent agent in the AnyLogic environment. Specifically, a black box process in the R language is used to provide behavioral instruction parameters for the finite state machine of the intelligent agent in the AnyLogic environment, thereby simulating different working conditions of maintenance operations in a certain type of aircraft hangar built in the AnyLogic environment, controlling the maintenance status and door opening and closing of the hangar, and correspondingly calling the corresponding number of maintenance personnel to participate in aircraft maintenance, or standby and prepare in the rest area in a lean and flexible manner. In terms of simulation methods, this example is a combination of machine learning and traditional simulation methods, and applies methods based on intelligent agents and system dynamics; in terms of fields, it belongs to business applications in the field of aviation maintenance; in general, it belongs to an experiment based on the plug-in library to use the R language to optimize and control the simulation process of AnyLogic (the experiment code is: CtrlTest.R2A).
[0057] Specifically, this embodiment simulates the operation conditions of a new type of hangar during a special overhaul mission, and the maintenance personnel try to carry out lean maintenance and flexible maintenance. There are 10 workstations in the hangar, and the corresponding team has 10 maintenance personnel; the new equipment is used intermittently, and some maintenance personnel on standby need to go to the rest area to prepare materials during the cooling time of the machine operation; the simulation experiment simulates the process of using a black box algorithm to optimize the intermittent cooling time of the 10 workstations and instruct the maintenance personnel to go to the hangar to carry out maintenance operations.
[0058] In the preferred solution, a certain random black box algorithm is simulated with 10 normally distributed 0-1 variables as output, and the sum of these 10 0-1 variables is used as the decision variable. The formula is: ; The simulation experiment of this embodiment designs four performance evaluation indicators, namely: real-time equipment operation time, real-time maintenance work time, real-time standby maintenance personnel (number) and the work efficiency of a single maintenance personnel.
[0059] Use Finite State Machine (FSM) models to drive the actions of agents in simulation environments: ; a. State transition function of Deterministic Finite Automation (DFA): ; b. State transition function of Nondeterministic Finite Automaton (NFA): ; Where: Represents the state set, including all possible states of the system; represents the input signal set, including all input signals received by the system; Represents the output signal set, including all output signals generated by the system; Represents the transfer function, describing the rules of state transition; represents the initial state, as the initial state of the system; Represents the empty transfer symbol, which is the empty transfer in the NFA method; Represents the Cartesian product between sets; express The power set (including ), is to convert the set All elements of are converted into combinations of binary numbers, reflecting the possibilities of all subsets.
[0060] Gate-Control Theory is a term originally used in the medical field. When this theory is transferred to the simulation field, for simulation gate control technology, it is to realize intelligent control of the simulation environment and the group of intelligent agents by identifying the switch state of the control gate (the threshold signal released by a certain mechanism or algorithm). This embodiment will deploy a finite state machine architecture of the reinforced aircraft hangar intelligent agent and the maintenance personnel intelligent agent based on the gate control theory and integrated with the machine learning algorithm.
[0061] In AnyLogic, we use the self-developed ALRcaller plug-in library to call the R language, use the calculation results of the R language algorithms and functions, control the logic and behavior of the intelligent agent in the AnyLogic environment, and simulate different working conditions of maintenance operations in a certain type of aircraft hangar, control the hangar maintenance status and door opening and closing, and call the corresponding number of maintenance personnel to participate in aircraft maintenance or standby and prepare in the rest area in a lean and flexible way. The process includes the following steps: E2S1: Install the Runiversal package based on the R language runtime environment on the local computer. Since it is currently no longer possible to download the package directly from the R language official support website or install the package using the install.packages() method in the R environment, you can only use the devtools::install_local() method to install the package using a local .zip file carrier.
[0062] E2S2: In AnyLogic 8.9.0 Professional and above, follow the order of "Panel → Manage Libraries → Add" and select the AnyLogic professional library Jar package edu.ctgu.sh.alrcaller.testtype.101.jar file independently developed by our R&D team in the file path. After the professional library is loaded successfully, the newly loaded library name will be displayed as ALRcaller Library, the provider is Hang Shao, the version is 1.0.1, and the local path information of the file will be displayed.
[0063] E2S3: Create a new simulation experiment in AnyLogic software and name it ALRcallerCase2.alp.
[0064] E2S4: After creating a new simulation experiment and loading the ALRcaller Library successfully, drag the RCmain, ALRcaller, ALStatistics, ALGraphics and ALException components of the library, a total of five components, to the AnyLogic runtime environment, beautify and lay out the R WORKING PANEL workgroup space, that is, import the Java class that can "convert and pass parameters from Java language to R language" into the underlying Java environment of AnyLogic, such as Figure 5 shown.
[0065] E2S5: Configure the dependency environment for the ALRcaller plug-in library. In view of the fact that data visualization images are accessed and output in this experiment, find "Advanced Java" in the Main agent at the top level of the simulation experiment and import Java basic libraries such as java.io.File and javax.swing.ImageIcon in the "Import section".
[0066] E2S6: Drag and drop the “Excel File” plug-in component into the AnyLogic environment in the order of “Panel → Connect → Excel File” to import sensor data files in Excel format into the simulation environment for subsequent simulation and prediction.
[0067] E2S7: Based on the real hangar floor plan, a simulated virtual physical environment is built for subsequent simulation and prediction. At the same time, intelligent agents and intelligent agent groups of the hangar, dormitory and maintenance personnel physical models are established, such as Figure 4 shown.
[0068] Further, drag the "Agent" component from the "Agent" library to the simulation environment interface, use the default process to create the maintenance crew group agent groundCrews and the hangar single agent flightHangar, then select the appropriate maintenance crew and hangar 3D models in .dae format, adjust the additional scale of the 3D model to a suitable size, and use them as the agent animations of the above group agent groundCrews and single agent flightHangar; Furthermore, for the hangar single agent flightHangar, it is necessary to specially select the animations and prompt icons for the two states of the hangar door "open" and "closed", type "Open" in the visibility parameters of the hangar in the "Opening" state, and type "Close" in the visibility parameters of the hangar in the "Closing" state.
[0069] E2S8: Based on the agent and state graph library, a logical template for the operation of each unit in the airport is constructed. Among them: The hangar single agent flightHangar is controlled by a three-state transition state diagram to control its basic operation, such as Figure 8 As shown, the statechart entry point is statechart, set the state branch connection to "Open", "Close" and "Normal", and drag three "Parameter" components from the "Panel → System Dynamics" library to the design panel of flightHangar, name them "OpenTime1", "OpenTime2" and "OpenDuration" respectively and specify them as double type; At the transition fromIndicator, set the transition condition to main.Indicator()>5 and point to the "Open" state; use the time transition countdown1 to point from the "Open" state to the "Normal" state, and set the time to 9 minutes; use the time transition countdown2 to point from the "Normal" state to the state branch connection, and set the time to 1 minute; extend the non-true trigger branch whileFalse from the state branch connection and point to the "Close" state, which is a marked state with no code; use the time transition countdown3 to point from the "Close" state to the "Normal" state, and set the time to 9 minutes; complete the state diagram construction of the hangar single agent flightHangar; The groundCrews agent is controlled by a three-state transition state diagram to perform basic operations, such as Fig. 9 As shown, the statechart entry point is statechart, set the state branch to connect "Work", "Wait" and "Normal", and drag three "Parameter" components from the "Panel → System Dynamics" library to the design panel of flightHangar, name them "WorkTime1", "WorkTime2" and "WorkDuration" respectively and specify them as double type; Set the transition condition to main.Indicator()>5 at the transition fromIndicator, and point it to the "Work" state; use the on-time transition countdown1 to point from the "Work" state to the "Normal" state, and set the on-time to 9 minutes; use the on-time transition countdown2 to point from the "Normal" state to the state branch connection, and set the on-time to 1 minute; extend the non-true trigger branch whileFalse from the state branch connection and point it to the "Wait" state, use the on-time transition countdown3 to point from the "Wait" state to the "Normal" state, and set the on-time to 9 minutes; complete the state diagram construction of the maintenance personnel group intelligent agent groundCrews; E2S9: Based on the analysis library, build the data analysis and visualization module of the simulation model. Use the time line chart and time stacking chart of "Panel→Analysis Library" to visualize the real-time maintenance efficiency evaluation data, including: The title of the time line chart plot1 is "Real-time equipment operation time", the value is getOpenDuration(), and the appropriate dot-line format is selected to draw the figure to show the difference; the title of the time line chart plot2 is "Real-time maintenance work time", the value is getWorkDuration(), and the appropriate dot-line format is selected to draw the figure to show the difference; the title of the time line chart plot3 is "Real-time standby maintenance personnel", the value is getRestCrews(), and the appropriate dot-line format is selected to draw the figure to show the difference; the title of the time line chart chart1 is "Single maintenance personnel work efficiency", and the appropriate dot-line format is selected to draw the figure to show the difference. Among them, the rationalization formula for the work efficiency of a single maintenance personnel is: ; Where: Indicates the work efficiency of a single maintenance personnel; Indicates the working hours of the maintenance personnel agent group; Represents the real-time running time of the hangar and its maintenance equipment agent group; Indicates the total number of maintenance team members; Indicates the number of maintenance personnel on standby; Represents a high-order infinitesimal, which is an auxiliary parameter set to prevent division by zero errors in iterative calculations. In this example, the value is 0.001; E2S10: Use R language to simulate a black box algorithm with randomness, pass the decision parameters into the finite state machine, and control the people, machines, and environment of the virtual airport in the AnyLogic environment. Specifically, during a special overhaul mission, the maintenance personnel relied on the operating conditions of a new type of hangar to try out lean maintenance and flexible maintenance models. There are 10 workstations in the hangar, and the corresponding team has 10 maintenance personnel; the use frequency of the new equipment is intermittent, so not all personnel are required to be at their workstations all the time. Instead, some maintenance personnel on standby need to go to the rest area to prepare materials during the cooling time of the machine; the simulation experiment simulates the process of optimizing the intermittent cooling time of 10 workstations through a black box algorithm, and guiding the corresponding maintenance personnel to go to the hangar to carry out maintenance operations through indicators; the overall top-level architecture of the model can be seen Figure 5 ; E2S11: Run the simulation model and evaluate the performance of the model. Click "ALRcallerCase2 / Simulation" in AnyLogic to run the simulation model and its embedded R language machine learning code in the Java environment of AnyLogic. The 3D window will display the status of the simulation in real time, including the opening and closing of the hangar, the operation of personnel, and the scheduling and work of personnel. The console will display the real-time parameter array and gate threshold, etc. Figure 6 As shown; the data visualization area will update the visualization chart of performance indicators in real time, such as Figure 7 shown.
[0070] Embodiment 3: This example demonstrates the use of the ALRcaller plug-in library independently developed by our team to call the random forest algorithm of R language in the AnyLogic environment, process sensor data in Excel format imported into AnyLogic software, and use the optimization experiment function of AnyLogic software to perform iterative optimization of the four important parameters of the random forest algorithm: the number of decision trees (ntree), the number of variables considered for each split (mtry), the minimum number of samples of leaf nodes (nodesize), and the maximum number of nodes of the decision tree (maxnodes) with the goal of minimizing the root mean square error (RMSE) of the model, and obtain the process of the four-parameter combination with the minimum RMSE within the number of iterations. This example is a combination of machine learning and traditional simulation methods in terms of simulation methods, and applies system dynamics and OptQuest methods; in terms of fields, it belongs to the business application of electrical science and engineering; in general, it belongs to an experiment of optimizing and controlling the R language using AnyLogic based on this plug-in library (experiment code: CtrlTest.A2R).
[0071] In actual experiments and applications of major projects, it is usually impossible to conduct large sampling (or obtain a large number of samples for training), and the prediction method for small samples has become an important scientific problem that needs to be solved urgently. The gap breakdown voltage experiment of positive polarity gas is such an experiment with high experimental difficulty, high risk factor and high material cost.
[0072] The data set used in this embodiment is specifically real data of a gap breakdown voltage experiment of a positive gas. The field information of the positive gas gap breakdown voltage experiment data is as follows:
[0073] The local file name of the above experimental data is breakdownData.xlsx, and its data content is shown as follows:
[0074] There is evidence that tree-based models are more likely to achieve good predictions for tabular data than various deep learning methods. In view of this, this study intends to use the random forest algorithm to analyze and process the above breakdownData.xlsx data.
[0075] In the preferred solution, for the growth stage of the random forest decision tree, information gain is used to select the partitioning attributes of the decision tree. And the optimal partitioning properties Defined as: ; Where: Represents a sample set The information entropy of Represents the current sample set Middle The proportion of class samples, usually The higher the purity, the The smaller the value of; Representing discrete attributes The value space of , represents the optimal partitioning attribute, Represents the sample value range.
[0076] Preferably, for numerical tasks, the voting stage adopts the weighted averaging principle, that is: ; Where: Indicates the sample predictions, T represents the number of individual learners in the ensemble, Represents an individual learner The weight is usually required ;when , the method becomes SimpleAveraging.
[0077] Preferably, for the classified tasks, the Plurality Voting principle is adopted in the voting stage, that is: ; Where: Indicates the sample predictions, N Dimensional vector Representation Learner In the sample The predicted output on express In category tag collection The output on T Represents the number of individual learners in the ensemble.
[0078] In AnyLogic, the self-developed ALRcaller plug-in library was used to call the R language random forest algorithm to simulate and predict the above breakdownData.xlsx data set (to predict the voltage at gas breakdown). The optimization experiment function of AnyLogic software was used to iteratively optimize the four important parameters of the random forest algorithm. Finally, the model parameters that minimized the RMSE index were obtained, including the following steps: E3S1: Referring to steps E2S1 to E2S6 of Example 2, build the operating environment of the ALRcaller plug-in library, create a new simulation experiment named ALRcallerCase3.alp, and import the sensor data file breakdownData.xlsx in Excel format for subsequent simulation and prediction.
[0079] E3S2: Drag four "Parameter" components from the "Panel → System Dynamics" library to the R WORKINGPANEL workspace in Main, and name them: ntree, mtry, nodesize, and maxnodes. The default values are 500, 10, 5, and 5, respectively. The types are all double. The detailed description of the above parameters is as follows:
[0080] In this embodiment, in order to control the time complexity and space complexity of the model, ensure that the calculation does not overflow, prevent overfitting, and ensure that the decision tree must have splits, the minimum value of ntree is 3, the maximum value of mtry is 10, the minimum value of nodesize is 2, and the minimum value of maxnodes is 2.
[0081] E3S3: Drag a "Function" component from the "Panel → Agent" library to the R WORKING PANEL workspace in Main, name it "randomForestRMSE", set the "Return Value" item to TRUE, and write the Java code used to call the R language to read the experimental data and train the random forest model in the function body; E3S4: In a pure R language environment, use the random forest algorithm in the randomForest package to conduct a preliminary experiment on the above data set, and obtain the optimal parameter value estimated by the randomForest package's own method by checking the min_index parameter containing data items such as rf$mse; The above process is essentially to use the plot() function to visualize the changing characteristics of the misclassification rate based on out-of-bag observations with the number of decision trees in the random forest, and then obtain intuitive observation conclusions, see Fig.10 The plot data of the plot() function is the overall prediction error rate err.rate of the random forest model for out-of-bag observations. The OOB misjudgment rate data is actually calculated by modelA.rf$mse when calling the plot() function.
[0082] Through the above preliminary experiments, it can be seen that when other parameters remain default, when the number of decision trees is 42, the overall error rate err.rate is the smallest, so the parameter ntree in this embodiment can be set to 42 for reference. Fig.10 .
[0083] Furthermore, a single simulation experiment was conducted in AnyLogic. Drag an "Event" component from the "Panel → Agent" library to the R WORKING PANEL workspace in Main, name it "calcRMSE", set the trigger type to "When", and the mode to "Occur once". In the action of this "Event", call the model's RMSE value calculation function randomForestRMSE(); Furthermore, click “ALRcallerCase3 / Simulation” in AnyLogic to run the above simulation experiment and the R code it contains in AnyLogic. When the operation is completed, the calculation results and status update labels will be printed in the AnyLogic Config console. E3S5: Deploy and run the first phase of the parameter optimization experiment in AnyLogic software. Right-click "Project → ALRcallerCase3" and select "New → Experiment". In the pop-up "New Experiment" dialog box, fill in "Optimization" in the "Name", "Main" in the "Top-level Agent", "Optimization" in the "Experiment Type", and leave the rest of the options as default. Click "Finish" to create a new optimization experiment.
[0084] In the parameter optimization experiment "Optimization", select "OptQuest DEMO" as the optimization engine, select "Minimize" as the target, and fill in root.randomForestRMSE() in the target value; Select the iteration number mode as "Fixed", its value as 200, and the maximum available memory as 512Mb. Click "Create Default User Interface" to display the optimization experiment appearance. In the parameter setting area, set the parameters as shown in the following table:
[0085] Click "Build Model (F7)" in the menu bar to confirm that all codes are compiled correctly. Then click "Run (F5) → ALRcallerCase3 / Optimization" to get the following Fig.11 The results of the first stage optimization experiment are shown: After 107.04 seconds and 207 iterations, we found that the optimal iteration in this range is the 177th step, with the minimum RMSE of 7.017, and at this time ntree = 3, mtry = 9, nodesize = 2, maxnodes = 46. In the above iterations, we found that: under the objective function of minimizing the model evaluation indicator RMSE, the number of decision trees ntree and the minimum number of leaf node samples nodesize tend to be minimized, the number of fission input variables mtry tends to be maximized, and the decision tree depth maxnodes tends to find a suitable optimal value in the middle, which is related to the characteristics of the data set and computing resources.
[0086] E3S6: Deploy and run the second phase of parameter optimization experiment in AnyLogic software. Based on the knowledge of the first phase of parameter optimization experiment, a new parameter optimization experiment is created as "Optimization1", the iteration mode is "Fixed", the value is 200, and the maximum available memory is 512Mb. The optimization goal remains unchanged, and the parameter settings are shown in the following table:
[0087] Click "Build Model (F7)" in the menu bar to confirm that all codes are compiled correctly. Then click "Run (F5) → ALRcallerCase3 / Optimization1" to get Fig.12 The results of the second stage optimization experiment are shown: After 26.05 seconds and 49 iterations, the optimal iteration in the range is found to be the 28th step, with the minimum RMSE of 6.822, and at this time ntree = 3, mtry = 9, nodesize = 2, maxnodes = 23. This further simplifies the calculation steps and saves computing resources.
[0088] E3S7: Post-processing is performed to correct the predicted values based on the parameter optimization experiment in the second phase. This is a data processing technique that uses special calculation methods to adjust the model output to better match the statistical characteristics of the actual observed data. According to the definition of RMSE, there are: ; In practice, if RMSE = 5, it can be considered that the regression effect differs from the true value by an average of ±5.
[0089] This invention patent originally designs and proposes a prediction value correction post-processing toolbox named Flexible Corrector. Currently, it provides two original prediction value correction post-processing methods, namely Flexible Difference Addition (FDA) and Flexible Difference Multiplication (FDM), which are defined as follows: Assume the predicted value vector is , the true value vector is , the root mean square error of the model is . Then the predicted value vector after FDA method post-processing is It can be expressed as: ; Let the scaling weight be , then: ; Then use the FDM method, based on the predicted value and the true value , and obtain the adjusted predicted value It is expressed as: ; The patent of this invention refers to the definition of "economic growth rate year-on-year" in economics, and designs and defines the use of a certain algorithm or post-processing method to reconcile the predicted value. RMSE convergence speed , the formula is: ; Where: represents the root mean square error before using some output correction method, Represents the root mean square error after using a certain output correction method.
[0090]
[0091] It can be seen that by calling R language in AnyLogic environment through the ALRcaller plug-in library, using the random forest algorithm of R language, processing sensor data in Excel format imported into AnyLogic software, and using the optimization experiment function of AnyLogic software (especially OptQuest optimizer) to optimize the parameters of the random forest algorithm, the computing performance of the randomForest package in R language can be improved by nearly 50% (44.23% in this case). The parameter optimization method of the randomForest package in the official support website of R language cannot do this at present.
[0092] It will be easily understood by those skilled in the art that the above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for running R language and deploying machine learning algorithms in AnyLogic software environment, characterized by: The steps include: S1. Build a Jar package of the project based on the Java SE platform to carry the sub-packages and their interrelationships of the methods for running R language and deploying machine learning algorithms in the AnyLogic software environment; S2. Build the main project package to define global variables and parameters, centralize debugging and testing logic, and provide a centralized entry point for potential future modifications and extensions; The main package of the project includes two first-level sub-packages, namely the first-level sub-package and the second-level sub-package: the first-level sub-package includes several core Java classes, which are composed of two second-level sub-packages, one of which is used for statistical simulation, sample generation and data analysis, and the other is used to handle various exceptions that may occur when Java and R languages interact; the second-level sub-package is used to provide themes, styles and format management for R language drawings in the Java environment for simulation; S3, porting the project code data constructed in steps S1 and S2 to the AnyLogic software environment, and using AnyLogic software to package the active objects contained in the project into a plug-in library that complies with the AnyLogic software communication specification, and exporting the plug-in library to the AnyLogic software in the form of an independent Jar package; S4, inserting the exported plug-in library into AnyLogic IDE for testing and use; S5. Conduct R code pre-experiments in the R language environment, and bridge the AnyLogic environment with the mainstream machine learning packages of the R language through the first-level sub-packages to build a paradigm ecosystem for the new research method of "machine learning + simulation".
2. A method for running R language and deploying machine learning algorithms in AnyLogic software environment according to claim 1, characterized in that: The method also includes step S6: using the plug-in library in conjunction with the native library of AnyLogic software to seamlessly connect the intelligent algorithm with the simulation, so as to achieve the paradigm shift generated by the fusion of the third paradigm and the fourth paradigm.
3. The method of running R language and deploying machine learning algorithms in AnyLogic software environment according to claim 1, characterized in that: In step S1, the decomposition steps are as follows: S11. Complete the download and installation of the Java toolkit and configure the Java environment variables in the control panel; S12. Build a Jar package based on the Java SE platform.
4. The method of running R language and deploying machine learning algorithms in AnyLogic software environment according to claim 1, characterized in that: In step S2, the first level sub-package includes nine Java classes: CodeUtils, EventHandler, Globals, JavaObject, RCaller, RCode, ROutputParser, RPlotViewer and RstreamHandler.
5. The method of running R language and deploying machine learning algorithms in AnyLogic software environment according to claim 1, characterized in that: In step S2, the two second-level sub-packets of the first first-level sub-packet are respectively the first second-level sub-packet and the second second-level sub-packet, and the first and second second-level sub-packets are constructed as follows: 1) Configure the operating environment and main parameters of the first and second level subpackages, including the RCaller class Java dependency that implements the parsing, execution and output of R scripts and the RCode class Java dependency that provides a method for dynamically building R language codes; 2) Set the main functional functions of the first and second level sub-packages and their relationships.
6. A method of running R language and deploying machine learning algorithms in AnyLogic software environment according to claim 5, characterized in that: The steps for constructing the second level sub-package are: 1) Configure the operating environment and main parameters of the second-level sub-package, including the JDK base package java.lang.Exception, the superclass of Java exceptions that can be coded and resolved, as a dependency; 2) Set the main functional functions of the second and second-level sub-packages.
7. The method of running R language and deploying machine learning algorithms in AnyLogic software environment according to claim 1, characterized in that: In step S2, the steps for constructing the second level sub-package are as follows: 1) Configure the operating environment and main parameters of the second-level subpackage, including the JDK base package java.awt.Color, which provides classes and interfaces for managing and manipulating colors, as a dependency; 2) Set the main functional functions of the second-level sub-package.
8. The method of running R language and deploying machine learning algorithms in AnyLogic software environment according to claim 1, characterized in that: In step S3, the decomposition steps are as follows: S31: Transplant the project into the AnyLogic software environment, convert all main packages, first-level sub-packages, and second-level sub-packages into "agent types" in the AnyLogic environment, and transfer the Java classes of each sub-package into the corresponding agent types; complete the construction of the structure and content of the Java package in steps S1 to S2 in the AnyLogic environment; S32. Create a new library in AnyLogic software to run R code to deploy machine learning and deep reinforcement learning in simulation experiments. S33. Operate the AnyLogic software interface to export the constructed plug-in library as an independent Jar package.
9. The method of running R language and deploying machine learning algorithms in AnyLogic software environment according to claim 1, characterized in that: In step S5, the decomposition steps are as follows: S51, prepare the algorithm model on paper, and then install the required R language packages; S52: In the RGui graphical user interface or RStudio integrated development environment, reference the installed R language package to conduct preliminary experiments on the R language machine learning algorithm to achieve the expected experimental results; S53: In AnyLogic software, complete the migration of the pre-experimental R language code to the Java environment, and add the R script to the simulation environment using the function statement form of the R code referenced by the plug-in library.
10. The method of running R language and deploying machine learning algorithms in AnyLogic software environment according to claim 2, characterized in that: In step S6, the decomposition steps are as follows: S61. Use the nested mode of "R script function + conditional trigger event" or "native library function block + R script parameter transfer" to organically integrate the machine learning method carried by R language into the simulation method based on discrete events, system dynamics and intelligent agents; S62, using the R language based machine learning method to predict the delay time value at the delay time of the Delay or Service component of the process modeling library; The queue capacity predicted by the R language machine learning method is used at the capacity of the Queue component of the process modeling library; the storage capacity predicted by the R language machine learning method is used at the capacity of the Pipeline component of the fluid library; the key parameter values predicted by the R language machine learning method are used at the equation mode-customization of the Stock component of the system dynamics library; The dynamic variable values are predicted using R-based machine learning methods at the assignment of dynamic variable components in the system dynamics library.
Citation Information
Patent Citations
Interaction method based on Anylogic simulation model and GIS (Geographic Information System) environment
CN104133924A
Production system parameter adaptive optimization method based on logistics simulation and machine learning
CN113627087A
BWB passenger plane emergency evacuation simulation analysis method
CN115758695A
Anylogic and python reinforcement learning algorithm interaction method
CN117807869A
Rapid prototyping model
US20210174273A1