



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Notes; Class: Distributed Software Develop; Subject: Computer Science; University: University of San Francisco (CA); Term: Unknown 1989;
Typology: Study notes
1 / 6
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/
??
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; no client-clientcommunication
Department of Computer Science — University of San Francisco – p. 2/
??
In medium-coupled problems, each node can do a substantialamount 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 Fra
Before the semester starts, Benson sends every teacher anemail: When and where do you want your classes?
-^
Each professor has their own constraints, and can come upwith 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 withoutconsulting 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 other departments’choices^ •^
CS 110 and Calculus I should be at different times.
Nodes start with a large set of constraints; some are eliminatedby the center.
-^
Hopefully at least one viable schedule remains.
If not, someone is “encouraged” to relax their constraints.
Department of Computer Science — University of San Francisco – p. 5/
??
A constraint satisfaction problem is one of assigning values tovariables so as to satisfy a set of constraints.
-^
Typically, any solution that satisfies the constraints is equallyacceptable.
-^
Toy problems:^ ◦
N-queens ◦^
map coloring
Real problems:^ ◦
Scheduling CS classes ◦^
Building a car ◦^
Register allocation
Department of Computer Science — University of San Fra
More formally, a CSP consists of:^ ◦
a set of variables
x
, x 1
, ..., x 2
}n
Each variable as a domain of possible values
n
and a set of constraints
Unary constraints:
x <
, ymod
, etc
Binary constraints:
x < y, x
y <
,^ etc
N-ary constraints:
x
1
x
2
x
n^
(a problem with N-ary constraints can be transformed intoa binary constraint problem, with an increase in thenumber 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/
??
If the domain of all variables is continuous (i.e. real numbers)and constraints are all linear functions, we can use
linear
programming
to solve the problem.
This is actually the easy version (in P).^ ◦
Express the problem as a system of equations
If variables are discrete, the problem is harder.
-^
We can use
dynamic programming
Often, variables have complex or symbolic values.
-^
In the most general case, we can express a CSP as a searchproblem.
Department of Computer Science — University of San Fra
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 each variable suchthat all constraints are met.
Since CSPs are commutative (for a solution, it doesn’t matterwhich order values are assigned) we can consider one variableat a time.
Department of Computer Science — University of San Francisco – p. 10/
??
With CSPs, the challenge is deciding how to proceed when aconstraint is violated.
Some assignment of values to variables must be undone,but which? ◦^
This decision is called
backtracking
Standard DFS undoes the most recently assigned value. ◦^
This is called
chronological backtracking
Easy to implement ◦^
Problem: an early assignment may have doomed us to aninconsistent solution.
Department of Computer Science — University of San Francisco – p. 11/
??
WesternAustralia
NorthernTerritory
SouthAustralia
Queensland
NewSouthWales Victoria
Tasmania
Three-coloring the map ofAustralia
-^
Assigning Q = red, NSW =green, V = blue, T = redcannot lead to a solution.
-^
Different values for T willnot change this.
-^
V needs a different value.
Department of Computer Science — University of San Fran
x1 returns
x
, which x2 adds to its local view.
x2 checks its current assignment and its local view against thelist of nogoods.^ ◦
x
x
is a nogood.
Therefore, x2, can’t find a consistent value, and so it sends (nogood,
(x
back to x1.
x1 receives the nogood. Since there are no other processesincluded, x1 knows that it must change its value.
-^
It chooses
x^1
and resends
ok
(x
to x2 and x3.
x2 can safely also choose 2. When x3 gets the message, itsends
ok
(x
x
to x2.
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 thenext-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 staticallydefined priorities.^ ◦
In the example, a poor choice by x1 influenced everything. ◦^
A bad choice by a high-priority agent might cause a greatdeal of needless resetting of variables.
Rather than just sending a nogood to the lowest-priorityprocess, we use a heuristic.
Department of Computer Science — University of San Fran
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 ◦ increases its priority to
k
, where
k
is the highest 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 itslocal view.
Department of Computer Science — University of San Francisco – p. 23/
??
a1(0)a2(0)a3(0)a4(1)
a4 sends (nogood
(a
a
a^3
a
messages to all other agents.
-^
a4 increments its priority.
-^
Chooses a new value thatminimizes constraints, given itslocal view.^ ◦
a
a4 sends ok? messages to allother processes.
Department of Computer Science — University of San Fran
a1(0)a2(0) a3(2)a4(1)
a3 receives a4’s ok? andtries to find a new value.
-^
No consistent value^ ◦
Selects 1 to minimizeconflicts ◦^
Increments priority to 2(since a4 was 1). ◦^
Sends ok? to all lowerpriorities. ◦^
a2 and a4 are fine withthis 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, andmoves to 2.
-^
Consistent, so no need to sendnogoods.
-^
The solution satisfies allconstraints.
-^
Notice that the original problemstemmed from a bad choice by a1.^ ◦
Unlike asynchronousbacktracking, this algorithmdoesn’t exhaustively searcha2’s choices before changinga1.
Department of Computer Science — University of San Francisco – p. 26/
??
Backtracking and weak-commitment are examples ofalgorithms that construct consistent partial solutions.^ ◦
Each node tries to select values that are consistent withsome 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 toapply improvements.
Department of Computer Science — University of San Fran
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/
??
Breakout
helps us jump out of local optima.
Each constraint starts with a weight of 1.
-^
When a local optimum is found, all currently-violatedconstraints have their weights increased by 1.
This makes nearby states more appealing, and “pushes” thehillclimber out of the optimum.
Like all hill-climbing algorithms, this is not complete, but can betuned to work well in practice.
Department of Computer Science — University of San Francisco – p. 29/
??
We can also construct a distributed version of breakout.
-^
Neighbors exchange possible assignments, and the agentwhose assignment produces maximal improvement is chosen.
-^
Agents detect that subgroups are trapped in a quasi-localminimum. (no need to solve consensus to detect a localminimum).^ ◦
xi
is in a quasi-local minimum if it is violating a constraint, and the improvement of all of its neighbors is 0. ◦^
In other words, no hill can be climbed in the agent’simmediate vicinity.
Department of Computer Science — University of San Fran