



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 Brooks Department of Computer Science University of San Francisco ?? Department of Computer Science — University of San Francisco – p.1/
distributed loosely coupled Last week, we talked about problems Primarily distributed search A large data set is divided across clients. Clients interact only with a central server; no client-client communication ?? Department of Computer Science — University of San Francisco – p.2/
In medium-coupled problems, each node can do a substantial amount of computing on its own A final solution will require communication between nodes. Actions taken by one node can affect other nodes. ?? Department of Computer Science — University of San Francisco – p.3/
Before the semester starts, Wolber sends every teacher an email: When and where do you want your classes? Each professor has their own constraints, and can come 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 schedules without consulting with anyone else. ?? Department of Computer Science — University of San Francisco – p.4/
Some choices require communication with a center (Wolber) Only one class in Kudlick at a time. Some classes may be constrained by other departments’ choices CS 110 and Calculus I should be at different times. Nodes start with a large set of constraints; some are eliminated by the center. Hopefully at least one viable schedule remains. If not, someone is “encouraged” to relax their constraints.
A constraint satisfaction problem is one of assigning values to variables so as to satisfy a set of constraints. Typically, any solution that satisfies the constraints is equally acceptable. Toy problems: N-queens map coloring Real problems: Scheduling CS classes Building a car Register allocation
More formally, a CSP consists of: }n , ..., x^2 , x^1 x{ a set of variables Each variable as a domain of possible values n , ..., D (^2) , D (^1) D , ...^2 , C^1 C and a set of constraints , etc 2 == 0, ymod 10 x < Unary constraints: etc , 50 y < + x < y, x Binary constraints: = 75^ nx + ... +^2 x +^1 x N-ary constraints: (a problem with N-ary constraints can be transformed 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 all solution. consistent constraints is called a We might might also have an objective function that lets us compare solutions. )n , ..., x^1 x( f = y ?? Department of Computer Science — University of San Francisco – p.8/
If the domain of all variables is continuous (i.e. real numbers) and constraints are all linear functions, we can to solve the problem. linear programming use This is actually the easy version (in P). Express the problem as a system of equations If variables are discrete, the problem is harder.
. dynamic programming We can use Often, variables have complex or symbolic values. In the most general case, we can express a CSP as a search problem. ?? Department of Computer Science — University of San Francisco – p.9/
We can use depth-first search to solve a CSP Begin with an initial state: no values assigned to n , ..., x (^1) x Sequentially assign values to variables. We are done if we find an assignment to each variable such that all constraints are met. Since CSPs are commutative (for a solution, it doesn’t matter which order values are assigned) we can consider one variable at a time. ?? Department of Computer Science — University of San Francisco – p.10/
With CSPs, the challenge is deciding how to proceed when a constraint is violated. Some assignment of values to variables must be undone, but which? backtracking This decision is called Standard DFS undoes the most recently assigned value. chronological backtracking This is called Easy to implement Problem: an early assignment may have doomed us to an inconsistent solution.
WesternAustralia NorthernTerritory SouthAustralia Queensland NewSouth Wales Victoria Tasmania Three-coloring the map of Australia Assigning Q = red, NSW = green, V = blue, T = red cannot lead to a solution. Different values for T will not change this. V needs a different value.
, which x2 adds to its local view.1) , 1 x( x1 returns x2 checks its current assignment and its local view against the list of nogoods. is a nogood. 2)) , 2 x( ,1) , 1 x (( Therefore, x2, can’t find a consistent value, and so it back to x1. 1)) , 1 x( nogood,( sends x1 receives the nogood. Since there are no other processes included, x1 knows that it must change its value. to x2 and x3. 1)) , 1 x( ,?ok( and resends 2) , 1 x( It chooses x2 can safely also choose 2. When x3 gets the message, to x2. 2)) , 3 x( ,2) , 1 x( ,?ok( it sends ?? Department of Computer Science — University of San Francisco – p.19/
Guaranteed to terminate and find a solution if one exists (complete). Same process as single-processor backtracking If an variable can’t be assigned a value, undo the next-most-recent variable. More communication, due to asynchronicity. ?? Department of Computer Science — University of San Francisco – p.20/
A problem with asynchronous backtracking is the statically defined priorities. In the example, a poor choice by x1 influenced everything. A bad choice by a high-priority agent might cause a great deal of needless resetting of variables. Rather than just sending a nogood to the lowest-priority process, we use a heuristic. ?? Department of Computer Science — University of San Francisco – p.21/
Each process gets a priority value assigned dynamically. When an agent can’t find a value that satisfies all constraints, it: chooses a value that minimizes constraint violations is the highest k , where+ 1 k increases its priority to nogood received. Sends nogoods to all lower-priority processes. ?? Department of Computer Science — University of San Francisco – p.22/
a1(0) a2(0) a3(0) a4(0) One agent per row Initially all priorities are 0. All agents send ok? messages to each other. a4 is unable to find an as- signment consistent with its local view.
a1(0) a2(0) a3(0) a4(1) a4 sends 4)) , 4 a( , 2) , 3 a( , 4) , 2 a( , 1) , 1 a( nogood ( messages to all other agents. a4 increments its priority. Chooses a new value that minimizes constraints, given its local view. 4 = 3 a a4 sends ok? messages to all other processes.
a1(0) a2(0) a3(2) a4(1) a3 receives a4’s ok? and tries to find a new value. No consistent value Selects 1 to minimize conflicts Increments priority to 2 (since a4 was 1). Sends ok? to all lower priorities. a2 and a4 are fine with this choice. ?? Department of Computer Science — University of San Francisco – p.25/
a1(0) a2(0) a3(2) a4(1) a1 has a conflict with a3, and moves to 2. Consistent, so no need to send nogoods. The solution satisfies all constraints. Notice that the original problem stemmed from a bad choice by a1. Unlike asynchronous backtracking, this algorithm doesn’t exhaustively search a2’s choices before changing a1. ?? Department of Computer Science — University of San Francisco – p.26/
Backtracking and weak-commitment are examples of algorithms that construct consistent partial solutions. Each node tries to select values that are consistent with some other subset of nodes. We can also use hill-climbing to solve this problem Sometimes called iterative improvement. Premise start with a complete but flawed solution and try to apply improvements. ?? Department of Computer Science — University of San Francisco – p.27/
We can use the min-conflict heuristic to guide hill-climbing. Start with a random assignment of values to variables. foreach variable: Choose the value that minimizes the number of conflicts Repeat until: A solution is found A local optimum is reached. ?? Department of Computer Science — University of San Francisco – p.28/
helps us jump out of local optima. Breakout Each constraint starts with a weight of 1. When a local optimum is found, all currently-violated constraints have their weights increased by 1. This makes nearby states more appealing, and “pushes” the hillclimber out of the optimum. Like all hill-climbing algorithms, this is not complete, but can be tuned to work well in practice.
We can also construct a distributed version of breakout. Neighbors exchange possible assignments, and the agent whose assignment produces maximal improvement is chosen. Agents detect that subgroups are trapped in a quasi-local minimum. (no need to solve consensus to detect a local minimum). is in a quasi-local minimum if it is violating a^ i x constraint, and the improvement of all of its neighbors is 0. In other words, no hill can be climbed in the agent’s immediate vicinity.