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.
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:
A mixed border is composed of several different types of plants which each serve a specific purposed. When desiging a bed from scratch, start first with plants that are (or will be) medium height which acts as a focal point. Next add some evergreen shrubs to accent it. Both of these types of plants will add structure to the bed. I call these backbone plants in my expert system. Next add some perennials (these are plants that once planted will come back year after year, but typically die back to the ground in winter, and don't get very big). They will add color and variety, and are usually more glamorous than the backbone plants. Groundcovers act to tie everything together like a carpet and help keep out weeds. Vines are an easy way to add height to a garden to keep it from looking too horizontal. Bulbs are another glamorous plant. They tend to send out spectacular flowers but die back after that. Because of this they can usually be planted nearly in the same space as another plant. Lastly, many gardeners love annuals (plants that live for only one year, however, they make up for their short lives by blooming profusely). They can add alot of color, but they tend to require attention in the form of constant deadheading (removing old blossoms), and planting and digging up every year.
A mixed border should have most of these things, and it should have them in a good balance. While a human expert can look at a bed and say "needs more structure", I had to quantify more or less for this expert system by coming up with a ratio. This is the only guideline I implemented at this time. However, it should be relatively easy (since the hard part was figuring out how to work in a rule-based environment vs. a traditional procedural approach) to add the other rules to do the rest.
A good rule of thumb for gardens is to make it interesting for as long as possible. Traditionally, gardens look pretty sad in winter in most of the US and will have a spectacular display for about 2 weeks in the spring or summer, however, that doesn't have to be the case. By choosing plants that characteristically look good in multiple seasons, particularly in the winter (evergreens, colorful trunks and bark, seed heads, etc.) you may not have that dynamic display in spring but it will still look respectable and interesting all year.
A fundamental element of garden design is plant placement. By arranging plants in certain ways you can create wonderful effects. A basic rule is to use contrasting and repeating textures. Place low rounded plants next to spiky ones, or airy ones next to substantial ones.
The same idea as texture holds true for color, both of foliage and leaves. Dark green leaves look nice next to golden-green ones. Or color can be a theme, for example, white and cream flowers and silver foliage.
Plants to be selected for a garden should fit the climate. There are all sorts of ways to measure this. Charteristics to look for include typical freezing tempatures, how hot in the summer, amount of sun/shade, amount of water, how fast the soil drains (sandy or boggy).
For easiest maintainance plants should be disease and pest resistance, not too messy (dropping leaves that need to be raked), or aggressive (so that your always weeding) etc. Also, some gardeners are willing to take the time to try new plants that may be finiky, while others want the tried and true.
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.
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.
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.