You use Decision Center to run this sample.
To generate random data for a specific number of scenarios, create a simulation that uses the RandomData format for the usage scenarios.
Create the Random Simulation simulation:
If you signed out, sign in again to Decision Center using rtsConfig.
Click the Compose tab, select Simulation, and then click OK.
In Step 1: Properties, enter Random Simulation as the name of the simulation, and click Next.
In Step 2: Rules tested, click Next to test all the rules of the current project.
In Step 3: Scenarios, select RandomData from the Format list.
The content of the Scenarios step changes to reflect the information required when using the RandomData format.
Enter 50 in the Number of scenarios field.
This value sets the number of scenarios to use in the simulation.
Click Finish to create the simulation.
Decision Center displays the details of the new simulation.
Run the Random Simulation simulation:
Click Run in the toolbar.
Select Sample as the server.
Click Run to run the simulation.
The run takes a few seconds to complete.
The simulation uses the RandomData scenario provider to run 50 scenarios created from random input data.
The report displays a KPI that indicates the overall performance of the simulation:
Key Performance Indicators | Loan Approval Rate 26.666668 % for 15 borrowers with income < 60000 Simulation on 50 scenarios |
From the 50 scenarios, 15 potential borrowers are found to have an income less than 60,000. The value of 60,000 is defined in the KPI. From the list of 15, only 4 are granted a loan based on the rules in the loan validation project. The loan success rate is 26.667%.
Create a History Simulation simulation:
Now, create a simulation that reads data from a database.
Click the Compose tab, select Simulation, and then click OK.
In Step 1: Properties, enter History Simulation as the name of the simulation, and click Next.
In Step 2: Rules tested, click Next.
Click Step 3: Scenarios, select HistoricalData from the Format list.
The content of the Scenarios step changes to reflect the information required when using the HistoricalData format.
Enter 60000 in the Maximum income field.
This value is used to query the database and make a preliminary selection of scenarios. The KPI that is used also tests for a maximum income of 60,000.
Click Finish to create the simulation.
Decision Center displays the details of the new simulation.
Run the History Simulation simulation:
Click Run in the toolbar.
Select Sample as the server.
Click Run to run the simulation.
The run takes a few seconds to complete.
The simulation uses the HistoricalData scenario provider, which queries a database of historical data. From the database, 30 potential borrowers are found to have an income less than 60,000.
The Decision Center displays the KPI results, which are also stored in the database.
Key Performance Indicators | Loan Approval Rate 30.000002 % for 30 borrowers with income < 60000 Simulation on 30 scenarios |
The result of running the rules in the loan validation project against these 30 borrowers is that only 9 of them are given a loan. The loan success rate is 30%.
Click the Report button to obtain a report with diagrams that represent the accepted and rejected loan requests.
The run takes a few moments.
Create two simulations to demonstrate parallel execution:
To demonstrate parallel execution a different database is used, which contains 100,000 entries. This database contains similar scenarios to the HistoricalData database, but there are many more scenarios (rows). Parallel execution reduces the time it takes to run a simulation. Using a database with many records is a better demonstration of how a parallel scenario provider works.
Click the Compose tab, select Simulation, and then click OK.
In Step 2: Rules tested, click Next.
Click Step 3: Scenarios, select ParallelHistoricalData from the Format list.
The content of the Scenarios step changes to reflect the information required when using the ParallelHistoricalData format.
This value is used to query the database and make a preliminary selection of scenarios. It shows how to pass a parameter from Decision Center to the scenario provider. The KPI is the same one that is used for the History Simulation, which tests for a maximum income of 60,000.
Enter 1 in the Number of parts field.
Decision Center displays the details of the new simulation.
Decision Center displays the details of the new simulation.
Run the Parallel One Part and Parallel Four Parts simulations:
Click the Explore tab, and click Simulations.
Decision Center displays all of the simulations.
Select Sample as the server, and unselect Create an Excel file for the results.
Click Run to run the simulation.
The simulation is started.
Click the Explore tab, and click Simulations.
Select Sample as the server, and unselect Create an Excel file for the results.
Click Run to run the simulation.
Click the Analyze tab, to see the two simulations running.
The simulation with four parts completes before the simulation with one part.
In the KPI report, the results show that the simulation completed in 33 seconds.
Key Performance Indicators | Loan Approval Rate 33.333336 % for 30000 borrowers with income < 60000 Simulation on 80000 scenarios Total Execution Time 33304 ms |
The simulation executes in four threads using the ParallelHistoricalData scenario provider. The provider queries a database that includes 100,000 scenarios, and initially selects the scenarios (80,000) corresponding to borrowers with an income less than 90,000. From these 80,000 scenarios, the KPI results show that only 30,000 potential borrowers are found to have an income less than the KPI required threshold of 60,000. The result of running the rules in the loan validation project against these 30,000 borrowers is that 10,000 of them are given the loan. The loan success rate is 33.33%.
Decision Center displays both of the reports on the same page. On the left is the report for Parallel One Part and on the right is the report for Parallel Four Parts.
The reports are the same, except for the time the simulations took to run. The difference in time is a result of the number of parts. In the KPI for Parallel Four Parts, the results show that the simulation completed in 33 seconds, compared with the 52 seconds that it took to run Parallel One Part.
Key Performance Indicators | Loan Approval Rate 33.333336 % for 30000 borrowers with income < 60000 Simulation on 80000 scenarios Total Execution Time 51566 ms |
The simulation that is divided into four parts executed almost two times faster compared with the simulation that has only one part.
The actual time that it takes to run the simulations can vary depending on the computer you run it on, but the ratio remains the same.
You create the formats and custom scenario providers used in Decision Center in Rule Designer using a DVS project. For more information, see DVS Projects.
To look at the DVS project that contains the custom scenario providers, you can import it into Rule Designer.
To import the projects used in this sample:
In Rule Designer, switch to the Samples Console perspective.
In the Samples and Tutorials view, navigate to
.Click Import projects.
The following projects are imported into your workspace:
The projects open in the Rule Explorer.
The BIRT report described in the DecisionCustomScenarioProvider Sample Report uses the database located in <InstallDir>/shared/data/derby/resdb-customdw. To be able to edit the report in the Report Design perspective in Rule Designer:
In DVSCustomizationProject, double-click SampleCustomization.sspc to view the details of the customization.
In the Formats section, select HistoricalData and click Edit.
The format editor opens.
You can see the HistoricalData scenario provider main class, as well as the renderer class, and the KPI classes.
To define a custom scenario provider, you define an implementation for IlrScenarioProvider.
To define this implementation you:
Initialize the provider
Close the provider
Provide the number of scenarios defined
Build each scenario one by one
The scenario is an IlrScenarioImpl object with its input parameters.
To define a parallel scenario provider you:
In this sample, the previous implementation of IlrScenarioProvider is extended to implement the IlrParallelScenarioProvider interface.
A scenario part is an instance of IlrParallelScenarioProvider.IlrScenarioSuitePart.
To define a renderer for Decision Center that corresponds to the custom scenario provider, you define an implementation for IlrScenarioSuiteResourcesRenderer.
To define this implementation, you:
Get the parameters for the provider
Define the HTML to view the provider parameters
Define the HTML to edit the provider parameters
In Decision Center, you define a parameter that associates the custom scenario provider to its renderer class. The new parameter is defined in the file rtsbin/preferences.properties.
To define a custom KPI, you define an implementation for IlrKPI.
To define an implementation for IlrKPI, you:
Initialize the KPI
Compute the KPI
Provide KPI results
The KPI result class implements IlrKPIResult. It defines how to encode and decode the result from the SSP to Decision Center. The KPI result can be a predefined type encoded to an array of bytes to be shown in Decision Center.
By default, the predefined IlrKPIResult classes have associated renderers. Define an implementation of IlrScenarioSuiteKPIRenderer to have a different KPI display from the Decision Center classic display. For example, in the ApprovedKPIRenderer class, the color of the KPI result is computed according to the KPI value and you use a Report button to access a BIRT report with diagrams that represent the accepted and rejected loan requests.
In Decision Center, you define a configuration parameter that associates the custom KPI to its renderer class. The new parameter is defined in the file rtsbin/preferences.properties.
A custom KPI has an associated message. You define this message in a messages.properties file that is added to the Decision Center application.
To control the custom scenario provider, the Decision Center renderers, and the KPIs you create a DVS Project in Rule Designer. In this project you specify the format against which you want to execute tests and simulations. The customization includes a definition of the scenario provider, the rule project, and the KPIs. A DVS project can also contain a configuration that specifies the application server that is used to run the tests.
The Repackage feature, available through the DVS customization in the DVS project, generates a build.xml file. This file contains Ant targets to repackage the web applications for the Scenario Service Provider and Decision Center.
This sample uses a build.xml file that calls the generated build.xml.
You perform the deployment of the custom scenario provider in this sample using Ant. The sample includes the following Ant targets in the <InstallDir>/teamserver/samples/dvscustomscenarioprovider/build.xml file:
This sample is located in <InstallDir>/teamserver/samples/dvscustomscenarioprovider.
The provider classes are located in <InstallDir>/teamserver/samples/dvscustomscenarioprovider/DVSCustomizationProject/src/ilog/rules/dvs/samples.
Class | Description |
---|---|
custom/HistoricalScenarioProvider.java | The implementation of IlrScenarioProvider that collects scenarios from the database using the derby/DatabaseApi.java interface. It uses an instance of FullHistoryData as an implementation of this interface.
|
custom/ParallelHistoricalScenarioProvider.java | The implementation of IlrParallelScenarioProvider that inherits
from HistoricalScenarioProvider. It uses an instance
of HistoryData as an implementation of DatabaseApi.
|
custom/RandomScenarioProvider.java | The implementation of IlrScenarioProvider that creates scenarios on demand.
|
The KPI classes are located in <InstallDir>/teamserver/samples/dvscustomscenarioprovider/DVSCustomizationProject/src/ilog/rules/dvs/samples/custom.
Class | Description |
---|---|
ApprovedKPI.java | The implementation of IlrKPI that computes the number of loans approved.
|
ApprovedIncomeKPI.java | The implementation of IlrKPI that computes the number of loans approved for borrowers with a limited income.
|
ApprovedKPIResultAggregator.java | The implementation of IlrKPIResultAggregator that computes the number of loans approved for borrowers with a limited income:
|
You must package the KPI result class in both Decision Validation Services and Decision Center. The KPI result class is located in <InstallDir>/teamserver/samples/dvscustomscenarioprovider/DVSCustomizationProject/src/ilog/rules/dvs/samples/custom.
Class | Description |
---|---|
KPIResultInteger.java | The implementation of IlrKPIResult for an integer value:
|
The renderer classes are located in <InstallDir>/teamserver/samples/dvscustomscenarioprovider/DVSCustomizationProject/src/ilog/rules/dvs/samples/custom.
Class | Description |
---|---|
HistoricalScenarioSuiteResourcesRenderer.java | The implementation of IlrScenarioSuiteResourcesRenderer that displays the HistoricalData format:
|
RandomScenarioSuiteResourcesRenderer.java | The implementation of IlrScenarioSuiteResourcesRenderer that displays the RandomData format:
|
ParallelScenarioSuiteResourcesRenderer.java | The implementation of IlrScenarioSuiteResourcesRenderer that displays the ParallelHistoricalData:
|
ApprovedKPIRenderer.java | The implementation of IlrScenarioSuiteKPIRenderer that defines how to view the KPI results.
|
ApprovedIncomeKPIRenderer.java | The implementation of IlrScenarioSuiteKPIRenderer that defines how to view the KPI results of the class IlrKPIResultMap.
|
The utility classes are located in <InstallDir>/teamserver/samples/dvscustomscenarioprovider/DVSCustomizationProject/src/ilog/rules/dvs/samples/derby.
Class | Description |
---|---|
DataFactory.java | Creates a random loan or borrower. |
DatabaseApi.java | Interface to get the data from a database. Gets the data source and reads and writes data to the database. |
FullHistoryData.java | The implementation of DatabaseApi used by the HistoryScenarioProvider to get/set data in the customdw database. |
HistoryData.java | The implementation of DatabaseApi used
by the ParallelHistoryScenarioProvider to get data
from the bigcustomdw database. Note:
The time it takes to query the database can contribute a lot to the overall execution time, so optimizing queries is important to look at. The HistoryData.java class gives an example of an optimized query to a Derby database. |
The BIRT report approved_rejected_report.rptdesign that shows the contents of the database is defined in <InstallDir>/teamserver/samples/dvscustomscenarioprovider/report/reports.