Introduction to RASON
About RASON Models and the RASON Server
Rason Subscriptions
Rason Web IDE
Creating and Running a Decision Flow
Defining Your Optimization Model
Defining Your Simulation Model
Performing Sensitivity Analysis
Defining Your Stochastic Optimization Model
Defining Your Data Science Model
Defining Custom Types
Defining Custom Functions
Defining Your Decision Table
Defining Contexts
Using the REST API
REST API Quick Call Endpoints
REST API Endpoints
Decision Flow REST API Endpoints
OData Endpoints
OData Service for Decision Flows
Creating Your Own Application
Using Arrays, For, Loops and Tables
Organization Accounts

Decision Table Containing Duration

Finally, let’s take a look into an example using the data type, duration. The table, tblParkingFee, computes a parking fee based on how long the vehicle is parked in the parking facility. This decision table requires just one input, dtDuration, and one output, parkingFee. According to the refType component, the input dtDuration must be a duration and a number will be returned for the output, parkingFee.


"tblParkingFee": {
	inputs: ["dtDuration"], 
	outputs: ["parkingFee"],
	refTypes: ["duration", "number"],
	hitPolicy: "U",
	rules: [
	   ["<'PT20M'", 0], 
       ["['PT20M'..'PT1H')", "2 *ceiling(duration(dtDuration)/duration('PT20M'))"], 
	   ["['PT1H'..'PT4H')", "6 *ceiling(duration(dtDuration)/duration('PT1H'))"], 
       [">='PT4H'", "30*ceiling(duration(dtDuration)/duration('P1D'))"]]
	}
},

There are two types of formats for Duration:

  • P1Y2M - measures duration in months
  • P1DT1H20M10S – measures duration in seconds

The individual components in these formats are optional; if we have 0 hours to represent, we may skip the hour component. For example, we can represent a 20 minute duration using either: PT0H20M0S or PT20M.

While we can skip a duration component in the format, the order of components in a format must be followed; entering first minutes and then hours; PT20M1H is not a currently supported syntax.

  • The first rule states that if a vehicle is parked for less than 20 minutes, no parking fee will be assessed.
  • The second rule states that if a vehicle is parked between 20 minutes and less than 1 hour, a parking fee will be assessed equal to 2 *ceiling(duration(dtDuration)/duration('PT20M')).
  • The third rule states that if a vehicle is parked between 1 hour (inclusive) and less than 4 hours, a parking fee will be assessed equal to 6 *ceiling(duration(dtDuration)/duration('PT1H')).
  • The fourth rule states that if a vehicle is parked for four or more hours, a parking fee will be assessed equal to 30*ceiling(duration(dtDuration)/duration('P1D')).

Input data is passed in the data section: durationParked = 25 minutes (PT25M).

"durationParked": { value: "PT25M", comment: "period" }

The final result requests, durationResult, passes the input data to the decision table, tblParkingFee, and requests the finalValue, in this case, the parking fee.

"durationResult": { formula: "tblParkingFee(,,durationParked)", finalValue: [] } 

Given this input data, only one rule is successful, rule 2, which states that if the vehicle is parked 20 minutes or up to 1 hour (not inclusive) the calculated toll will be 2 *ceiling(duration(dtDuration)/duration('PT20M')) or $4.

"durationResult": { "value": 4 } 
Back to Decision Table Time Example