



























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




























Chris BrooksDepartment of Computer ScienceUniversity of San Francisco
Department of Computer Science — University of San Francisco – p. 1/
-^ Last week, we talked about
loosely coupled
distributed problems^ •^ Primarily distributed search • A large data set is divided across clients. • Clients interact only with a central server; noclient-client communication
Department of Computer Science — University of San Francisco – p. 2/
-^ Before the semester starts, Benson sends everyteacher an email: When and where do you want yourclasses? •^ Each professor has their own constraints, and cancome up with choices locally:^ •^ Brooks: no classes before 10 am, in Kudlick^ •^ Wolber: No classes on Friday^ •^ Galles: Mornings, nothing on Lone Mountain. •^ Brooks is able to eliminate some possible scheduleswithout consulting with anyone else.
Department of Computer Science — University of San Francisco – p. 4/
-^ Some choices require communication with a center(Benson)^ •^ Only one class in Kudlick at a time.^ •^ Some classes may be constrained by otherdepartments’ choices^ •^ CS 110 and Calculus I should be at differenttimes. •^ Nodes start with a large set of constraints; some areeliminated by the center. •^ Hopefully at least one viable schedule remains.^ •^ If not, someone is “encouraged” to relax theirconstraints.
Department of Computer Science — University of San Francisco – p. 5/
-^ More formally, a CSP consists of:^ •^ a set of variables
{x, x, ..., x^12
}n
-^ Each variable as a domain of possible values^ D, D^12
, ..., Dn
-^ and a set of constraints
C, C, ...^12
-^ Unary constraints:
x <^10 , ymod
2 == 0, etc
-^ Binary constraints:
x < y, x^
+^ y <^50 ,^ etc
-^ N-ary constraints:
x+^ x+^1
...^ +^ x= 75n^
-^ (a problem with N-ary constraints can betransformed into a binary constraint problem,with an increase in the number of variables)
Department of Computer Science — University of San Francisco – p. 7/
-^ An assignment of values to variables that satisfies allconstraints is called a
consistent
solution.
-^ We might might also have an objective function^ y^ =^ f^ (x
, ..., x)^1 n that lets us compare solutions.
Department of Computer Science — University of San Francisco – p. 8/
-^ We can use depth-first search to solve a CSP^ •^ Begin with an initial state: no values assigned to^ x, ..., x^1
n
-^ Sequentially assign values to variables. •^ We are done if we find an assignment to eachvariable such that all constraints are met. • Since CSPs are commutative (for a solution, it doesn’tmatter which order values are assigned) we canconsider one variable at a time.
Department of Computer Science — University of San Francisco – p. 10/
-^ With CSPs, the challenge is deciding how to proceedwhen a constraint is violated.^ •^ Some assignment of values to variables must beundone, but which?^ •^ This decision is called
backtracking
-^ Standard DFS undoes the most recently assignedvalue. •^ This is called
chronological backtracking
-^ Easy to implement •^ Problem: an early assignment may have doomedus to an inconsistent solution.
Department of Computer Science — University of San Francisco – p. 11/
-^ In some cases, the variables in a CSP may bedistributed over multiple nodes or processes oragents.^ •^ Natural division of problem (e.g. scheduling ameeting, coordinating research teams)^ •^ Information may be private, or difficult to quantifyand share. •^ Constraints may be intra-agent or inter-agent. •^ Agents communicate by message passing withasynchronous communication.
Department of Computer Science — University of San Francisco – p. 13/
-^ For purposes of demonstration, we’ll make thefollowing assumptions:^ •^ Each process has a single variable^ •^ All variables have binary values^ •^ All constraints are binary. •^ Note: this is just to keep the examples simple; thealgorithms work fine without these assumptions.
Department of Computer Science — University of San Francisco – p. 14/
x^
x {1,2}^ {2}^ !=!= x3 {1,2}
-^ x1 and x3 can be either1 or 2. •^ x2 can only be 2. •^ x1 != x3, x2 != x3 •^ (we^ can
see^ that
the only solution is x1 = x2= 2, x3 = 1)^ Department of Computer Science — University of San Francisco – p. 16/
-^ Each node sends messages to other nodes that itshares a constraint with.^ •^ Includes all known assignments •^ For example, x1 sends an
(ok?,^ (x^1
,^ 1))^ to x3.
-^ x2 sends
(ok?,^ (x^2
,^ 2))^ to x3.
-^ x3 constructs a
local view
from this:
((x^1 ,^ 1), (x^2 ,^ 2))
-^ x3 cannot choose a value consistent with this localview.
Department of Computer Science — University of San Francisco – p. 17/
-^ x1 returns
(x^1 ,^ 1), which x2 adds to its local view.
-^ x2 checks its current assignment and its local viewagainst the list of nogoods.^ •^ ((x^1
,^ 1),^ (x^2 ,^ 2))
is a nogood.
-^ Therefore, x2, can’t find a consistent value, and so itsends (nogood,
(x^1 ,^ 1))^ back to x1.
-^ x1 receives the nogood. Since there are no otherprocesses included, x1 knows that it must change itsvalue. •^ It chooses
(x^1 ,^ 2)^ and resends
(ok?,^ (x^1
,^ 1))^ to x2 and
x3. • x2 can safely also choose 2. When x3 gets themessage, it sends
(ok?,^ (x^1
,^ 2),^ (x^3 ,^ 2))
to x2. Department of Computer Science — University of San Francisco – p. 19/
-^ Guaranteed to terminate and find a solution if oneexists (complete). •^ Same process as single-processor backtracking •^ If an variable can’t be assigned a value, undo thenext-most-recent variable. •^ More communication, due to asynchronicity.
Department of Computer Science — University of San Francisco – p. 20/