public interface IlrKPI extends IlrSimulationKPI
IlrKPI is the interface for the calculated key performance indicators (KPIs) during a sequential execution of a simulation.
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:
IlrKPI(): Creates a new instance.initialize(): Called once after this object is instantiated.onScenarioBegin(): Called before ruleset execution for each scenario.onScenarioEnd(): Called after ruleset execution for each scenario.getKPIResult(): Called once after all scenarios have been executed. The result will be shown in the report
using the renderer associated to its class.close(): Called once to release resources if necessary.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;
}
}
Decision Validation Services provides business rule testing and simulation solutions to developers and business users.
You use the DVS API to:
| Modifier and Type | Method and Description |
|---|---|
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.
|
close, getKPIResultinitializevoid onScenarioBegin(IlrScenario scenario, IlrSessionRequest request) throws IlrKPIException
IlrKPIException - if an error occurs.scenario - The scenario.request - The request used to execute the ruleset to test.void onScenarioEnd(IlrScenario scenario, IlrSessionRequest request, IlrSessionResponse response) throws IlrKPIException
IlrKPIException - if an error occurs.scenario - The scenario.request - The request used to execute the ruleset to test.response - The response returned by executing the ruleset.© Copyright IBM Corp. 1987, 2017