Distributed Software Develop - Problem Solving II | 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/31/2009

koofers-user-slu-1
koofers-user-slu-1 🇺🇸

9 documents

1 / 6

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
Departmentof Computer Science University of San Francisco p. 1/??
21-2: 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-client
communication
Departmentof Computer Science University of San Francisco p. 2/??
21-3: “Medium-coupled” problems
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.
Departmentof Computer Science University of San Francisco
21-4: Example: scheduling classes
Before the semester starts, Benson 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.
Departmentof Computer Science University of San Francisco p. 4/??
21-5: Example: scheduling classes
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 eliminated
by the center.
Hopefully at least one viable schedule remains.
If not, someone is “encouraged” to relax their constraints.
Departmentof Computer Science University of San Francisco p. 5/??
21-6: Constraint Satisfaction
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.
Toyproblems:
N-queens
map coloring
Real problems:
Scheduling CS classes
Building a car
Register allocation
Departmentof Computer Science University of San Francisco
pf3
pf4
pf5

Partial preview of the text

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

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/

??

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/

??

“Medium-coupled” problems

•^

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

Example: scheduling classes

•^

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/

??

Example: scheduling classes

•^

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/

??

Constraint Satisfaction

•^

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

Constraint Satisfaction

•^

More formally, a CSP consists of:^ ◦

a set of variables

x

, x 1

, ..., x 2

}n

◦^

Each variable as a domain of possible values

D

, D 1

, ..., D 2

n

◦^

and a set of constraints

C

, C 1

•^

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/

??

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/

??

Approaches

•^

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

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 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/

??

Backtracking

•^

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/

??

Example

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

Asynchronous Backtracking Example

•^

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

,^ 2)

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/

??

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/

??

Asynchronous Weak-commitment Search

•^

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

Asynchronous Weak-commitment Search

•^

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/

??

Example

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/

??

Example

a1(0)a2(0)a3(0)a4(1)

•^

a4 sends (nogood

(a

,^ (

a

,^ (

a^3

,^ 2)

,^ (

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

Example

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/

??

Example

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/

??

Breakout

•^

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

Breakout

•^

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

•^

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/

??

Distributed Breakout

•^

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