Monday, March 5, 2012

Dynamics AX 2012 Optimization – Product Builder

Dynamics AX 2012 Optimization – Product Builder

Purpose: The purpose of this document is to illustrate how Product Builder can be used in Dynamics AX 2012 to configure products. In this document the emphasis will be put on how to build rules base or constraints base for particular business scenario to ensure that valid combination of modeling variables values is selected.

Challenge: In Dynamics AX 2012 new Product Configurator was introduced which will ultimately replace Product Builder in the next release. Product Configurator is a new Configurator solution which leverages Solver Foundation engine. One of the reasons to introduce Product Configurator was to eliminate a need for Developer license in order to use Configurator capabilities of Dynamics AX 2012, so functional users will be able to use Configurator efficiently. The challenge is to understand what is the difference between Product Builder and Product Configurator in the light of real world rules-based and constraint-based configuration scenarios.

Solution: Example of start-to-end Car configuration using Product Builder in Dynamics AX 2012 will be described in this document. We start with definition of the problem and its formalization, and then continue with translating this knowledge into Dynamics AX 2012 terms and setting up the system appropriately, and end with working solution and the result.

Configuration Model:

Modeling Variable Name

Modeling Variable Value(s)

Type

"Sport Car", "Family Car"

Package

"Deluxe", "Luxury", "Standard"

Frame

"Convertible", "Hatchback", "Sedan"

Engine

"A", "B"

Transmission

"Manual", "HalfAutomatic", "Automatic"

In this example Car is configured using 5 modeling variables such as Type, Package, Frame, Engine and Transmission. Each modeling variable has a set of possible values as depicted in the table above. The task is to build rules base or constraints base for Car configuration scenario to ensure that valid combination of modeling variables values is selected.

Configuration Model Diagram:

image

In the configuration process client initially is supposed to provide input regarding Type of Car which he/she needs and what Package will have to be included. After that other Car specifications will be determined such as Frame, Engine and Transmission based on Configuration rules.

For example, Client says: "I need Deluxe Sport Car" and the system will have to ensure that valid combination of Car specifications is selected as the result of configuration.

On the Configuration Model Diagram you can see that certain modeling variables drive the selection of other modeling variables. For example, Type of Car is used to determine Transmission. Please see the full list of Configuration rules which were composed with knowledge of business domain (Automotive industry in this example).

Configuration Rules:

Rule 1: IF Package = "Deluxe" AND Frame = "Convertible" THEN Engine = "A"

Rule 2: IF Package = "Deluxe" AND Frame = "Hatchback" THEN Engine = "B"

Rule 3: IF Package = "Standard" AND Frame = "Convertible" THEN Engine = "A"

Rule 4: IF Engine = "A" THEN Transmission = "Manual"

Rule 5: IF Engine = "B" THEN Transmission = "Automatic"

Rule 6: IF Type = "Sport Car" THEN Frame = "Convertible"

Rule 7: IF Type = "Family Car" THEN Frame = "Sedan"

Rule 8: IF Type = "Sport Car" THEN Transmission = "Manual"

Rules 1, 2 and 3 use Package and Frame to determine Engine. Rules 4 and 5 make decision about Transmission based on Engine. Rules 6 and 7 decide on Frame taking into account Type. And Rule 8 uses Type to determine Transmission.

Please note that certain modeling variable selection may be a result of different combinations of other modeling variables selections which is the case in complex business domains (such as Automotive industry).

Next step: We will define Product Model, Modeling Variables and Outcomes, Product Model Modeling Variables and design User Interface for Product Model (Groupings) in Dynamics AX 2012

Product Model

Modeling Variables

Modeling Variable Name

Base Type

Type

Enumerated Text

Package

Enumerated Text

Frame

Enumerated Text

Engine

Enumerated Text

Transmission

Enumerated Text

Modeling Variable = "Type"

Modeling Variable = "Type" -> Outcomes

Modeling Variable = "Package"

Modeling Variable = "Package" -> Outcomes

Modeling Variable = "Frame"

Modeling Variable = "Frame" -> Outcomes

Modeling Variable = "Engine"

Modeling Variable = "Engine" -> Outcomes

Modeling Variable = "Transmission"

Modeling Variable = "Transmission" -> Outcomes

Product Model Modeling Variables

User interface

Variable Group

Variable Group Description

Preference

Preferences

Specificat

Specifications

To better organize configuration process all modeling variables will be divided into 2 groups: Preferences and Specifications. Preferences will represent client's initial requirements regarding Type of Car and Package to be included. Specifications group will represent physical characteristics of Car such as Frame, Engine and Transmission which will be defined based on initial client's requirements.

Next step: We will implement 2 options to illustrate Rules-based and Constraints-based approach in order to structure knowledge base. Option 1 implements Rules-based approach and Option 2 implements Constraints-based approach.

Option 1: Local Rules (Rules base)

Using Rules-based approach all Rules can be represented as Local Rules in Dynamics AX 2012. Please see all Local Rules in relation to the original rule below

Rule 1: IF Package = "Deluxe" AND Frame = "Convertible" THEN Engine = "A"

Rule 2: IF Package = "Deluxe" AND Frame = "Hatchback" THEN Engine = "B"

Rule 3: IF Package = "Standard" AND Frame = "Convertible" THEN Engine = "A"

Rule 4: IF Engine = "A" THEN Transmission = "Manual"

Rule 5: IF Engine = "B" THEN Transmission = "Automatic"

Rule 6: IF Type = "Sport Car" THEN Frame = "Convertible"

Rule 7: IF Type = "Family Car" THEN Frame = "Sedan"

Rule 8: IF Type = "Sport Car" THEN Transmission = "Manual"

Option 1: Result

Please note that when you just open Configuration screen and you don't have any particular selections for modeling variables yet, absolutely all selections for all modeling variables will be available

Type

Package

Frame

Engine

Transmission

This is because the system will start evaluating rules after you will make particular selections of modeling variables.

And even when you specify client's requirements "Deluxe Sport Car" the system will still show you all selections for all modeling variables.

Please note that after you have selected Type = "Sport Car" and Package = "Deluxe" the system will not display any errors for you as soon as there is no rule which is violated at the moment

Type

Package

Frame

Engine

Transmission

However when you specify Engine = "B" and press "Ok" Rule 8 will be violated

As the result you will see the following error after you press "Ok"

The error pops up after you press "Ok" because there is no Rule that defines explicit relationship between Type -> Engine, Package -> Engine or {Type, Package} -> Engine. So when you press "Ok" having Engine = "B", Frame = "" (empty) and Transmission = "" (empty) then Rule 8 fails because of Type = "Sport Car" and Transmission = "" (empty)

Ultimately after you specify Type = "SportCar", Package = "Deluxe", Frame = "Convertible", Engine = "A" and Transmission = "Manual" you will be able to successfully complete configuration process

Type

Package

Frame

Engine

Transmission

After that in the case if you specify Transmission = "Automatic" by mistake when Frame = "Convertible" and Engine = "A"

Then you will see the following error right away

Rule 8 fails right away when you specify Transmission = "Automatic" because selections for Frame (= "Convertible") and Engine (="A") are not "" (empty) at this moment

You can download DAT/DEF file for Rules-based configuration (PB-AlexCar-Rules) here: https://skydrive.live.com/redir.aspx?cid=9c660ef56a3ba3f7&resid=9C660EF56A3BA3F7!111&parid=9C660EF56A3BA3F7!101&authkey=!ACa1ueZkALwWr1I

Option 2: Table Constraints

In order to use Constraints-based approach we will have to represent Rules differently by grouping them into 4 groups. Rules 1, 2 and 3 will fall into 1st group which represents all valid combinations of Package, Frame and Engine. Rules 4 and 5 will form 2nd group which represents all valid combinations of Engine and Transmission. Rules 6 and 7 will be basis for 3rd group which represents all valid combinations of Type and Frame. And Rule 8 will represent 4th group with the only one valid combination of Type and Transmission defined at the moment.

Group 1: Package-Frame-Engine

Rule 1: IF Package = "Deluxe" AND Frame = "Convertible" THEN Engine = "A"

Rule 2: IF Package = "Deluxe" AND Frame = "Hatchback" THEN Engine = "B"

Rule 3: IF Package = "Standard" AND Frame = "Convertible" THEN Engine = "A"

Package

Frame

Engine

Deluxe

Convertible

A

Deluxe

Hatchback

B

Standard

Convertible

A

Please note that I substituted Rules 1, 2 and 3 with Group 1 Table representing all valid combinations of Package-Frame-Engine

Group 2: Engine-Transmission

Rule 4: IF Engine = "A" THEN Transmission = "Manual"

Rule 5: IF Engine = "B" THEN Transmission = "Automatic"

Engine

Transmission

A

Manual

B

Automatic

Please note that I substituted Rules 4 and 5 with Group 2 Table representing all valid combinations of Engine-Transmission

Group 3: Type-Frame

Rule 6: IF Type = "Sport Car" THEN Frame = "Convertible"

Rule 7: IF Type = "Family Car" THEN Frame = "Sedan"

Type

Frame

Sport Car

Convertible

Family Car

Sedan

Please note that I substituted Rules 6 and 7 with Group 3 Table representing all valid combinations of Type-Frame

Group 4: Type-Transmission

Rule 8: IF Type = "Sport Car" THEN Transmission = "Manual"

Type

Transmission

Sport Car

Manual

Please note that I substituted Rule 8 with Group 4 Table representing valid combination of Type-Transmission

The difference between Rules-based approach and Constraints-based approach is that instead of expressing the rules in form of conditions and conclusions (Rules-based approach) I'm expressing relations between modeling variables and valid modeling variables value combinations (Constraints-based approach).

Using Constraints-based approach all Rules can be represented as Table constraints in Dynamics AX 2012. However before I will be able to define Table constraints I will have to do some X++ (Data model) development and physically create Tables in AOT which correspond to appropriate groups.

Table Name

Table Description

AlexPackageFrameEngine

Group 1: Package-Frame-Engine

AlexEngineTransmission

Group 2: Engine-Transmission

AlexTypeFrame

Group 3: Type-Frame

AlexTypeTransmission

Group 4: Type-Transmission

After I created physical Tables in AOT representing different groups I will have to enter data, by other words valid combinations of modeling variables. Please note that appropriate EDTs will have to be created in advance before you add fields to tables.

AlexTypeTransmission

AlexTypeFrame

AlexPackageFrameEngine

AlexEngineTransmission

Please see all Table constraints in relation to the original rules group below

Group 2: Engine-Transmission

Table Constraint = "EngineTransmission"

Group 3: Type-Frame

Table Constraint = "TypeFrame"

Group 1: Package-Frame-Engine

Table Constraint = "PackageFrameEngine"

Please note that when I'm trying to add "AlexEngine" modeling variable in "PackageFrameEngine" Table Constraint I have an error "The record already exists". This is because the system is trying to create "AlexEngine"modeling variable automatically during Table constraint and "AlexEngine" modeling variable has been already created for "EngineTransmission" Table Constraint introduced earlier.

In order to resolve this I created AlexAll table which will contain all valid combinations of 5 modeling variables to avoid modeling variables overlap between different Table Constraints

Please note that in this example each group has overlap with another one by 1 modeling variable. For example, "Engine-Transmission" group has an overlap with "Package-Frame-Engine" group by "Engine" modeling variable. In general case though it would be okay to have more than one "combined" Table Constraint as long as there is no overlap by modeling variables.

Please also note that you will have to delete all modeling variables from Product Model before adding Table Constraints because Table Constraint will try to add required modeling variables automatically. In this example I created modeling variables with different names prefixed with "Alex" to be able to add Table Constraints without deleting originally created modeling variables without "Alex" prefix.

Finally I entered all valid combinations of modeling variables into AlexAll table.

AlexAll

In order to define all valid combination of 5 modeling variables based on existing groups the following pseudo-code logic can be used

Foreach (Package)

Foreach (Frame)

Foreach (Engine)

Foreach (Transmission)

If (EXISTS Table1 WHERE Package = Package, Frame = Frame, Engine = Engine AND

EXISTS Table2 WHERE Engine = Engine, Transmission = Transmission)

INSERT Package, Frame, Engine, Transmission INTO GroupTable1-2

This pseudo-code snippet creates "combined" GroupTable1-2 group ("Package-Frame-Engine-Transmission") based on "Package-Frame-Engine" group and "Engine-Transmission" group. Alternatively you can use the following pseudo-code snippet to do the same

Foreach (Table1)

Foreach (Table2)

If (Engine1 = Engine2)

INSERT Package1, Frame1, Engine1, Transmission2 INTO GroupTable1-2

Ultimately you will have to "combine" all groups together in similar fashion to obtain 1 "super" group.

After we created and filled in AlexAll table with data we can create Table Constraint based on AlexAll table

Table Constraint – "All"

Modeling Variables

Modeling Variable Name

Base Type

AlexType

Table

AlexPackage

Table

AlexFrame

Table

AlexEngine

Table

AlexTransmission

Table

User Interface

Variable Group

Variable Group Description

Selections

Selections

As soon as we use the only 1 Table Constraint we will have to change our approach to User Interface. That's why I defined new Variable group "Selections" which will contain all modeling variables selections.

Resulting Product Model will now look like the following

Please note that the system automatically created Product Model modeling variables when Table Constraint was added to Product Model

Option 2: Result

Please note that when you just open Configuration screen and you don't have any particular selections for modeling variables yet, only certain selections for all modeling variables will be available

Type

Package

Frame

Engine

Transmission

This is because the system takes into account all valid combinations of 5 modeling variables defined in AlexAll table (Table Constraint "All"). They are {Type = "Sport Car", Package = "Deluxe", Frame = "Convertible", Engine = "A", Transmission = "Manual"} and {Type = "Sport Car", Package = "Standard", Frame = "Convertible", Engine = "A", Transmission = "Manual"}.

Now when you specify client's requirements "Deluxe Sport Car" along with other allowed Specifications final result will look like the following

Please note that the system will display particular selection for modeling variable if this value does exist in Table Constraint table. For example, there are 2 records in AlexAll table where Package = "Deluxe" and Package = "Standard" correspondingly. That's why the system provides 2 selections for modeling variable "Package".

Type

Package

Frame

Engine

Transmission

You can download DAT/DEF file for Constraints-based configuration (PB-AlexCar-Constraints) here: https://skydrive.live.com/redir.aspx?cid=9c660ef56a3ba3f7&resid=9C660EF56A3BA3F7!111&parid=9C660EF56A3BA3F7!101&authkey=!ACa1ueZkALwWr1I

Summary: Product Builder is a flexible solution which can be used in Dynamics AX 2012 for configuring products. Product Builder allows you to implement Rules-based approach and Constraints-based approach for Product Models. However it is recommended to use new Product Configurator in Dynamics AX 2012 to configure products and services with more ease and efficiency. Please note that there is no need to have Developer license if you use Product Configurator. In similar walkthrough I will also explain how Product Configurator in Dynamics AX 2012 allows you to implement Rules-based approach and Constraints-based approach for Product Configuration Models.

Author: Alex Anikiev, PhD, MCP

Tags: Dynamics ERP, Dynamics AX 2012, Product Builder, Rules-based Configurator, Constraints-based Configurator.

Note: This document is intended for information purposes only, presented as it is with no warranties from the author. This document may be updated with more content to better outline the concepts and describe the examples.

Reference: "Constraint-based knowledge representation for configuration systems" by Boi Faltings and Rainer Weigel

No comments:

Post a Comment