You define a task for computing rental prices for eligible customers, and run the rules
with the RetePlus algorithm.
About this task
You define a second rule task, which computes rental prices for eligible customers.
Procedure
- Select the pricing rule
task in the ruleflow diagram.
- In the Properties view, click Rule Selection, and then click
Edit.
- In the Select Rules dialog, select the pricing rule
package. Use the arrow to move it to the panel on the side, and then
click OK.
The
rule task now includes all the rules in the pricing rule
package.
- In the Properties view, click Rule Task,
and for Algorithm, select RetePlus. The RetePlus mode is better suited for pricing rules because
they use inference. It means that objects in the working memory are
modified by the rules and the condition for firing the rules should
be reevaluated. For more information on the RetePlus mode, see Engine execution modes.
- In the Properties view, click Rule Selection and
under Choose runtime rule selection, select Static
BAL.
- Enter the following code:
the pickup date of 'the current rental agreement' is after or the same as
the effective date of 'the rule',
or by default the start date of the session
and
the pickup date of 'the current rental agreement' is before
the expiration date of 'the rule',
or by default the end date of the session
With this runtime rule selection statement, you specify
that only the pricing rules that are still in effect and have not
expired by the date of the pickup can be evaluated as part of the
pricing rule task at run time.
- In the Properties view, click Final Action,
select IRL, and then type the following code:
java.util.List offersList = new ArrayList(rental.offers);
Collections.sort(offersList);
Iterator it = offersList.iterator();
while (it.hasNext()) {
Offer offer = (Offer) it.next();
session.displayMessage(" * Offer: " + offer);
}
session.displayMessage(" # Best Offer: " + rental.bestOffer);
After you finish executing the rule task, the Console
output displays a message that lists the prices of all available offers
and shows which one is the best deal for the customer.
- Because you used IRL for the final action, you must add
the imports used for the BOM classes:
- Click in an empty part of the ruleflow diagram.
- In the Properties view for the ruleflow, click Imports.
- Type the following imports:
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.Date;
import carrental.Offer;
use rental;
use session;
- Save your work.
Results
In the next task, you define the conditions under
which the transition between the eligibility rule
task and the pricing rule task can be taken as part
of the ruleflow execution path.