foundations of computational agents
Constraint satisfaction problems are described in terms of variables and possible worlds. A possible world is a possible way the world (the real world or some imaginary world) could be.
Possible worlds are described by algebraic variables. An algebraic variable is a symbol used to denote features of possible worlds. For this chapter, we refer to an algebraic variable simply as a variable. Algebraic variables are written starting with an upper-case letter. Each algebraic variable has an associated domain, , which is the set of values the variable can take.
A discrete variable is one whose domain is finite or countably infinite. A binary variable is a discrete variable with two values in its domain. One particular case of a binary variable is a Boolean variable, which is a variable with domain , . We can also have variables that are not discrete; for example, a variable whose domain corresponds to the real line or an interval of the real line is a continuous variable.
Given a set of variables, an assignment on the set of variables is a function from the variables into the domains of the variables. We write an assignment on as , where is in . This assignment specifies that, for each , variable is assigned value . A variable can only be assigned one value in an assignment. A total assignment assigns all of the variables. Assignments do not have to be total, but may be partial.
A possible world is defined to be a total assignment. That is, it is a function from variables into values that assigns a value to every variable. If world is the assignment , we say that variable has value in world .
The variable Class_time may denote the starting time for a particular class. The domain of Class_time may be the following set of possible times:
The variable Height_joe may refer to the height of a particular person at a particular time and have as its domain the set of real numbers, in some range, that represent the height in centimeters. Raining may be a random variable with domain , , which has value true if it is raining at a particular time.
The assignment specifies that the class starts at 11, Joe is 165cm tall and it is not raining.
In the electrical environment of Figure 1.8, there may be a variable for the position of each switch that specifies whether the switch is up or down. There may be a variable for each light that specifies whether it is lit or not. There may be a variable for each component specifying whether it is working properly or if it is broken. Some variables that the following examples use include:
is a binary variable denoting the position of switch with domain , , where means switch is up, and means switch is down.
is a discrete variable denoting the status of switch with domain , where means switch is working normally, means it is installed upside down, means it is shorted and it allows electricity to flow whether it is up or down, means it is working intermittently, and means it is broken and does not allow electricity to flow.
Number_of_broken_switches is an integer-valued variable denoting the number of switches that are broken.
is a real-valued variable denoting the current, in amps, flowing through wire . means there are amps flowing through wire . We also allow inequalities between variables and constants; for example, is true when there are at least amps flowing through wire .
A world specifies the position of every switch, the status of every device, and so on. For example, a world may be described as switch 1 is up, switch 2 is down, fuse 1 is okay, wire 3 is broken, etc.
A classic example of a constraint satisfaction problem is a crossword puzzle. There are two different representations of crossword puzzles in terms of variables:
In one representation, the variables are the numbered squares with the direction of the word (down or across), and the domains are the set of possible words that can be used. For example, one_across could be a variable with domain ’ant’, ’big’, ’bus’, ’car’, ’has’. A possible world corresponds to an assignment of a word for each of the variables.
In another representation of a crossword, the variables are the individual squares and the domain of each variable is the set of letters in the alphabet. For example, the top-left square could be a variable with domain . A possible world corresponds to an assignment of a letter to each square.
A trading agent, in planning a trip for a group of tourists, may be required to schedule a given set of activities. There could be two variables for each activity: one for the date, for which the domain is the set of possible days for the activity, and one for the location, for which the domain is the set of possible towns where it may occur. A possible world corresponds to an assignment of a date and a town for each activity.
An alternative representation may have the days as the variables, with domains the set of possible activity–location pairs.
The number of worlds is the product of the number of values in the domains of the variables.
If there are two variables, with domain and with domain , there are six possible worlds, which we name as follows
If there are variables, each with domain size , there are possible worlds.
One main advantage of reasoning in terms of variables is the computational savings. Many worlds can be described by a few variables:
10 binary variables can describe worlds
20 binary variables can describe worlds
30 binary variables can describe worlds
100 binary variables can describe , worlds.
Reasoning in terms of thirty variables may be easier than reasoning in terms of more than a billion worlds. One hundred variables is not that many, but reasoning in terms of more than worlds explicitly is not possible. Many real-world problems have thousands, if not millions, of variables.