Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Problem Solving II - Distributed Software Develop - Slides | CS 682, Study notes of Software Engineering

Material Type: Notes; Class: Distributed Software Develop; Subject: Computer Science; University: University of San Francisco (CA); Term: Unknown 1989;

Typology: Study notes

Pre 2010

Uploaded on 07/30/2009

koofers-user-mfx
koofers-user-mfx 🇺🇸

10 documents

1 / 35

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Distributed Software Development
Problem Solving II
Chris Brooks
Department of Computer Science
University of San Francisco
Department of Computer Science University of San Francisco p.1/??
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23

Partial preview of the text

Download Problem Solving II - Distributed Software Develop - Slides | CS 682 and more Study notes Software Engineering in PDF only on Docsity!

Distributed Software Development^ Problem Solving II

Chris BrooksDepartment of Computer ScienceUniversity of San Francisco^ Department of Computer Science — University of San Francisco – p.1/

17-0:^ Distributed Problem Solving

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/

17-2:^ Example: scheduling classes

Before the semester starts, Wolber sends every teacheran email: When and where do you want your classes? Each professor has their own constraints, and can comeup 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/

17-3:^ Example: scheduling classes

Some choices require communication with a center(Wolber)^ Only one class in Kudlick at a time.^ Some classes may be constrained by otherdepartments’ choices^ CS 110 and Calculus I should be at different times. 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/

17-5:^ Constraint Satisfaction

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, ..., D^12 n and a set of constraints

C, C, ...^12

Unary constraints:

x <^10 , ymod2 == 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 anincrease in the number of variables)

Department of Computer Science — University of San Francisco – p.7/

17-6:^ Formalizing a CSP

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/

17-8:^ Solving CSPs with search

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 variablesuch that all constraints are met. Since CSPs are commutative (for a solution, it doesn’tmatter which order values are assigned) we can considerone variable at a time.

Department of Computer Science — University of San Francisco – p.10/

17-9:^ Backtracking

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 doomed us toan inconsistent solution.

Department of Computer Science — University of San Francisco – p.11/

17-11:^ Distributed CSP

In some cases, the variables in a CSP may be distributedover multiple nodes or processes or agents.^ Natural division of problem (e.g. scheduling a meeting,coordinating research teams)^ Information may be private, or difficult to quantify andshare. 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/

17-12:^ Algorithms for Distributed CSP

For purposes of demonstration, we’ll make the followingassumptions:^ 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/

17-14:^ Asynchronous Backtracking

Example

x^

x2 !=!= x {1,2}^

{2} {1,2}

x1 and x3 can be either 1or 2. x2 can only be 2. x1 != x3, x2 != x3 (we can see that the onlysolution is x1 = x2 = 2, x3= 1)^ Department of Computer Science — University of San Francisco – p.16/

17-15:^ Asynchronous Backtracking

Example

Each node sends messages to other nodes that it sharesa 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 local view.

Department of Computer Science — University of San Francisco – p.17/

17-17:^ Asynchronous Backtracking

Example

x1 returns^ (x^1 ,

1), which x2 adds to its local view. x2 checks its current assignment and its local view againstthe 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 the message,it sends^ (ok?,^ (

x^1 ,^ 2),^ (x^3 ,^ 2))^ to x2.

Department of Computer Science — University of San Francisco – p.19/

17-18:^ Asynchronous backtracking

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/