Evaluation is a Rate Object that allows you to assign variables and use math via Python.
Tip: Basic knowledge of Python is helpful.
Core Concepts
Running total
The Rate Chain serves as a running total for premium calculation. By breaking the chain during the build, you can hide any given step in the chain from users when they’re viewing the rate chain calculation on a policy.
Important: Breaking the chain during the build breaks the premium from the running total concept.
Master Premium
Master Premium uses a line item’s total premium evaluation result and ignores any other rate objects assigned to the premium.
Variables
You can set each step in the Rate Chain to a variable (numbers or dictionaries) to reference later or use for premium calculation.
BriteCore setup
Using the Evaluation line item, you can calculate premium by referencing various items:
- The line item
- Additional line items
- Sublines
- Properties
You will need to use specific syntax to reference each item.
Reference the line item
To reference the line item, use the following syntax:
Limits
Use this.limit to reference the line item's own limit.
Premium
Use this.premium to reference the line item's own premium, which is the Rate Chain premium of the item up to the point of this.premiumevaluation.
Deductible
Use this.deductible to reference the line item’s own deductible.
Categories
Use this.categories to reference the line item's own categories.
Miscellaneous
- Use this.policy_inception_date.year to reference the inception date of the policy.
- Use this.policy_term_effective_date.year to reference the effective date of the current term.
Reference additional line items
To reference additional line items, use the following syntax:
Limits
- Use items["line item name"].limit to reference another item's limit. You can’t use limit(items["Coverage A - Dwelling"]) as you do with premium, because the function isn’t currently supported.
- Use limit([items.get("line item name", 0), items.get("line item name", 0), items.get("line item name", 0)]) to return the limit of identified line items. If a line item isn’t on the policy, then 0 will be returned.
Premium
- Use items["line item name"].premium or premium(items["line item name"]) to reference the premium of a specified line item. If the line item’s premium is referenced, BriteCore rates the referenced item in order to get its premium.
- Use premium(this.property) to calculate the premium for all coverages (policy_type_items.type = ‘coverage’) in the Primary Exposures section. Since this function rates numerous coverages, you should use it sparingly to avoid extended processing time. The premium(this.property) function:
- Rates all coverage line items so no other line items can reference the line item with this evaluation without creating a loop.
- Requires every other item on the property to be rated to return the right amount. If the function runs into an item that hasn’t been rated, it tries to rate it. For instance, if item A runs premium(this.property) and item B looks at item A’s premium, item B won’t ever be able to rate.
- Use premium(items['line item name'], items['line item name']) to return the sum of the premiums of all identified line items.
- Use premium([items.get("line item name", 0), items.get("line item name", 0), items.get("line item name", 0)]) to return the sum of the premium of identified line items. If a line item isn’t on the policy, then 0 will be returned.
Deductible
Use items[“line item name”].deductible to reference another line item’s deductible.
Categories
- Use items[“line item name”].categories[“category name”] to reference a category within another line item.
- Use items['line item name'].categories[“category name”] in [“cat1 name”, “cat 2 name”] to reference multiple categories within another line item.
Check item existence
Note: This replaces if “Line Item” in items.
Use if exists_in_items(‘Line Item’) to check another item’s existence.
Example: items["Test 1"].premium if exists_in_items('Test 1');else d('50')
Reference sublines
To reference sublines, use the following syntax:
Premium
Use premium([item for item in this.property.all_items() if item.sub_line_name == "My Special SubLine and not item.is_a_calculation"]) to reference the premium of all items in a subline that aren’t calculation items.
Reference properties
Use this.stage_properties() and premium(this.properties) to reference properties.
Miscellaneous syntax
To reference miscellaneous items, use the following syntax:
Revision Date
Use this.revision.revision_date.year to reference a policy's revision date year.
Instance List
Use instance_list to reference and retrieve values from every instance of another specified line item.
Use sum([i.customVarName for i in items["Test Multiples"].instance_list]) to add every instance of Test Multiples and get a sum.
Decimals
Use d() for decimals because d():
- Is necessary because of floating-point rounding errors.
- Is a wrapper for Python's Decimal function.
- Accepts a string data type. The syntax d(1.5) won’t work because 1.5 is a float. To process decimals without floating-point rounding errors, use a string.
Rounding
Since you can’t round a float, use round() with decimals.
Example: round(d(“3.5”))
Control Statements
Tip: When possible, break up statements because writing multiple if-else statements makes the statements hard to read.
Single if statement:
(this.premium * 3) if this.premium < 100 else 220
Single if statement with defined value range:
this.variableName1 if this.variableName2 >= 1000000 and
this.variableName2 <= 5000000 else 0
Multiple if-else statements:
d("140.00")
if this.limit == 300000 else
if this.limit == 500000 else
if this.limit == 1000000 else
d("1000000.00")
Get
Use get() to retrieve data from a dictionary.
Interpolate Between Values
Use interpolate (this.limit, the thing you want to interpolate) to interpolate between values.
Dictionaries
For dictionaries, use the following syntax:
{"Owner": 1, "Tenant": d("1.2"), "Seasonal": d("1.4")}
{"Frame":{"1": 1, "2": 2},"Masonry":{"1": 3, "2": 4}}
FAQs
Does the Evaluation Rate Object support case/switch operations?
Python doesn’t have a concept of case/switch. It supports multiple if statements. Depending upon the need, it might be cleaner to create a dictionary rather than multiple ifs. If multiple ifs are needed, it is recommended to break the multiple *ifs* into separate evaluations.
Multiple ifs:
if test_value == 'something':
other_value = 'result1'
elif test_value == 'something else':
other_value = 'result2'
elif test_value == 'last value':
other_value = 'final result'
else:
other_value = 'default'
Dictionary:
other_value = {
"something": "result1",
"something else": "result2",
"last value": "final result",
}.get(test_value, "default)
What resources can I use to troubleshoot Python errors?
- Python docs
- Stackoverflow
- pudb
- Python terminal (to recreate an issue)
What does the error File "", line 1 indicate?
This error typically indicates a syntax error.
What does the error InvalidOperation: Invalid literal for decimal indicate?
This error indicates you used a comma in your number (e.g., 1,500 instead of 1500). To correct the issue, remove the comma.