Optimizing strategies with allow list functions in Pega 7.4
When a globally optimized strategy cannot be optimized because its component or components contain expressions with unsupported functions, you can add the functions to the pyWhitelistfunction data transform or change the strategy logic to contain only supported functions.
Unsupported function in a strategy component
Cause
A strategy component cannot be optimized when it contains functions that are not allow list functions. The following functions and the functions that are listed in the pxWhitelistFunction data transform are allow list functions.
For an example of a function that can be optimized in globally optimized strategies, see the figure in Adding a new allow list function.
Function | Ruleset | Library | Parameters |
---|---|---|---|
divide | Pega-RULES | Math | (BigDecimal::dividend, BigDecimal::divisor) |
today | Pega-RULES | DateTime | N/A |
normal | Pega-DecisionEngine | Random | N/A |
normal | Pega-DecisionEngine | Random | (double::mean, double::sd) |
random | Pega-DecisionEngine | Random | N/A |
random | Pega-DecisionEngine | Random | (double::min, double::max) |
and | N/A | N/A | (boolean::param...) |
or | N/A | N/A | (boolean::param...) |
getDate | Pega-RULES | DateTime | (String::strStamp) |
DateTimeDifference | Pega-RULES | DateTime | (String::beginTime, String::endTime, String::strPrecision) |
if | N/A | N/A | (boolean::condition, then, otherwise) |
Solution
Investigate the strategy that you want to optimize and consider changing the strategy's logic. You might need to use different strategy components or reconfigure the existing ones to remove references to the functions that cannot be optimized. Alternatively, it might be possible to add these functions to the pyWhitelistFunction data transform that is applied in the pxWhitelistFunction data transform and enable optimization for the component that uses the functions.
Adding a new allow list function
When you add a function to the pyWhitelistFunction data transform, consider these requirements:
- Use only the following supported parameters and return types for the new function:
- “java.lang.String”
- “java.math.BigDecimal”
- “java.util.Date”
- “double”
- “java.lang.Double”
- “int”
- “java.lang.Integer”
- “java.lang.Boolean”
- “boolean”
- Do not embed any public APIs in the function body.
- Do not modify the StepPage in the function body.
- Ensure that the function does not have any side effects.
- Enclose column values with double quotes.
- In the navigation panel of Designer Studio, click Records.
- Expand the Data Model section and click Data Transform.
- In the list of data transform rules, click pyWhitelistFunction.
- On the Definition tab, in the column, select , and then specify source values for the following targets, as shown in the following figure:
- .pyFunctionName
- .pyMethodName
- .pyLibraryName
- .pyRuleSetName
- .pyReturnType
- .pyParameters(<APPEND>)
- Save your changes and rerun the globally optimized strategy.
- On the Test tab of the optimized strategy, do a side-by-side comparison to see differences between nonoptimized and optimized results.