Expert Systems

Lab 1: A Rule Based Garden Design Expert System


Introduction

For this lab I choose to create an expert system that helps a user design a garden bed. There are many types of garden styles, and opinions on what makes a garden asthetically appealing, lots of different uses for gardens, and all kinds of gardeners with different experiences who are working with different kinds of environments. All these variables don't even begin to cover the complexity in working with a palette of plants that easily numbers in the thousands (if not tens of thousands) just for common specimens.

I used myself as an expert for this system, and so was able to narrow down the focus to make this a manageable project by selecting areas that I was interested in. The area that I choose to focus on was that of a garden bed and its composition. My expert system isn't strictly a planner; it won't come up with a garden bed by scratch. Instead a user enters plants that they have in an existing bed, and the system will return a list of plants that will help improve the composition of the bed. Composition is defined here as the structure of the bed, where every plant serves a certain purpose, and the bed has the right proportion of plants serving that purpose, achieving a balance. There are other factors besides composition that help create a good bed. I believe that my design is scaleable so that if an expert wanted a more robust system, more rules could be added to create that principle of garden design. It was implemented in CLIPS which uses forward-chaining as the control mechanism. My system's task is to design, however, it has some aspects of classification as well in order to design.


Background and References

Garden Design Background Information

Gardens can serve many different purposes from a casual kitchen herb garden, based upon functionality and casualness, to historical formal knot gardens, designed to keep hoards of common people busy and to impress other nobles with their grandeur. Each funtion and style has its own criteria for what is considered beautiful. Nowadays most people are intereseted in two types of gardens: the purely functional vegetable gardens or easy to care for yet beautiful landscapes. You don't need to be an expert to plant a vegetable garden, just plant what you want to eat of vegetables that can be grown in your area. But there are too many choices and options when designing landscapes.

One type of garden design is to use mixed borders. These borders (or beds or large clusters of plants) are composed of many different types of plants with the idea being that its easier to care for many different species than a homogenious bed. I believe that most people even if they aren't die-hard horticulturists yet still want to garden could benefit from an expert system that helped them create this type of bed.

There are still lots of guidelines to keep in mind when designing a good border Here are some of the majors ones:

This list is by no means exhaustive but it gives a good idea of all the factors that needs to be considered when planning a garden. Some of my references for gardening information included seed catalogs, _Horticulture_ and _Fine Gardening_ magazines, _The Four-Season Landscape_ and _The Weekend Gardener_ both by Susan Roth, my own experiences and my mother who taught me almost everything.

Using CLIPS

While I haven't done an exhaustive search, I looked into some of the different rule based shells, and at expert systems in general and couldn't find any other garden design tools. I knew that I wanted a tool that could assist in gardening. I ended up choosing CLIPS because it seemed to have the most support. There was also an applet written in Java that was free. It was based upon the CLIPS syntax, but the developers recommended using CLIPS first and then porting because it had more built in debugging, etc.

CLIPS uses forward-chaining as control. When I first started thinking about the problems I assumed forward-chaining would be best because of the sheer number of plants out there and the number of variables makes this problems very data driven. However, my next problem was how to deal with representing thousands of plants in rules. For example, the user wants the expert system to suggest a plant to add to the garden, but the expert system needs to consider hundreds of plants to find a good match. I started thinking about the problem in a different manner. What if the user entered a list of plants they were considering adding, and the expert system would then have to select from those plants. The control structure then needed would be backward chaining because its goal driven. But I still thought CLIPS was the system I wanted (always nice to be able to run on more than one system as well). My eventual solution was a compromise. Once I started looking into CLIPs I realized I was really going to need to pair down my problem. The solution I came up with was to have a "list" of plants that the system knows about. The user will enter the plants that they already have in their bed with the stipulation that these plants are in the list. The expert system will then suggest other plants that it knows about. In this manner and with a little data entry the plan is a lot more manageable.

Some other sources of infomation that have been of help to me, include _User's Guide_ and _Basic Programming Guide_ both standard documentation for CLIPS. I also used some sample programs from the CMU AI Repository This samples were supposedly projects for an expert system course. Nematode.clp was a classification example which helped me get started on I/O. Cam.clp solves the missionary and cannibal problem and was helpful as well.


Implementation

Algorithm

The algorithm that this expert system uses is straight forward. It comes with 50 plants built in. Knowledge about the plants fits into a predefined template. In this way if I decide I want to add another attribute to the plant, it should be relatively simple to add a new field to the fact list. Currently the plants have a name and a usage (one of 6 types: backbone, perennial, annual, vine, bulb, and groundcover) Some plants also have a season value where the value is one or more of the following depending on what season it looks good in: fall winter spring summer.

The program starts by displaying a list of plants that the system has knowledge of. It then prompts the user for a list of plants that they already have in a garden bed. This list is stored as symbols in a rule. It will error check to make sure that these plants are ones that it knows about (i.e., its in the pregenerated list). It will then analyze the bed by looking at each individual plant and that plants usage. It counts up the number of backbone plants, perennials, annuals, vines, etc. It then determines what percentage each type makes up. It compares these values to the ideal value for that type. If it falls below the ideal a new rule is asserted stating that that type is needed. The next phase of the system looks at each of the needed types and finds one plant in the existing plant list to suggest to the user, and outputs the results.

Code

To run this code, from CLIPS command line type

CLIPS> (batch saved-file-name)

CLIPS> (reset)

CLIPS> (run)

It only runs once so you will need to reset and run if you want to do it more than once.

Sample Run


Limitations and Future Improvements

Sample Run of Error Situation

Limitations

Future Directions