Embedding rule sets into schemas and processes in Web applications hosted by the public cloud

Source: Internet
Author: User
Keywords Processes Web applications public cloud hosting rule sets

In part 2nd of this series, we will describe the schemas and processes used to embed rule sets in Web applications hosted by the public cloud.

This column is intended for http://www.aliyun.com/zixun/aggregation/13387.html ">websphere operational Decision Management Developer, It is also assumed that the reader can understand the product better from the developer's perspective. See the Resources section for the knowledge you need to complete the steps outlined in this column. When I wrote this column, I used the product version for WebSphere operational Decision Management V7.5, especially rule Designer.

This article will explain how rules are effective, concise, and implicitly iterate over rows and columns in a single grid, and developers with programming backgrounds can benefit a lot from it. For higher-level developers, this article discusses how to make rule task partitioning for efficiency, how to use rules as part of a hybrid approach, and which rules are more adaptable to other constraint satisfaction issues.

Introduction

A few years ago I went to visit my grandfather, my naughty cousins like to play in the home, I thought they were going to play cricket or something, and it turned out that everyone was curled up in the house, concentrating on what was written on the paper, as if taking a nervous exam, and then I realized they were playing Sudoku. This is the first time I have come into contact with the Sudoku games that have been rage now. In order to fully introduce this game, I must admit that I am also a fan of it today.

The Sudoku game (shown in Figure 1) consists of 9 rows of 9 columns, a total of 81 cells, its goal is simple: to fill the squares with numbers between 1 and 9, so that each row and every square of the 3x3 grid contains all the numbers from 1 to 9, meaning that no duplicate numbers can be in each row, column, or block. The game has already provided some value at the beginning, and the rest of the space will be filled by the person playing the game.

Figure 1. Sudoku Games

Each space in the grid is identified by the row and column in which it resides. For example, the square is in the 9th row, column 3rd, and it is written as r9c3.

The number of classical 9x9 grid is very large, there are probably 6.67x1021, and the common problem of solving Sudoku is np-complete structure. The fun of playing Sudoku comes from finding the right answers from a number of logical steps that get you closer to the right answer. Each logical step needs to find a pattern from the squares that have already been filled. Filling in a square will limit the filling of other spaces/This forward chain method is ideal for simulations using the forward chain rule engine, such as WebSphere operational Decision Management, where the assertion of new knowledge triggers all relevant rules. Therefore, the target State will be reached from the initial state in a step-by-step manner.

Sometimes, however, people fall into a dead end when playing Sudoku, unable to move forward. At this point, they need to turn to the "Trial and Error" method, they have to guess the value of a square, and may need to go back to modify the guessing value and all other values inferred from this value. The number of guesses required is inversely proportional to the amount of knowledge in the knowledge base used by the forward chain. Whether the trial and error method is effective depends on which space the person who plays the game chooses to guess.

This method is simulated in the traditional AI when building the sample rule application. The goals of the rule application are:

uses heuristic methods commonly used by Sudoku players. Therefore, we avoid the more obscure heuristic methods of Sudoku, such as x-wings and swordfish. The trial and error method is the last choice. Provides a step-by-step tool to explain why you should fill a Sudoku box in a particular way.

Note: There are several ways to solve Sudoku, so this column does not imply that the rule-based approach is the only method or best method. For example, it is straightforward to use constraint programming notation to solve Sudoku (and use the Ibm®ilog operational Decision Manager Enterprise platform).

Rule implementation

Business rules can effectively capture the heuristic knowledge that people use to solve Sudoku. This section provides an overview of this knowledge and the corresponding business rule implementation.

9 Kinds of illuminating knowledge

After adapting Bob Hanson's Sudoku Assistant, we have defined 9 heuristic methods that can be implemented with business rules to solve Sudoku puzzles. In addition to rows, columns, and squares, these heuristics are called candidate values, which are the possible values that can be populated into a square. Therefore, candidate K refers to the possible value of a square k,k a number between 1 and 9.

Heuristic Method 1: Exclusion heuristic

If the value of a square is K, the value of the other squares in the same row, the same column, or the same block of squares must not be k.

Heuristic Method 2: Dominant unique solution (naked single) heuristic

If the candidate value is feasible in a square and no other candidate can be filled in this square, then the square must be K.

Heuristic Method 3: Implicit unique solution (hidden single) heuristic

If the candidate value K can only be filled in a square in a row, column, or block of squares, the value of the square must be K.

Heuristic Method 4: Line/row lock candidate value heuristic

If a candidate is fit to fill the intersection of a row/column and a block of squares, but it does not fit elsewhere in the row/column, it is not suitable to fill the other position of the block.

Heuristic Method 5: Heuristic for locking candidate values in square blocks

If a candidate is fit to fill the intersection of a row/column and a block of squares, but not the other position within the block, it is not suitable for filling in the other position of the row/column.

Heuristic Method 6: The illumination of the dominant number (naked pair)

If two candidates fit into the two squares of a given row/column, and no other candidate is fit to fill in the two squares, the squares are not suitable for filling in the other positions of the row/row.

Heuristic Method 7: The inspiration of the recessive number (hidden pair)

If the two candidates fit into the two squares of a given row/column, and the squares are not fit to fill the other positions of the row/row, no other candidate is fit to fill the two squares.

Heuristic Method 8: The illumination of dominant ternary group (naked Trio)

If the three candidates fit into the three squares of a block, and no other candidate is fit to fill the three squares, then the three squares are not suitable for filling in the other positions of the square blocks.

Heuristic Method 9: The inspiration of recessive ternary group (hidden trio)

If the three candidates fit into the three squares of a block, and the three squares are not fit to fill the other positions of the block, then no other candidate is fit to fill the three squares.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.