Rule Designer API

ilog.rules.dvs.core
Interface IlrKPI

All Superinterfaces:
IlrInitializable, IlrSimulationKPI

public interface IlrKPI
extends IlrSimulationKPI

IlrKPI is the interface for the calculated key performance indicators (KPIs) during a sequential execution of a simulation.

Overview

IlrKPI is the interface for the calculated key performance indicators (KPIs) during a sequential execution of a simulation. It is used as a standalone KPI implementation when running a simulation sequentially, or in combination with an IlrKPIResultAggregator instance when running a simulation using parallel execution.

An IlrKPI object acts as a scenario suite observer. It enables the suite to compute data for a set of scenarios.

The callback methods in this interface are called by the SSP runner during simulation execution. The ilog.rules.dvs.core package description gives more information on how IlrKPI interacts with IlrScenarioSuiteKPIRenderer and IlrKPIResult.

The life cycle of a KPI is:

Example

The following example defines a KPI computing the approval percentage for borrowers who have an income that is lower than the given limit:

 public class ApprovedIncomeKPI implements IlrKPI {
 protected int m_totalCount;
 protected int m_approvalCount;
 protected int m_incomeMax = 60000;

 public void close() {
 }

 public void initialize(IlrScenarioSuiteExecutionContext context) {
    m_totalCount = 0;
    m_approvalCount = 0;
 }

 public void onScenarioBegin(IlrScenario scenario, IlrSessionRequest request) {
 }

 // Checks whether or not the loan is approved and stores the intermediate results in m_approvalCount and m_totalCount.

 public void onScenarioEnd(IlrScenario scenario, IlrSessionRequest request,
 IlrSessionResponse response) throws IlrKPIException {
          // Retrieve the borrower from the parameters list
          Map params;
          try {
               params = scenario.getInputParameters();
          } catch(IlrScenarioDataException e) {
                 throw new IlrKPIException(e);
          }
          Borrower b = (Borrower) params.get("borrower");
          // Update the two counters for this scenario
          if (b.getYearlyIncome() < m_incomeMax) {
              m_totalCount++;
              Report report = (Report) response.getOutputParameters().get("report");

              if (report != null && report.isApproved())
                  m_approvalCount++;
          }
 }

  // Compute the percentage and send it as a result.

  public IlrKPIResult getKPIResult() {
      KPIResultString result = new KPIResultString();
      result.setKPIClassName(this.getClass().getName());
      float percent = 0;
      if (m_totalCount != 0) {
          percent = m_approvalCount / (float) m_totalCount * 100;
      }
      result.setValue("The loan approval rate for " + m_totalCount + " runs with income < "
               + m_incomeMax + " is " + (int) percent + "%");
      return result;
  }     
 }
 

About the DVS API

Decision Validation Services provides business rule testing and simulation solutions to developers and business users.

You use the DVS API to:

Since:
7.0

Method Summary
 void onScenarioBegin(IlrScenario scenario, IlrSessionRequest request)
          Called by the runner before the ruleset is executed.
 void onScenarioEnd(IlrScenario scenario, IlrSessionRequest request, IlrSessionResponse response)
          Called by the runner after the ruleset has executed.
 
Methods inherited from interface ilog.rules.dvs.core.IlrSimulationKPI
close, getKPIResult
 
Methods inherited from interface ilog.rules.dvs.core.IlrInitializable
initialize
 

Method Detail

onScenarioBegin

void onScenarioBegin(IlrScenario scenario,
                     IlrSessionRequest request)
                     throws IlrKPIException
Called by the runner before the ruleset is executed. This method is called for each scenario defined in the suite.

Throws:
IlrKPIException - if an error occurs.
Parameters:
scenario - The scenario.
request - The request used to execute the ruleset to test.

onScenarioEnd

void onScenarioEnd(IlrScenario scenario,
                   IlrSessionRequest request,
                   IlrSessionResponse response)
                   throws IlrKPIException
Called by the runner after the ruleset has executed. This method is called for each scenario defined in the suite. When it is called, the report element is not yet available from the suite report.

Throws:
IlrKPIException - if an error occurs.
Parameters:
scenario - The scenario.
request - The request used to execute the ruleset to test.
response - The response returned by executing the ruleset.

Rule Designer API

© Copyright IBM Corp. 1987, 2013