Dynamic Csp Thesis

download Dynamic Csp Thesis

of 50

Transcript of Dynamic Csp Thesis

  • 8/13/2019 Dynamic Csp Thesis

    1/50

    Dynamic Flexible Constraint

    Satisfaction and Its Application toAI Planning

    Ian Miguel

    AI GroupDepartment of Computer Science

    University of York

  • 8/13/2019 Dynamic Csp Thesis

    2/50

    Outline

    Part I Constraint Satisfaction.

    Weaknesses/Remedies.

    Dynamic Flexible Constraint Satisfaction. Part II

    AI Planning.

    Flexible Planning. Plan Synthesis via dynamic flexible CSP.

  • 8/13/2019 Dynamic Csp Thesis

    3/50

  • 8/13/2019 Dynamic Csp Thesis

    4/50

    The Constraint Satisfaction Problem

    (CSP)

    Given:

    1. A set of variables.2. Each variable has an associated finite domainof

    potential values.

    3. A set of constraintsover these variables.

    Find:

    A complete assignmentof values to variables that

    satisfies all constraints.

    Specify allowed combinations of assignments

    of values to variables.

  • 8/13/2019 Dynamic Csp Thesis

    5/50

    Applications

    Combinatorial Mathematics.

    Fault diagnosis.

    Machine vision.

    Planning.

    Scheduling. Systems Simulation.

    Csplib.org

  • 8/13/2019 Dynamic Csp Thesis

    6/50

    Example CSPCourse Scheduling

    Decide the number of lecture, exercise and

    training sessions.

    So we need 3 variables.

    Constraints:

    There must be a total of 8 sessions.

    Professor A will give 4 or 5 lectures.

    Dr B will give 3 or 4 exercise sessions.

    There must be 1 or 2 training sessions.

    These unary constraints

    determine the domains

    in this simple example.

  • 8/13/2019 Dynamic Csp Thesis

    7/50

    Solving CSPs

    Most often depth-first search (I.e. Backtrack). Select an unassigned variable.

    Select a value compatible with all previously

    assigned variables.

    If no such value, backtrack and find a new value for

    previous variableRoot

    1stvariable

    2ndvariable

  • 8/13/2019 Dynamic Csp Thesis

    8/50

    Course Scheduling: A Solution

    Lectures = 4

    Exercise = 3

    Training = 1

    Constraints:

    There must be a total of 8 sessions.

    Professor A will give 4 or 5 lectures. Dr B will give 3 or 4 exercise sessions.

    There must be 1 or 2 training sessions.

  • 8/13/2019 Dynamic Csp Thesis

    9/50

    The Problem Changes

    Constraints: There must be a total of 8 sessions.

    Professor A will now give 3 or 4lectures.

    Dr B agrees to give 4 or 5exercise sessions. There must be 1 or 2 training sessions.

    The solution to the old problem:

    Lectures = 4 Exercise = 3

    Training = 1

  • 8/13/2019 Dynamic Csp Thesis

    10/50

    Weakness 1: Static Formulation

    Classical CSP has no way of dealing with this

    change gracefully.

    Naively we can solve the new problem from scratch.

    This wastes all work on the old problem!

    So?

    We use an extension called dynamic CSP.

  • 8/13/2019 Dynamic Csp Thesis

    11/50

    Dynamic CSP

    A dynamic environment is viewed as a sequenceof static CSPs.

    Linked by:

    Restriction(constraints added)

    Relaxation(constraints removed)

  • 8/13/2019 Dynamic Csp Thesis

    12/50

    Solving Dynamic CSPs

    Oracles:

    Start from scratch.

    Previous solution guides value assignment.

    Local Repair:

    Start from previous solution.

    Modify individual assignments until find a solution.

    Constraint Recording:

    Record new constraints during search.

    Carry new constraints over to future problems to

    restrict search there.

  • 8/13/2019 Dynamic Csp Thesis

    13/50

    Course Scheduling

    In problem 2:

    Dr B agrees to give 4 or 5exercise sessions.

    Problem 1 Problem 2Solution:

    Lectures = 4

    Exercise = 3

    Training = 1

    Solution:

    Lectures = 3

    Exercise = 4

    Training = 1Incompatible with

    solution to problem 1

    Repair method:

    Start with violated exercise constraint: Exercise = 4

    Then repair violated sum constraint: Lectures = 3

  • 8/13/2019 Dynamic Csp Thesis

    14/50

    The Problem Changes Again

    Constraints: There must be a total of 7sessions.

    Professor A will give 3 or 4 lectures.

    Dr B will give 4 or 5 exercise sessions. There must be 1 or 2 training sessions.

    This problem has no solution.

  • 8/13/2019 Dynamic Csp Thesis

    15/50

    Weakness 2: Hard Constraints

    Classical CSP has no way of finding acompromise.

    Constraints are hard:

    Imperative: Valid solution must satisfy all of them. Inflexible: Constraints wholly satisfied or wholly

    violated.

    So? We use an extension called flexible CSP.

  • 8/13/2019 Dynamic Csp Thesis

    16/50

    Flexible CSP

    An umbrella term for a variety of methods.

    Max-CSP: Maximise the number of

    satisfied constraints/Minimise violations.

    WeightedMax-CSP.

    Weighted Preference.

    FuzzyCSP.

    General frameworks:

    Partial CSP, Valued CSP, Semi-ring CSP.

  • 8/13/2019 Dynamic Csp Thesis

    17/50

    Solving Flexible CSPs

    Branch and boundis most common technique. Search for a first solution (minimise violations).

    Use this as a bound on future solutions.

    As soon as current search branch can be shown to be

    equal or exceed the bound, prune it.

    When a new solution is found, use as new bound,

    etc

    New bound

    E.g. 3 violatedconstraints.

    Equals bound:

    3 violated

    already. Prune.

  • 8/13/2019 Dynamic Csp Thesis

    18/50

    Course Scheduling

    In problem 3:

    There must be a total of 7sessions.

    Problem 2 Problem 3Solution:

    Lectures = 3

    Exercise = 4

    Training = 1

    Incompatible with

    solution to problem 2

    Max-CSP: Pretty good solutiononly 1 violated

    constraint.

    Or attach priorities/preferences to each constraint.

  • 8/13/2019 Dynamic Csp Thesis

    19/50

    The Gap in the Market

    Dynamic CSP research is founded almost

    exclusively on hard constraints.

    Flexible CSP research is founded almostexclusively on static problems.

    We want to combine the two to bring to

    bear the benefits of both.

  • 8/13/2019 Dynamic Csp Thesis

    20/50

    Dynamic Flexible CSP

    Also an umbrella term for a variety of methods.

    FlexibleCSP

    Techniques

    Dynamic CSP Techniques

    DFCSP Instance

    Solution methods

    Max

    Weighted

    Max

    WeightedPreference

    Fuzzy

  • 8/13/2019 Dynamic Csp Thesis

    21/50

    Fuzzy rrDFCSP

    Restriction/Relaxation DCSP + Fuzzy CSP.

    Fuzzy CSP:

    A totally ordered satisfaction scale.

    Endpoints signify total violation/satisfaction.

    Constraints modelled by fuzzy relations: map

    variable assignments to points in the scale. Overall satisfaction determined by fuzzy

    conjunction: the minoperator.

  • 8/13/2019 Dynamic Csp Thesis

    22/50

    Two Algorithms

    Dynamic version of a flexible CSP algorithm.

    Using oraclesmethod.

    Flexible version of a dynamic CSP algorithm. Flexible Local Changes.

    Each algorithm has several variants, which do

    an increasing amount of work to spot deadends early.

  • 8/13/2019 Dynamic Csp Thesis

    23/50

    Flexible Local Changes

    Complete Local repair algorithm.

    Divides Variables into three sets:

    1. Assigned & Fixed.

    2. Assigned & Not Fixed.

    3. Unassigned.

    Uses these sets to control search

    procedure.

  • 8/13/2019 Dynamic Csp Thesis

    24/50

    Flexible Local Changes: Operation

    Maintain aboundon best

    solution found for each

    sub-problem.

    1. Assigned & Fixed.

    2. Assigned & Not Fixed.

    3. Unassigned.

    1 2 3 1 2 3

    1 2 3 1 2 3

    1 2 3

    1 2 3

    Sub-sub problem

    solved.

    Sub-problemsolved.

  • 8/13/2019 Dynamic Csp Thesis

    25/50

    Experiments

    We wanted to investigate:

    The structure of fuzzy rrDFCSPs.

    The relative performance of the algorithms.

    We varied:

    Problem size.

    Connectivity.

    Proportion of variables related by a constraint.

    Constraint tightness. Proportion of disallowed value combinations.

    Satisfaction scale size.

    The amount of changebetween instances.

    Each sequence contains 10 problems.

  • 8/13/2019 Dynamic Csp Thesis

    26/50

    Experiments: Measurements

    Constraint checks.

    Every time we query a constraint for the

    satisfaction degree of an assignment.

    Search nodes.

    Every time we assign a value to a variable.

    Size of search tree.

    Solution stability.

    Proportion of assignments that remain the same

    between instances.

  • 8/13/2019 Dynamic Csp Thesis

    27/50

    Results: Search Effort Mean over 3 sequences of 10 instances.

    Scale size: 3, Change 1 constraint between instances.

    Instance size: 20 variables, connectivity: 0.25

    0

    500

    1000

    1500

    2000

    2500

    0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9

    Tightness

    Checks

    FLC

    BB

  • 8/13/2019 Dynamic Csp Thesis

    28/50

    Search Effort: Trends

    Branch and bound finds solutions moreefficiently than FLC.

    BB has a more rigid search structure.

    This allows stronger inferences to be made at eachnode in the search tree.

    Result: BB spots dead ends earlier.

    Algorithm variants: Doing more work to spot dead ends guarantees a

    smaller or equal-sized search tree.

    But often costs more in terms of constraint checks.

  • 8/13/2019 Dynamic Csp Thesis

    29/50

    Search Effort: Trends

    Phase transition behaviour.

    Increasing some parameters generally increases

    difficulty:

    Problem size.

    Connectivity.

    Size of satisfaction degree scale.

    Amount of change between instances.

  • 8/13/2019 Dynamic Csp Thesis

    30/50

    Results: Stability

    Scale size: 3, Change 1 constraint between instances Problem size: 20 variables, connectivity: 0.25

    90

    91

    92

    93

    94

    95

    96

    97

    98

    99

    100

    0.1 0.2 0.3 0.4 0.5 0.6

    Tightness

    Stability

    FLC

    BB

  • 8/13/2019 Dynamic Csp Thesis

    31/50

    Stability: Trends

    FLC produces more stable solutions than BB. Both algorithms prefer stable assignments where

    possible.

    FLC actively seeks to leave areas of the previous

    solution undisturbed.

    Variants: More work to spot dead ends means

    more stability.

    Extra work gives us a better idea of the utility of

    potential assignments.

    Can reveal that they are no better than our

    preferred stable assignment.

  • 8/13/2019 Dynamic Csp Thesis

    32/50

    Utility of Dynamic Information

    We tested `crippled versions of the algorithms.

    Branch and bound loses its oracle.

    FLC starts from an empty assignment. Crippled versions:

    Explore significantly larger search trees.

    Give significantly lower solution stability. Extent varies according to the particular dynamic

    sequence.

  • 8/13/2019 Dynamic Csp Thesis

    33/50

    Part II

    Application to AI Planning

  • 8/13/2019 Dynamic Csp Thesis

    34/50

    Plan: Course of action to achieve pre-specified

    goals.

    Components of a planning problem:

    Plan objects.

    Initial state.

    Goal state.

    Operators.

    AI Planning

    c1 c2 c4

    c3

    r

    r2 r3

    m1 m2

    pkg1 pkg2

    guard1

  • 8/13/2019 Dynamic Csp Thesis

    35/50

    Characteristics of AI Planning

    Inflexible operators.

    Imperative goals.

    Suffers from similar problems to classical CSP.

    If no perfect solution, no plan returned.

    We want to give the planner the ability to

    compromise.

  • 8/13/2019 Dynamic Csp Thesis

    36/50

    Flexible Planning

    Incorporate preferences into operators and goals.

    Model both via fuzzy relations:

    Map from preconditions onto a totally ordered

    satisfaction scale.

    Load-truck operator has preconditions:

    Truck and package in same place.

    Guard must be present.

    Can relax, with associated

    damage to resultant plan

    Imperative

    Preference

  • 8/13/2019 Dynamic Csp Thesis

    37/50

    Example

    Goals:

    Both packages to c4

    .

    pkg2is worth less, dont deliver: l1

    Guard to c3.

    Can also leave guard at c2or c4: l2

    c1 c2 c4

    c3

    r1

    r2 r3

    m1 m2

    pkg1 pkg2

    guard1

    L={l , l1, l2, lT}

  • 8/13/2019 Dynamic Csp Thesis

    38/50

    Example

    Operators:

    Drive-truck.

    Avoid mountains or: l1 Load/Unload-truck.

    For valuable package, guard present or: l2 Guard-boards/leaves-truck.

    c1 c2 c4

    c3

    r1

    r2 r3

    m1 m2

    pkg1 pkg2

    guard1

    L={l , l1, l2, lT}

  • 8/13/2019 Dynamic Csp Thesis

    39/50

    Graphplan

    Solution procedure for classical planning problems. Constructs/analyses aplanning graph.

    Forward phase extends planning graph until goals found.

    Add binary mutexconstraints betweenactions/propositions that conflict.

    Backward phase extracts valid plan.Inconsistent:

    Preconditions

    Effects

    Initial

    Conditions

    Actions1 Propositions1

    . . .

    . . .

    . . .

  • 8/13/2019 Dynamic Csp Thesis

    40/50

    The Flexible Planning Graph

    Actions annotated with their satisfaction degrees.

    Actions1 Propositions1. . .

    . . .

    . . .

    l2

    l3

    l1

  • 8/13/2019 Dynamic Csp Thesis

    41/50

    The CSP Viewpoint

    Variables: proposition nodes. Domains: actions who assert these propositions

    as effects.

    Constraints: Binary mutex + Unary fuzzy.Actions1 Propositions1

    . . .

    . . .

    . . .

    l2

    l3

    l1

  • 8/13/2019 Dynamic Csp Thesis

    42/50

    Plan Synthesis via Fuzzy rrDFCSP

    Goals, and their domains form a first sub-problem. Action pre-conditions specify new sub-problems

    GoalSub-problem

    Solutions at level nare likely to intersect.

    So, problems at level n-1form a related sequence:

    Each level is a DFCSP.

  • 8/13/2019 Dynamic Csp Thesis

    43/50

    Guiding Overall Search

    Goal: Solve as few sub-problems as possible. Generate memosetsfrom unsolvable sub-problems.

    Propagate memosets up the level hierarchy.

    Goal

    Sub-problem

  • 8/13/2019 Dynamic Csp Thesis

    44/50

    4-step Solution

    1. Load-truckpkg1

    truckl2

    .

    2. Drive-trucktruckc1to c2via r1 lT.

    3. Drive-trucktruckc2to c4via m2 l1.

    4. Unload-truckpkg1truckl2.

    c1 c2 c4

    c3

    r1

    r2 r3

    m1 m2

    pkg1 pkg2guard1

    L={l , l1, l2, lT}

    Satisfaction: l1

  • 8/13/2019 Dynamic Csp Thesis

    45/50

    6-step Solution

    1. Load-truckpkg1truckl2.

    2. Drive-trucktruckc1to c2via r1 lT.

    3. Load-truckpkg2trucklT.

    4. Drive-trucktruckc2to c3via r2 lT.

    5. Drive-trucktruckc3to c4via r3 lT.

    6. Unload-truckpkg1truckl2,pkg2trucklT.

    c1 c2 c4

    c3

    r1

    r2 r3

    m1 m2

    pkg1 pkg2guard1

    L={l , l1, l2, lT}

    Satisfaction: l2

  • 8/13/2019 Dynamic Csp Thesis

    46/50

    Compromise-free Solution

    10 steps.

    First collect the guard. Return to loadpkg1.

    Use the main roads to deliver both packages

    and guard.

    c1 c2 c4

    c3

    r1

    r2 r3

    m1 m2

    pkg1 pkg2

    guard1L={l , l1, l2, lT}

  • 8/13/2019 Dynamic Csp Thesis

    47/50

    Flexible Graphplan: Observations

    It is more expensive to search for a range of

    plans than for one compromise-free plan.

    But it is often possible to find short,compromise plans quickly.

    Supports anytimebehaviour.

    Range of plans trade length versus numberand severity of the compromises made.

  • 8/13/2019 Dynamic Csp Thesis

    48/50

    Conclusions

    Dynamic flexible constraint satisfactioncombines two extensions to classical CSP.

    Multiple instances of DFCSP. Considered fuzzy rrDFCSP in detail.

    Two solution procedures (with variants).

    Flexible planning.

    Plan synthesis via hierarchical decompositionand fuzzy rrDFCSP.

  • 8/13/2019 Dynamic Csp Thesis

    49/50

    Future Work

    We have examined one instance of DFCSP

    in detail.

    Examine other instances. Modify existing solution techniques/consider

    new ones (e.g. local search).

    Other applications. Compositional Modelling [Keppens 2002].

    Dynamic Scheduling.

    Interactive configuration

  • 8/13/2019 Dynamic Csp Thesis

    50/50

    Acknowledgements

    Qiang Shen, University of Edinburgh.

    Peter Jarvis, SRI International.