Car Insurance

◷ Reading Time: 16 minutes

This sample project is for the Car Insurance industry and calculates the premium of a car based on Auto and Base premium components. The business rules are for risk classification and calculation of the insurance premium.

Decision Model

The main Car Premium.xml decision graph automatically resolves the dependencies between different logic implementations (i.e. decision table, natural language, etc.).

There are two inputs to this graph, Car and the High Theft Probability. The Car details input feeds into the Base premium, Car Style premium and the rating determination decisions.

The High Theft Probability data and two business knowledge documents are used to determine the rating.

The Rating, Car style calculate the Auto premium. This along with the Base premium decision feed into the final car premium decision. There is a Knowledge source document Underwriting Guidelines that is reference to the overarching Premium calculation.

Example of a decision graph for the Car Insurance premium calculation

Decision Flow

If a Flow is preferred, then the decision requirement diagram above can be presented as a Decision Flow. For this example, add a start node and link to an Activity node that loads High risk cars from the Database. This is then linked to three Decision tables, Theft Rating, Injury Rating and a final Premium calculation. Finally an End node completes the flow.

Example of a Decision flow as an alternative to a decision graph to calculate premium.

Business Rules

This sample project calculates the premium of a car based on Auto and Base premium components. The following business rules are for risk classification and calculation of the premium of a car.

Potential Theft Category definition

  • If the car is a convertible, then the car’s potential theft rating is high.
  • If the car’s price is greater than $45,000, then the car’s potential theft rating is high.
  • If the car model is on the list of “High Theft Probability Auto”, then the car’s potential theft rating is high.
  • If all of the following are true, then the car’s potential theft rating is moderate.
    • car’s price is between $20,000 and $45,000,
    • the car model is not on the list of “High Theft Probability Auto”
  • If all of the following are true, then the car’s potential theft rating is low:
    • car’s price is less than $20,000
    • the car model is not on the list of “High Theft Probability Auto”

(The “High Theft Probability Auto” list is maintained by Risk Management and provided as input to the eligibility rating process. This list is retrieved from a Database e.g. MS SQL SERVER)

Potential Occupant Injury Category

  • If the car has no airbags, then the car’s potential occupant injury rating is extremely high.
  • If the car only has driver’s side airbags, then the car’s potential occupant injury rating is high.
  • If the car has driver’s side and front passenger airbags, then the car’s potential occupant injury rating is moderate.
  • If the car has a driver, front passenger and side panel airbags, then the car’s potential occupant injury is low.
  • If the car is a convertible and has no roll bar, then the potential occupant injury is extremely high.

Auto Premiums calculation

  • If a compact car, then the base premium is $250.
  • If sedan, then the base premium is $400.
  • If a luxury car, then the base premium is $500.
  • If the car is new, then increase the premium by $400.
  • If the model year is the same as the current year, then this is a new car.
  • If the model year is the same as next year, then the car is new.
  • If the car is less than 5 years old, then increase the premium by $300.
  • If the car is between 5 and 10 years old, then increase the premium by $250.
  • If uninsured motorist coverage is included, then increase the premium by $300
  • If medical coverage is included, then increase the premium by $600.
  • If Potential Occupant Injury is Extremely High, then increase the premium by $1,000.
  • If Potential Occupant Injury is High, then increase the premium by $500.
  • If Potential Theft is High, then increase the premium by $500.

Decision Tables

The above business rules in each decision are formalized as shown in the Decision Tables below:

Potential Theft Rating Decision Table

Car is listed in “High Theft Probability Auto”Car is ConvertiblePriceTheft Rating
FALSE< 20000Low
FALSE[20000; 45000]Moderate
TRUEHigh
TRUEHigh
>= 45000High

Potential Occupancy Injury Rating Decision Table

Driver’s AirbagFront Passenger’s AirbagSide Panel AirbagRoll barConvertibleOccupant Injury Rating
TRUEFALSEFALSEHigh
TRUETRUEFALSEModerate
TRUETRUELow
FALSETRUEExtremely High
Extremely High

Calculate Premiums Decision Table

Auto Premium
Is Car
New?
Car AgeUninsured Motorist
coverage is included
Medical coverage
is included
Potential Occupant
Injury Rate
Potential
Theft Rating
Rule NumberAuto
Premium
R1= 0
R2+= 250
R3+= 400
R4+= 500
TRUER5+= 400
FALSE< 5R6+= 300
FALSE[5; 10]R7+= 250
TRUER8+= 300
TRUER9+= 600
ExtremelyHighR10+= 1000
HighR11+= 500
HighR12+= 500
Base Premium
Car TypeRule NumberAuto
Premium
R1= 0
CompactR2+= 250
SedanR3+= 400
LuxuryR4+= 500

Open the Car Insurance sample project

On the Home screen, under Sample Gallery, search for “Car Insurance”. Then click on Download & Install.

FlexRule Designer Start modal showing the Car Insurance sample project in the Sample Gallery tab

In Designer, Open the downloaded project (if it has not opened after download).

Looking at the logic documents in the Project Explorer view, Car Flow.xml is the main model that connects all the sub-models.

Car Flow.xml, this is the main Model for the Car Insurance project

Database Setup

Install MS SQL and MS SQL Server Management Studio.

Once installed, open MS SQL Studio and create the following database and tables.

HighRiskCars

The Potential Theft Category decision needs to access a list of “High Theft Probability Auto” which is maintained in our sample database. You can follow the instructions below to create your own sample database.

Create Table

Create a Database called Car-Insurance and then run the following script against it to create a table called HighRiskCars

USE [Car-Insurance]
GO

CREATE TABLE [dbo].[HighRiskCars](
 [Id] [int] IDENTITY(1,1) NOT NULL,
 [Made] [nvarchar](50) NULL,
 [Model] [nvarchar](50) NULL,
 CONSTRAINT [PK_HighRiskCars] PRIMARY KEY CLUSTERED 
( [Id] ASC ) ON [PRIMARY]
) 
GO

Prepare Data

Once you create the database called Car-Insurance Run the script below to create the required data records:

USE [Car-Insurance]
GO
 
INSERT INTO [dbo].[HighRiskCars] VALUES ('Hyundai','IX35')
INSERT INTO [dbo].[HighRiskCars] VALUES ('BMW','E63')
GO

Thefts

In this version of the sample project, an Information Requirements Diagram is used to build up the HighTheftAutoList rather than reading it directly from the database.

Create Table

Create a Database called Car-Insurance and then run the following script against it to create a table called Thefts

USE [Car-Insurance]
GO

CREATE TABLE [dbo].[Thefts]( 
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[Made] [nvarchar](50) NOT NULL,
	[Model] [nvarchar](50) NOT NULL,
	[Year] [int] NOT NULL,
	[Type] [nvarchar](50) NOT NULL,
	[Location] [nvarchar](50) NOT NULL,
	[Use] [nvarchar](50) NULL
)

GO

Prepare Data

Once you create the database called Car-Insurance Run the script below to create the required data records:

USE [Car-Insurance]
GO
 
INSERT INTO [dbo].[Thefts] VALUES ('Honda','CR-Z',2014,'Sedan','VIC','City')
INSERT INTO [dbo].[Thefts] VALUES ('Hyundai','IX35',2012,'SUV','VIC','Off-road')
INSERT INTO [dbo].[Thefts] VALUES ('Honda','Passport',1995,'Van','NSW','Off-road')
INSERT INTO [dbo].[Thefts] VALUES ('BMW','E63',2016,'Sedan','VIC','City')
INSERT INTO [dbo].[Thefts] VALUES ('Ford','Pickup',2010,'Van','NT','City')
INSERT INTO [dbo].[Thefts] VALUES ('Ford','Ranger',1920,'Wagon','VIC','Off-road')
INSERT INTO [dbo].[Thefts] VALUES ('Ford','Taurus',2000,'Sedan','VIC','City')
INSERT INTO [dbo].[Thefts] VALUES ('Austin','Mini',2000,'Mini','NSW','City')
INSERT INTO [dbo].[Thefts] VALUES ('Hyundai','Santa Fe',2010,'SUV','VIC','City')
INSERT INTO [dbo].[Thefts] VALUES ('Hyundai','Tucson',2010,'SUV','VIC','City')
INSERT INTO [dbo].[Thefts] VALUES ('Ford','Pickup',2010,'Van','NSW','City')
INSERT INTO [dbo].[Thefts] VALUES ('Ford','Ranger',1920,'Wagon','NSW','City')
INSERT INTO [dbo].[Thefts] VALUES ('Ford','Taurus',2000,'Sedan','NSW','Off-road')
INSERT INTO [dbo].[Thefts] VALUES ('Hyundai','Santa Fe',2010,'SUV','NSW','Off-road')
INSERT INTO [dbo].[Thefts] VALUES ('Honda','CRF250l',2014,'Motorcycle','VIC','Off-road')
INSERT INTO [dbo].[Thefts] VALUES ('Aprila','RS250',2010,'Motorcycle','VIC','City')
INSERT INTO [dbo].[Thefts] VALUES ('Kawasaki','KR1',2014,'Motorcycle','VIC','Off-road')
INSERT INTO [dbo].[Thefts] VALUES ('Suzuki','RGV250',2015,'Motorcycle','VIC','City')
INSERT INTO [dbo].[Thefts] VALUES ('Yamaha','TZR250',2015,'Motorcycle','VIC','City')
INSERT INTO [dbo].[Thefts] VALUES ('Suzuki','RMX450Z',2015,'Motorcycle','NSW','Off-road')
GO

Cars

Create Table

Create a Database called Car-Insurance and then run the following script against it to create a table called Cars

USE [Car-Insurance]
GO

CREATE TABLE [dbo].[Cars]( 
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[Made] [nvarchar](50) NOT NULL,
	[Model] [nvarchar](50) NOT NULL,
	[Year] [int] NOT NULL,
	[Type] [nvarchar](50) NOT NULL,
	[Location] [nvarchar](50) NOT NULL,
	[Use] [nvarchar](50) NULL
)

GO

Prepare Data

Once you create the database called Car-Insurance Run the script below to create the required data records:

USE [Car-Insurance]
GO
 
INSERT INTO [dbo].[Cars] VALUES ('Honda','CR-Z',2014,'Sedan','VIC','City')
INSERT INTO [dbo].[Cars] VALUES ('Hyundai','IX35',2012,'SUV','VIC','Off-road')
INSERT INTO [dbo].[Cars] VALUES ('Honda','Passport',1995,'Van','NSW','Off-road')
INSERT INTO [dbo].[Cars] VALUES ('BMW','E63',2016,'Sedan','VIC','City')
INSERT INTO [dbo].[Cars] VALUES ('Ford','Pickup',2010,'Van','NT','City')
INSERT INTO [dbo].[Cars] VALUES ('Ford','Ranger',1920,'Wagon','VIC','Off-road')
INSERT INTO [dbo].[Cars] VALUES ('Ford','Taurus',2000,'Sedan','VIC','City')
INSERT INTO [dbo].[Cars] VALUES ('Austin','Mini',2000,'Mini','NSW','City')
INSERT INTO [dbo].[Cars] VALUES ('Hyundai','Santa Fe',2010,'SUV','VIC','City')
INSERT INTO [dbo].[Cars] VALUES ('Hyundai','Tucson',2010,'SUV','VIC','City')
INSERT INTO [dbo].[Cars] VALUES ('Ford','Pickup',2010,'Van','NSW','City')
INSERT INTO [dbo].[Cars] VALUES ('Ford','Ranger',1920,'Wagon','NSW','City')
INSERT INTO [dbo].[Cars] VALUES ('Ford','Taurus',2000,'Sedan','NSW','Off-road')
INSERT INTO [dbo].[Cars] VALUES ('Hyundai','Santa Fe',2010,'SUV','NSW','Off-road')
INSERT INTO [dbo].[Cars] VALUES ('Honda','CRF250l',2014,'Motorcycle','VIC','Off-road')
INSERT INTO [dbo].[Cars] VALUES ('Aprila','RS250',2010,'Motorcycle','VIC','City')
INSERT INTO [dbo].[Cars] VALUES ('Kawasaki','KR1',2014,'Motorcycle','VIC','Off-road')
INSERT INTO [dbo].[Cars] VALUES ('Suzuki','RGV250',2015,'Motorcycle','VIC','City')
INSERT INTO [dbo].[Cars] VALUES ('Yamaha','TZR250',2015,'Motorcycle','VIC','City')
INSERT INTO [dbo].[Cars] VALUES ('Suzuki','RMX450Z',2015,'Motorcycle','NSW','Off-road')
GO

Project Steps

1. Create the database following the steps above

2. Create a New project in Designer

3. Add a new Generic Flow document to the project

FlexRule Designer New Document modal with the Business Logic folder open and Generic Flow document selected

4. Validate the car

Validate the car using an Input Validation Logic file.

The purpose of creating this logic file is to check the car’s brand and car’s model in the input, which should not be empty. This logic document notifies us if the input does not include the model of the car, giving the notification with the text ‘Car model must be provided,’ and if the input does not include the car’s brand, it gives us ‘Car made must be provided.’

Example of a validate logic from imported file

How to create the validation document:

Add a new Input Validation Logic document to the project.

In 2 steps, we create this validation document.

  • Define which part of input we want to validate.
  • Define the rules.

To define which part of the input should be validated, use the toolbar to drag a Logic operator, drop it under the validation, and change the name of the logic to main.

Then drag and drop the And operator under the Logic (because we want to check two different input parts) and also the Null operator under the And operator. For the Null operator, change ‘Is Negative’ to True from the properties window since we need to check first whether we have a car in our input.

In the next step, add the Validate operation under And operation from the toolbar, and set which value should be checked in the input. In this scenario, we add car. Model as a value to validate the operator in the Properties window. In the same window, add the text that you want to get as a notification in the message under the notice drop-down. Doing the same work for car-made as well.

To define the rules, we add another Logic under the validation to say, check two things: first, these two parts of the input are not Null, and second, these two parts are not empty.

Drag and drop the OR operator under the logic and leave the Null and Empty operators under that. Just put the $v for the value of these two operators in the properties window.

5. Once the car is valid, connect the database and get the required data to calculate the premium value

6. Build High Thefts Probability List

Use an Information Requirements Diagram to define the High Theft Probability depending on the model, city and the country in which the car is being used.

Example of an Information requirement diagram for the car theft probability

7. Calculate the insurance premium

Use a Decision Requirements Diagram to calculate the car insurance premium.

Example of a decision graph for the Car Insurance premium calculation

Decision tables are used to define the rules.

Example of a decision table to define the rules for the Car Insurance premium calculation

Natural Language files were also used for defining the rules.

Example of a Natural Language doc to define the rules for the Car Insurance premium calculation

8. The result shows the Payable amount for the premium

Payable Amount for Car Insurance

How to run the project

1. Open the file Car Flow.xml

2. Click on the Logic Run Template from the main toolbar menu.

Detail view of the Logic Run Template menu item

3. Select a template from the Logic Run Template modal. There are two templates, one with Valid and one with Invalid data. This allows testing of valid and invalid inputs.

Logic Run Template modal with Car Flow template selected

4. Click Debug.

Detail view of the Debug menu item

5. Click Next Step to go to each step of the flow.

Detail view of the Debug new step menu item

If you want to stop debugging and see the output, click Stop Debugging.

Detail view of the Stop Debugging menu item

6. When your model is linked to other models and you are trying to navigate into the child model, FlexRule Designer will ask you to confirm that you wish to open and navigate to the child model and show debug navigation through the child. Or just execute the child model and return the output.

Open Child Model modal confirmation

7. Once the execution is successful, you will see a success notification modal appear.

Test run completed alert modal

8. Navigate to the Parameters view and you will see the final output in this window.

Resulting payable Amount displayed in the Parameter Window

Download the project

Use the attachment at the end of the page to download the sample project.

Updated on February 12, 2024

Article Attachments

Was this article helpful?

Related Articles