Expert systems for the analytical laboratory - American Chemical Society

amine two different typesof expert sys- tems and consider how they could be used in the analytical laboratory. We will also discuss some of the realit...
0 downloads 0 Views 7MB Size
r

Systems for the Analytical laboratory Allan R. de Monchy, Alan R. Foster, and Johnny R. Arrelteig Shell Development Company Westhollow Research Center P.O. Box 1380 Houston,TX 77001

Lan Le and Stanley N. Deming Department of Chemistry University 01 Houston Houston, TX 77004 For the past several years, analytical chemists have been exploring the potential uses of expert systems in analytical chemistry ( I ) . In some cases the results have been excellent (2-4) hut in others the results have been discouraging. Some of the discouragement may have come from an incomplete understanding of what expert systems are and why they cannot always he applied successfully. An expert system is a computer program that emulates the prohlemsolving process of human experts (5). Because there are many such computer programs, there are many types of expert systems. The differences among these systems are attributable to the different ways human knowledge is represented and manipulated in the programs. Along with natural language processing and robotics, the field of expert systems is generally considered to lie within the larger artificial intelligence (AI) domain (6). In this A K INTERFACE, we will examine two different types of expert systems and consider how they could be used in the analytical laboratory. We will also discuss some of the realities of developing and using expert systems. Rule-based expert systems “Rules provide a formal way of repri senting recommendations, directives, or strategies; they are often appropriate when the domain knowledge results from empirical associations developed 0003-2700/88/A360-1355/$01.50/0 @ 1988 American Chemical Society

1

I

through years of experience solving problems in au area,” according to Waterman (7).Rules are usually expressed as IF-THEN-ELSE statements. The following are examples of simple rules. (1) IF the sample is liquid THEN pipet ELSE weigh. (2) IF the seal on the samnle container is intact THEN continue with analvsis ELSE reject the sample. When the IF portion of a rule (the antecedent) is found to be logically true, the THEN portion of the rule (the consequent) is considered to be logically true or, if the consequent is an action, the specified action is carried out. When this happens, the rule is said to “execute” or, loosely, to “fire.” In rules 1 and 2 above, the antecedents represent facts and the conse-

quents represent actions. Rules can also be used to “create” new facts. For example, (3) IF the seal on the sample container is properly applied AND there is no evidence of tampering AND the seal is not broken THEN the seal on the sample container is intact. Clearly, rules 2 and 3 are now related and make up a simple inference chain, shown in Figure 1. Inference chains can be traversed hy forward chaining (a “what if” approach) or by backward chaining (a “can we” approach). In forward chaining we would look at established facts and see where those facts lead in the logical structure of the inference chain. For example, “what if” it were estahlished that “the seal on the sample container is properly applied”

A7C INTERFAZE

-

Flaure 1. A SimDle inference chain Digital logic Symbols represent (clockwise from left) multi-input AND (IF ail inputs are true THEN the output is true), AMPLIFICATION (IF the input is true THEN the output is true). and NOT (IF the input is false THEN the Output is true).

ANALYTICAL CHEMISTRY, VOL. 60, NO. 23. DECEMBER 1, 1988 * 1355A

AND “there is no evidence of tampering” AND “the seal is not broken”? We could then conclude that “the seal on the sample container is intact” and, further, that we should “continue with analysis.” In backward chaining we would choose an action that might be taken and see if there are enough facts to justify that action. For example, “Can we reject the sample?” We could reject the sample if we could establish the fact that the seal on the sample container is not intact. If that fact were not yet available to us, we would have to look back in the inference chain to establish the fact that “the seal on the sample container is not properly applied,” OR establish the fact that “there is evidence of tampering” OR establish the fact that “the seal is broken.” Few people would want to keep track of the structure of an inference chain as more rules are added or to search forward or backward in an inference chain. These are not fun tasks, and they are better suited to a computer than to a human. Computer programs (often written in LISP or PROLOG) that carry out these tasks are called inference engines and are at the heart of moat rule-based expert system.

Once developed, the inference engine becomes a fairly rigid set of computer code, oasified but constantly useful. The knowledge base, by contrast, might always be changing as new, improved rules are added and (ideally) old, inadequate rules are deleted. Useful expert systems programs also need a third section of computer code that allows them to interface with the human user, with available databases, and/or with external specialized computer programs (Figure 2a). Very early in the evolution of the expert systems field, researchers realized that if they removed the knowledge base from this type of expert system they would be left with an empty shell containing a well-developed inference engine and a well-developed user interface (Figure 2b). Of course, this expert system shell couldn’t actually do any. thing because it wouldn’t have any rules by which to operate. But researchers could then add a different knowledge base to the existing shell and instantly have a new expert system (Figure 2c). Rule-based systems have their place in analytical chemistry, especially for areas that have straightforward, welldefined logic structures and clear TRUE-FALSE conditions. One example of this type of application is robotic systems control. Another example might involve decisions about legislative approval of analytical laboratories based on a fixed but complicated set of criteria. Rule-based expert system shells have been used as rule-building tools for classification purposes in chemometrics (8). As appealing as these systems are, the application of rule-based expert systems in analytical chemistry is not always straightforward. Some novice expert system builders suppose that if one expert is good, then many individual experts are better, and it is not necessary to funnel knowledge through one central “knowledge engineer.”

They believe that many human “experts” should be encouraged to contribute individually to the overall knowledge base. This approach potentially leads to serious problems. Suppose a second expert (or even the first expert) later adds to the knowledge base shown in Figure 1what is believed to be a valid, simple rule to produce the inference chain shown in Figure 3. (4) 1F the seal on the sample container is properly applied THEN continue with analysis. This makes the additional facta “there is no evidence of tampering” and “the seal is not broken” unnecessary for reaching the decision if the first fact is true. This is a benign example, but it illustrates the way the logical structure of the inference chain in rule-based systems quickly becomes complex. It is not always easy to detect and remove less benign logical contradictions, redundancies, and inconsistencies. A second difficulty with rule-based expert systems becomes evident when the conditions are not clearly TRUE or clearly FALSE. Things get “iffy” then. Is there really no evidence of tampering with the seal on this sample? “What about this mark here? It looks like someone gained access to this sample!” “No, I don’t think so. It looks to me like it got scratched by the sample holder.” “Well, I don’t thiik so. It looks like tampering to me.” “You’re wrong.” “Oh yeah? Sez who?” How would a human expert resolve this dilemma? How can an expert system resolve this dilemma? Some expert systems allow users to assign probabilities or confidence to the answers and propagate them down the inference chain into the final result. It is not always clear, however, how multiple probabilities or confidence should he interpreted when a given goal or action could result from more than one path

Figure 2. The concept of an expert sys-

tem shell. $)methae wcl!aM o f a n n p u t a ~ mat make up an sxpn system. (b)ma empty &-all aftsr ramal of krmwlbase, Md (c) m wmrl ~stm ansr addltlon of a d l M n i krovrbdgn base.

1356A

Flgurc .

IIIW

complicated inferc

ANALYTICAL CHEMISTRY. VOL. 60. NO. 23, DECEMBER 1, 1988

..:hain.

and FUME HOODS

0

0

II

L.

I

Engineered for your Special requirements Approved budget Exclusive use of nickel + lead-coated sheet steel with baked-on enamel finish to provide corrosion and acid resistance for the utmost in performance, durability and value. Custom detailing includes concealed hinges, double panel insulated doors and drawers with removable panels for easy cleaning and decontamination. Call us to discuss your require-

DURALA

c

Phone 718-649-9600 FAX 718-649-503 -SINCE 1962

-

CIRCLE 32 ON READER SERVICE CARD

Besident, 1989 ~itts6urghConference and the Conference Committee FamiCu at the cele6ration ofthe 40thAnniuersary ofthe

Titts6urgh Conference & Exposition Georgia World Congress Center Atlbnta, Georgia March 6-10,1989 Anniversary activities m'ffinch& 130 Symposia andan eapandede~hi6itionwith over 850suppliers.

me Plltsburgh Conference. 12 Federal Drive, SuWe 322. Pithburgh, PA U.S.A (412) 7%-7110 CIRCLE 125 ON READER SERVICE CARD

ANALYTICAL CHEMISTRY. VOL. 60, NO. 23, DECEMBER 1, 1988

195TA

through an inference chain. Probabilities or confidence or possibilities can be used effectively for some of the data retrieval aspects of rulebased expert systems in analytical chemistry. The followingfuzzy logic (9) example is parallel to one given by Zadeh (IO). Suppose we want to search a database for samples with what we consider to be a high magnesium concentration of greater than or equal to 1000 ppm AND what we consider to he a high calcium concentration of greater than or equal to 15 ppm. Table I shows the results provided by a crisp, or ordinary, logical search of the database: Only sample F satisfies our search criteria. Suppose we redefine what we mean by high magnesium and calcium concentrations by the fuzzy-set memhership functions (11) shown in Figure 4. If the magnesium concentration is 600 ppm or less, we might reasonably say that it has no high character and assign the membership function a value of 0.00. If the magnesium concentration is 1150 ppm or greater, we might say that it has completely high character and assign the membership function a value of 1.00.In this example, membership function values for magnesium concentrations between 600 and 1150 ppm are in simple linear proportion between 0.00 and 1.00.A similar membership function is shown for calcium: Concentrations of 12 ppm or less are considered to have no high character; concentrations of 18 ppm or greater are considered to have full high character. If we use the fuzzy logic probabilityAND function (p-AND)-the product of the membership functions in this case (12)-we achieve the results shown in Table 11. The higher the value for the p-AND function, the closer the sample comes t o simultaneously achieving our requirements of high magnesium concentration and high calcium concentration as defined by the membership functions. Note that sample E now has the greatest value for the p-AND.

Table 1. Crisp logic resuns for samples containing high magnesium and hmh calcium concentrations Sample A B

500 600 800 850 900 1000 1100 1200 1300 1400 1500

C D E F

G

H I J K

Crlsp lcglc resuns Hlgh Ca Hlgh Mg and High Ca

Ca (ppm)

Hlgh Mg

7 14 17 12 18 15 14 13 13 6 12

0

0

0

0

0 1 0 1 1

0 0

0

0 0

0 0 0 1 1 1 1 1 1

0 0 1

0 0 0

0

0

0

0

-

Flgure 4. Membership functions for (a) high magnesium and (b)calcium concentrations.

Table II. Fuzzy logic results for samples containing hiah magnesium and high calcium concentrations

I

Sample

Mg (ppm)

Ca (ppm)

Hlgh Mg

Fuzzy lcgic results Hlgh Ca High Mg pAND High Ca

I ‘

I A 8 C D E

i

< 1358A

Decision analysis expert systems

500 600 800 850

7 14 17 18 12

900

1000 1100 30 10 1500

15 13 14 13 6 12

0

0 0.36 0.46 0.55 0.73 0.91 1.00 1.00 1 .OD 1 .oo

0 0.33 0.83 0 1.00 0.50 0.33 0.17 0.17 0 0

0

0 0.30 0 0.55 0.36 0.30 0.17 0.17 0

0

ANALYTICAL CHEMISTRY, VOL. 60, NO. 23, DECEMBER 1, 1988

Multiple-attribute multiple-goal decision analysis appears to be a useful technique for constructing expert systems that must make use of indefinite, incomplete information (4). Fuzzy-set theory and fuzzy logic are especially useful in this context. An example of a multiple-attribute multiple-goal decision analysis expert system might be one used for the selection of an appropriate method of elemental analysis. A two-dimensional expandable array is created in which the columns correspond to the multiple goals (methods of elemental analysis in this example) and the rows correspond to attributes (information that will help in the selec-

constructed in this way are relatively easy to maintain. Addition or deletion of a goal or attribute does not diarupt any inference chain.

Table ill. Example of a multiple-attribute, multiple-goal decision analysis matrix for selecting a method of elemental analysis Goal Anrlbute

Samples per week 200 Equipment budget $40,000 Elements per sample 1 2-3

>3

Tnration

Atomk absorption rpectrcscopy

Inductively coupled plasma spectr08c0py

1.00 0.50

0.05

0.00

0.80

0.01 0.50 0.95

1.00

-1.00 1.oo 1.oo

1.00 1.oo

1.00

0.30 0.10

tion of the goals), as shown in Table 111. Information about the attributes is obtained from a series of questions posed to the user (or from an existing information base). The elements of the array are fuzzy numbers that are used to store a human expert’s indication of the importance of an attribute toward the selection of a goal (positive fuzzy values) or elimination of a goal (negative fuzzy values). Note in Table 111 that although the attributes have been subdivided into crisply defined categories, membership functions can be used to define a smooth relationship between the expert’s fuzzy numbers and, say, the number of samples per week. Evidence in favor of a goal (ranging from 0.00 to 1.00) or against a goal (ranging from 0.00 to -1.00) can be accumulated using a fuzzy logic probability-OR @-OR) function. For a given possible goal, if A is the (positive) fuzzy value associated with one attribute and B is the (positive) fuzzy value for a second attribute, then

P=A+B-AX (1)B can be used to represent the accumulated evidence in favor of that goal. An equivalent way of calculating the p-OR function is useful when evidence from more than two goals is being combined

‘P = 1- (1- A)(1 - B)(1- C). . . (2)

Evidence against a goal, based on negative fuzzy values, is accumulated separately as P.The values can’be combined by first converting each to a positive value, calculating as in Equation 2, and then converting the result to a negative value. Note that the p-OR function as defined above will be “clamped” a t unity

0.75

1.00 0.60 0.45

-1.00

-1.00 1.oo 0.10 0.25 1.00

by a single attribute of 1.00. Many workers believe that in some situations only one piece of information can make a goal completely undesirable, and this clamping feature is appropriate for evidence against a goal (e.g., an equipment budget of