Getting good quality data to run simulations in IBM Operational Decision Manager (ODM) is challenging. The traditional approach is to connect to your corporate databases and transform historical data into simulation scenarios with the format expected as input by the decision services.
This article explains how to connect ODM simulation with IBM Business Automation Insight (BAI) events to be used as a source for historical data. This approach is easy to adopt because BAI events contain the input data of historical executions already in the expected format and they are stored in ElasticSearch indexes that can be queried using the HTTP protocol. BAI and ODM are automation components provided as part of IBM Cloud Pak for Business Automation.
Full implementation details are out of the scope for the extension of this article, rather guidelines and implementation ideas are provided.
Previous knowledge of ODM is required.
As pre-requisites, you need IBM Business Automation Insight (BAI) installed. There’re several options, for instance, check here. Also, you must enable the BAI event emitter in ODM following the instructions here.
Follow the steps to Start Samples Server and Start Samples Console. In the Samples and Tutorials perspective, navigate to Getting Started -> Decision Server -> answer and click import projects. Miniloan tutorial projects are imported into the workspace.
- Edit deployment configuration (Miniloan Service -> deployment -> Miniloan) and enable Miniloan Decision Operation to emit events to BAI by adding the following properties:
- Prepare miniloan BOM for testing and simulation. Open member miniloan.Loan. approval status in the BOM editor and check “Ignore for testing and simulation”.
- Save all and deploy the miniloan decision service to your running Samples Server.
- To populate the ElasticSearch index of BAI with ODM events, execute several times the deployed service. You can use HTDS testing from the RES console, or you can launch a batch of HTTP requests with tools like SOAP UI or Postman. At this point, you should be able to see ODM execution events in BAI stored as JSON documents. Run a quick query to check everything is in place by opening the URI: <elastic-search-url> /*odm-timeseries*/_search.
- Next, you have to implement a custom simulation data provider for ODM following product documentation. Implement an ItemReader named ElasticDataReader and make it parametrizable by implementing the following properties in the class:
Note that you will need to reference these properties in the simulation data provider configuration file (extension simx) as explained in the documentation. In our case, it should be like this:
- In ElasticDataReader class, implement the inherited method open() to retrieve the ElasticSearch documents and store them in a local variable. For this purpose, we will use HTTPClient to send the request and Jackson-Databind to manage the JSON content. If you use Maven, just add the coordinates of these projects as dependencies in your pom.xml, otherwise, you can just use the releases already provided by ODM in your installation: <odm>/execution server/lib.
- At this point, we will have a local JSON array with all the hits resulting from our parametrizable ElasticSearch Query. The next step is to implement the inherited method readItem() to retrieve events one by one and map them to miniloan input parameters. Following documentation about the format of ODM events, you can get the input params from the JSON Path “/_source/data/odm/imput-parameters/<param-name>” in each event. Then you use Jackson-Databind ObjectMapper to easily map the JSON parameters to the Java classes miniloan.Loan and miniloan.Borrower and add to the scenario input parameters.
- Follow product documentation of a custom simulation data provider to package your code and deploy it to Decision Server as a resource.
- Login to Decision Center and open Miniloan Service. In the simulations tab, add a data provider using your simulation data provider configuration file (extension simx). Name it “Elastic Data Provider”
- Create a new simulation using “Elastic Data Provider” as a source for the data and fill the parameters for the elastic query. For instance, to simulate with the data of all March executions with a maximum of 15K scenarios, enter this data:
- Run the simulation and check your results in the generated report.
This approach works fine with simple ODM decision services like miloan tutorial. As soon as you have arrays or collections in your decision service input parameters, you will need some transformation of the generated events. This is because of the way the BAI event processor stores JSON events in the ElasticSearch Index. You can find further details in the IBM community. Anyway, there’re several ways to walk around this inconvenience, but this is a good topic for the next article.
Do you want to learn more about decide4AI and keep up to date with future webinars or actions? Follow us on social networks (Linkedin, Twitter, Youtube).